From 4dc2a451aba5ce44e962d0a13cccd30e355bca9e Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 18 Sep 2013 11:16:22 -0700 Subject: [PATCH] Bug 910487 - Hack binary Python extensions into building on Windows; r=mshal --- build/virtualenv/populate_virtualenv.py | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/build/virtualenv/populate_virtualenv.py b/build/virtualenv/populate_virtualenv.py index 14caa76d95d..fe069cd167c 100755 --- a/build/virtualenv/populate_virtualenv.py +++ b/build/virtualenv/populate_virtualenv.py @@ -12,6 +12,7 @@ import os import shutil import subprocess import sys +import warnings # Minimum version of Python required to build. @@ -273,6 +274,33 @@ class VirtualenvManager(object): old_env_variables[k] = os.environ[k] del os.environ[k] + # HACK ALERT. + # + # The following adjustment to the VSNNCOMNTOOLS environment + # variables are wrong. This is done as a hack to facilitate the + # building of binary Python packages - notably psutil - on Windows + # machines that don't have the Visual Studio 2008 binaries + # installed. This hack assumes the Python on that system was built + # with Visual Studio 2008. The hack is wrong for the reasons + # explained at + # http://stackoverflow.com/questions/3047542/building-lxml-for-python-2-7-on-windows/5122521#5122521. + if sys.platform in ('win32', 'cygwin') and \ + 'VS90COMNTOOLS' not in os.environ: + + warnings.warn('Hacking environment to allow binary Python ' + 'extensions to build. You can make this warning go away ' + 'by installing Visual Studio 2008. You can download the ' + 'Express Edition installer from ' + 'http://go.microsoft.com/?linkid=7729279') + + # We list in order from oldest to newest to prefer the closest + # to 2008 so differences are minimized. + for ver in ('100', '110', '120'): + var = 'VS%sCOMNTOOLS' % ver + if var in os.environ: + os.environ['VS90COMNTOOLS'] = os.environ[var] + break + for package in packages: handle_package(package) finally: