From 96dc809236f654fa60b50dd1e317bf977dbc0ca4 Mon Sep 17 00:00:00 2001 From: James Wettenhall Date: Wed, 22 Mar 2017 08:40:05 +1100 Subject: [PATCH] Adding support for Microsoft Visual C++ Compiler for Python 2.7 --- build.py | 4 ++++ wscript | 3 +++ 2 files changed, 7 insertions(+) diff --git a/build.py b/build.py index f170fdf2..9c233fc7 100755 --- a/build.py +++ b/build.py @@ -723,7 +723,9 @@ def checkCompiler(quiet=False): # Make sure that the compiler that Python wants to use can be found. # It will terminate if the compiler is not found or other exceptions # are raised. + # setuptools is imported to address https://bugs.python.org/issue23246 cmd = "import distutils.msvc9compiler as msvc; " \ + "import setuptools; " \ "mc = msvc.MSVCCompiler(); " \ "mc.initialize(); " \ "print(mc.cc)" @@ -734,7 +736,9 @@ def checkCompiler(quiet=False): # Now get the environment variables which that compiler needs from # its vcvarsall.bat command and load them into this process's # environment. + # setuptools is imported to address https://bugs.python.org/issue23246 cmd = "import distutils.msvc9compiler as msvc; " \ + "import setuptools; " \ "arch = msvc.PLAT_TO_VCVARS[msvc.get_platform()]; " \ "env = msvc.query_vcvarsall(msvc.VERSION, arch); " \ "print(env)" diff --git a/wscript b/wscript index 51754d7b..e73629bd 100644 --- a/wscript +++ b/wscript @@ -74,6 +74,7 @@ def configure(conf): msvc_version = str( distutils.msvc9compiler.get_build_version() ) conf.env['MSVC_VERSIONS'] = ['msvc ' + msvc_version] conf.env['MSVC_TARGETS'] = [conf.options.msvc_arch] + conf.env['NO_MSVC_DETECT'] = 1 conf.load('msvc') else: conf.load('compiler_cc compiler_cxx') @@ -415,6 +416,8 @@ def my_check_python_headers(conf): if env.CC_NAME == "msvc": from distutils.msvccompiler import MSVCCompiler + # setuptools is imported to address https://bugs.python.org/issue23246 + import setuptools dist_compiler = MSVCCompiler() dist_compiler.initialize() env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options)