...
4. WoA (win-arm64) support
...
Fake native compilation, no real cross-compilation
From Python point of view, we can only invoke native compilation on x64 and win-arm64 as well.
https://github.com/pypa/setuptools/blob/main/setuptools/_distutils/command/build_ext.py#L312
(self.plat_name == get_platform()) is set to true by our usecases
But it's cross-compilation by the C compiler (MSVC), so I tend to call it fake native compilation as we convince Python to invoke the native build flow by a cross-compiler.
By VSCMD_ARG_TGT_ARCH env var, we're telling to Python it runs on the given platform
As there is no native compiler for win-arm64 this works (for now) - as seen in sources below - win-arm64 platform always results x86/arm64 compiler.
VSCMD_ARG_TGT_ARCH=arm64 -> x86_arm64 (PLAT_TO_VCVARS) -> VC\Tools\MSVC\<version>\bin\HostX86\ARM64\cl.exe
build_ext has plat_name as cross-compiling target platform parameter, which looks hacky at first sight and I suppose that's why it’s not preferred to use
I see one long-term problem here:
If there will be ever a native win-arm64/win-arm64 MSVC compiler, this method should be updated heavily as it can't fallback to win-arm64 = x86/win-arm64 anymore.
The current fake cross-compilation would fail as it would try to use the real native one.
It’s not a blocker, but it should be known.
4.1. Built-in lib in Python interpreter
...