11Look for the first match in the format
12 C:\\Program Files (x86)\\Microsoft Visual Studio\\${RELEASE}\\${VERSION}\\VC
15 if sys.platform.startswith(
'win'):
16 default_dir =
r'C:\Program Files (x86)\Microsoft Visual Studio'
17 for release
in [
'2019',
'2017']:
18 for version
in [
'Enterprise',
'Professional',
'Community',
'BuildTools',
'Preview']:
19 path = os.path.join(default_dir, release, version,
'VC')
20 if os.path.isdir(path):
25 vswhere = os.path.join(os.getenv(
'ProgramFiles(x86)'),
26 'Microsoft Visual Studio',
'Installer',
'vswhere.exe')
27 command = (vswhere +
' -prerelease -legacy -products * -sort -utf8 '
28 '-property installationPath')
29 paths = subprocess.check_output(command).
decode(
'utf-8').splitlines()
31 return paths[0] +
'\\VC'
35if __name__ ==
'__main__':
38 sys.stdout.write(result +
'\n')
static DecodeResult decode(std::string path)