Skip to content
35 changes: 25 additions & 10 deletions distutils/_msvccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
LibError,
LinkError,
)
from .util import get_platform
from .util import get_platform, get_host_platform


def _find_vc2015():
Expand Down Expand Up @@ -178,15 +178,30 @@ def _find_exe(exe, paths=None):
return exe


# A map keyed by get_platform() return values to values accepted by
Comment thread
jaraco marked this conversation as resolved.
# 'vcvarsall.bat'. Always cross-compile from x86 to work with the
# lighter-weight MSVC installs that do not include native 64-bit tools.
PLAT_TO_VCVARS = {
'win32': 'x86',
'win-amd64': 'x86_amd64',
'win-arm32': 'x86_arm',
'win-arm64': 'x86_arm64',
}
def _get_plat_to_vcvars():
Comment thread
saschanaz marked this conversation as resolved.
Outdated
# A map keyed by get_platform() return values to values accepted by
# 'vcvarsall.bat'.
if get_platform() == get_host_platform() == "win-arm64":
Comment thread
saschanaz marked this conversation as resolved.
Outdated
# Use the native MSVC host if the host platform would need expensive
# emulation for x86.
return {
'win32': 'arm64_x86',
'win-amd64': 'arm64_amd64',
'win-arm32': 'arm64_arm',
'win-arm64': 'arm64',
}
else:
# Always cross-compile from x86 to work with the lighter-weight MSVC
# installs that do not include native 64-bit tools.
return {
'win32': 'x86',
'win-amd64': 'x86_amd64',
'win-arm32': 'x86_arm',
'win-arm64': 'x86_arm64',
}


PLAT_TO_VCVARS = _get_plat_to_vcvars()


class MSVCCompiler(CCompiler):
Expand Down