[setup.py] use MSVC 10.0 when compiling for Windows Python 2.7

Python 2.7 for Windows is compiled using MS Visaul C++ 9.0 (Visual Studio 2008).
However the latter does not support many modern C++ features which are
required to compile the Brotli encoder. So we monkey-patch distutils
to always look for MSVC version 10.0 instead of 9.0.
This commit is contained in:
Cosimo Lupo 2015-08-10 18:01:29 +01:00
parent f14172902b
commit c3540e2b7a

View File

@ -1,9 +1,24 @@
import distutils
from distutils.core import setup, Extension
from distutils.command.build_ext import build_ext
from distutils.cmd import Command
import platform
# when compiling for Windows Python 2.7, force distutils to use Visual Studio
# 2010 instead of 2008, as the latter doesn't support c++0x
if platform.system() == 'Windows':
try:
import distutils.msvc9compiler
except distutils.errors.DistutilsPlatformError:
pass # importing msvc9compiler raises when running under MinGW
else:
orig_find_vcvarsall = distutils.msvc9compiler.find_vcvarsall
def patched_find_vcvarsall(version):
return orig_find_vcvarsall(version if version != 9.0 else 10.0)
distutils.msvc9compiler.find_vcvarsall = patched_find_vcvarsall
class TestCommand(Command):
""" Run all *_test.py scripts in 'tests' folder with the same Python
interpreter used to run setup.py.