Skip to content

Commit

Permalink
Apply downstream VS 2017 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 27, 2024
1 parent 23e3bfa commit 196d44b
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,40 @@ def _find_vc2017():
if not root:
return None, None

try:
path = subprocess.check_output(
[
os.path.join(
root, "Microsoft Visual Studio", "Installer", "vswhere.exe"
),
"-latest",
"-prerelease",
"-requires",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"-property",
"installationPath",
"-products",
"*",
],
encoding="mbcs",
errors="strict",
).strip()
except (subprocess.CalledProcessError, OSError, UnicodeDecodeError):
return None, None
variant = 'arm64' if get_platform() == 'win-arm64' else 'x86.x64'
suitable_components = (
f"Microsoft.VisualStudio.Component.VC.Tools.{variant}",
"Microsoft.VisualStudio.Workload.WDExpress",
)

for component in suitable_components:
# Workaround for `-requiresAny` (only available on VS 2017 > 15.6)
with contextlib.suppress(
subprocess.CalledProcessError, OSError, UnicodeDecodeError
):
path = (
subprocess.check_output([
os.path.join(
root, "Microsoft Visual Studio", "Installer", "vswhere.exe"
),
"-latest",
"-prerelease",
"-requires",
component,
"-property",
"installationPath",
"-products",
"*",
])
.decode(encoding="mbcs", errors="strict")
.strip()
)

path = os.path.join(path, "VC", "Auxiliary", "Build")
if os.path.isdir(path):
return 15, path
path = os.path.join(path, "VC", "Auxiliary", "Build")
if os.path.isdir(path):
return 15, path

return None, None
return None, None # no suitable component found


PLAT_SPEC_TO_RUNTIME = {
Expand Down

0 comments on commit 196d44b

Please sign in to comment.