aboutsummaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-08-10 18:01:29 +0100
committerCosimo Lupo <cosimo.lupo@daltonmaag.com>2015-08-11 11:12:49 +0100
commitc3540e2b7aff0f4632e1ea82cd2cfd55b1b11ff4 (patch)
treef560f0242c4d15050fc45e36a6c8aaee24d9a077 /setup.py
parentf14172902b9c21f4ed47a35ce467727f02867280 (diff)
downloadbrotli-c3540e2b7aff0f4632e1ea82cd2cfd55b1b11ff4.zip
brotli-c3540e2b7aff0f4632e1ea82cd2cfd55b1b11ff4.tar.gz
brotli-c3540e2b7aff0f4632e1ea82cd2cfd55b1b11ff4.tar.bz2
[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.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/setup.py b/setup.py
index 3b3419b..c78553e 100644
--- a/setup.py
+++ b/setup.py
@@ -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.