in setup.py [0:0]
def determine_generator_args():
if sys.platform == 'win32':
try:
# See which compiler python picks
compiler = distutils.ccompiler.new_compiler()
compiler.initialize()
# Look at compiler path to divine the Visual Studio version.
# This technique may not work with customized VS install paths.
# An alternative would be to utilize private python calls:
# (distutils._msvccompiler._find_vc2017() and _find_vc2015()).
if '\\Microsoft Visual Studio\\2019' in compiler.cc:
vs_version = 16
vs_year = 2019
elif '\\Microsoft Visual Studio\\2017' in compiler.cc:
vs_version = 15
vs_year = 2017
elif '\\Microsoft Visual Studio 14.0' in compiler.cc:
vs_version = 14
vs_year = 2015
assert(vs_version and vs_year)
except Exception:
raise RuntimeError('No supported version of MSVC compiler could be found!')
print('Using Visual Studio', vs_version, vs_year)
vs_version_gen_str = "Visual Studio {} {}".format(vs_version, vs_year)
if vs_year <= 2017:
# For VS2017 and earlier, architecture goes at end of generator string
if is_64bit():
vs_version_gen_str += " Win64"
return ['-G', vs_version_gen_str]
# For VS2019 (and presumably later), architecture is passed via -A flag
arch_str = "x64" if is_64bit() else "Win32"
return ['-G', vs_version_gen_str, '-A', arch_str]
return []