MCPcopy Create free account
hub / github.com/python/cpython / _find_vc2017

Function _find_vc2017

Tools/c-analyzer/distutils/_msvccompiler.py:54–84  ·  view source on GitHub ↗

Returns "15, path" based on the result of invoking vswhere.exe If no install is found, returns "None, None" The version is returned to avoid unnecessarily changing the function result. It may be ignored when the path is not None. If vswhere.exe is not available, by definition, VS 2

()

Source from the content-addressed store, hash-verified

52 return best_version, best_dir
53
54def _find_vc2017():
55 """Returns "15, path" based on the result of invoking vswhere.exe
56 If no install is found, returns "None, None"
57
58 The version is returned to avoid unnecessarily changing the function
59 result. It may be ignored when the path is not None.
60
61 If vswhere.exe is not available, by definition, VS 2017 is not
62 installed.
63 """
64 root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
65 if not root:
66 return None, None
67
68 try:
69 path = subprocess.check_output([
70 os.path.join(root, "Microsoft Visual Studio", "Installer", "vswhere.exe"),
71 "-latest",
72 "-prerelease",
73 "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
74 "-property", "installationPath",
75 "-products", "*",
76 ], encoding="mbcs", errors="strict").strip()
77 except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
78 return None, None
79
80 path = os.path.join(path, "VC", "Auxiliary", "Build")
81 if os.path.isdir(path):
82 return 15, path
83
84 return None, None
85
86PLAT_SPEC_TO_RUNTIME = {
87 'x86' : 'x86',

Callers 1

_find_vcvarsallFunction · 0.85

Calls 5

getMethod · 0.45
stripMethod · 0.45
check_outputMethod · 0.45
joinMethod · 0.45
isdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…