Is there a way to explicitly force the compiler for building Cython extensions when running python setup.py install
? Where setup.py
is of the form:
I ended up putting this at the beginning of setup.py to force visual2015
useful when running in a non bat environment and starting vcvarsall from outside is not an option
if sys.platform == 'win32':
# patch env with vcvarsall.bat from vs2015 (vc14)
try:
cmd = '"{}..\\..\\VC\\vcvarsall.bat" x86_amd64 >nul 2>&1 && set'.format(environ['VS140COMNTOOLS'])
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except:
print("Error executing {}".format(cmd))
raise
for key, _, value in (line.partition('=') for line in out.splitlines()):
if key and value:
os.environ[key] = value
# inform setuptools that the env is already set
os.environ['DISTUTILS_USE_SDK'] = '1'