...
4. WoA (win-arm64) support
Todo: fake native compilation where win-arm64 == x86/arm64 !
4.1. Built-in lib in Python interpreter
As this is going to be deprecated, I won’t expect any further support.
Short summary
On WoA machine, the cross-compile MSVC is called by default, but on x64 it can’t be enforced.
win-arm64 has been added as a host platform (in 2019)
This means on win-arm64 platform without any env var setting, it will invoke x86/arm64 MSVC compiler by default.
Whis is good on WoA
https://github.com/python/cpython/blob/v3.10.0rc1/Lib/distutils/util.py#L39
Code Block def get_host_platform(): if os.name == 'nt': if 'amd64' in sys.version.lower(): return 'win-amd64' if '(arm)' in sys.version.lower(): return 'win-arm32' if '(arm64)' in sys.version.lower(): return 'win-arm64' return sys.platform
https://github.com/python/cpython/blob/v3.10.0rc1/Lib/distutils/_msvccompiler.py#L163
Code Block PLAT_TO_VCVARS = { 'win32' : 'x86', 'win-amd64' : 'x86_amd64', 'win-arm32' : 'x86_arm', 'win-arm64' : 'x86_arm64' }
win-arm64 is not added as a target platform
it means win-arm64 as build target can’t be enforced by VSCMD_ARG_TGT_ARCH=arm64 environment variable on x64
as this is going to be deprecated and not recommended to use for any projects it’s not a blocker, but any project that is tied to old distutils, can’t be cross-compiled from x64 to win-arm64, for example numpy!
https://github.com/python/cpython/blob/v3.10.0rc1/Lib/distutils/util.py#L99
Code Block def get_platform(): if os.name == 'nt': TARGET_TO_PLAT = { 'x86' : 'win32', 'x64' : 'win-amd64', 'arm' : 'win-arm32', } return TARGET_TO_PLAT.get(os.environ.get('VSCMD_ARG_TGT_ARCH')) or get_host_platform() else: return get_host_platform()
Test
Code Block |
---|
Test command:
python setup.py build_ext
CPython(3.10_rc1)/distutils (old)
SETUPTOOLS_USE_DISTUTILS=
x64
VSCMD_ARG_TGT_ARCH=
self.plat_name: win32
get_platform() win32
get_host_platform() win32
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\cl.exe
VSCMD_ARG_TGT_ARCH=arm64
self.plat_name: win32
get_platform() win32
get_host_platform() win32
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\cl.exe
Can't build for win-arm64!
win-arm64
VSCMD_ARG_TGT_ARCH=
self.plat_name: win-arm64
get_platform() win-arm64
get_host_platform() win-arm64
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\ARM64\cl.exe
VSCMD_ARG_TGT_ARCH=arm64
self.plat_name: win-arm64
get_platform() win-arm64
get_host_platform() win-arm64
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\ARM64\cl.exe
Tested projects:
Cython: successful
numpy: successful |
4.2. Within stand-alone setuptools package
As this deprecates the internal lib of CPython, any further support should be added and expected here.
Short summary
On WoA machine, the cross-compile MSVC is called by default, while on x64 it can be enforced by VSCMD_ARG_TGT_ARCH=arm64 env var.
win-arm64 is supported as host platform
https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/util.py#L40
Code Block def get_host_platform(): if os.name == 'nt': if 'amd64' in sys.version.lower(): return 'win-amd64' if '(arm)' in sys.version.lower(): return 'win-arm32' if '(arm64)' in sys.version.lower(): return 'win-arm64' return sys.platform
https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/_msvccompiler.py#L92
Code Block PLAT_TO_VCVARS = { 'win32' : 'x86', 'win-amd64' : 'x86_amd64', 'win-arm32' : 'x86_arm', 'win-arm64' : 'x86_arm64' }
win-arm64 is supported as a target platform as well
Code Block def get_platform(): if os.name == 'nt': TARGET_TO_PLAT = { 'x86' : 'win32', 'x64' : 'win-amd64', 'arm' : 'win-arm32', 'arm64': 'win-arm64', } return TARGET_TO_PLAT.get(os.environ.get('VSCMD_ARG_TGT_ARCH')) or get_host_platform() else: return get_host_platform()
Test
Code Block |
---|
Test command:
python setup.py build_ext
setuptools-57.4.0/distutils (new)
SETUPTOOLS_USE_DISTUTILS=local
x64
VSCMD_ARG_TGT_ARCH=
self.plat_name: win32
get_platform() win32
get_host_platform() win32
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\x86\cl.exe
VSCMD_ARG_TGT_ARCH=arm64
self.plat_name: win-arm64
get_platform() win-arm64
get_host_platform() win32
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\ARM64\cl.exe
Tested projects:
Cython: successful
numpy: failed (as numpy relies on old distutils)
win-arm64
VSCMD_ARG_TGT_ARCH=
self.plat_name: win-arm64
get_platform() win-arm64
get_host_platform() win-arm64
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\ARM64\cl.exe
VSCMD_ARG_TGT_ARCH=arm64
self.plat_name: win-arm64
get_platform() win-arm64
get_host_platform() win-arm64
self.cc C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\HostX86\ARM64\cl.exe
Tested projects:
Cython: successful
numpy: failed (as numpy relies on old distutils)
|