Allow cross-compiling for Windows ARM64#343
Conversation
This allow proper handling of cross-compilation added to setuptools but not to [deprecated] distutils.
setupinfo.py
Outdated
| from distutils.core import Extension | ||
| from distutils.errors import CompileError, DistutilsOptionError | ||
| from distutils.command.build_ext import build_ext as _build_ext | ||
| from setuptools.command.build_ext import build_ext as _build_ext |
There was a problem hiding this comment.
Probably ok to change this since we're importing setuptools anyway. What was the reason why this was necessary?
There was a problem hiding this comment.
setuptools has an additional override in its build_ext.get_ext_filename to set the right suffix when compiling (in this case, .cp310-win_arm64.pyd) that distutils does not. Under normal circumstances, the presence of setuptools is enough to get the right command, so it's transparent, but when you explicitly import it from distutils (even with the setuptools bundled version of distutils) and subclass, then you override it.
Eventually setuptools will merge the two, and I think they consider imports directly from distutils to be deprecated (at least, I hope they do), so those will eventually stop working. But for the transition, they're keeping them working.
There was a problem hiding this comment.
Ok. I think we should then import setuptools before from distutils.core import Extension, to mark the dependency. Otherwise, this would stop working if the import order in setup.py changed.
Co-authored-by: scoder <stefan_ml@behnel.de>
setupinfo.py
Outdated
| from distutils.core import Extension | ||
| from distutils.errors import CompileError, DistutilsOptionError | ||
| from distutils.command.build_ext import build_ext as _build_ext | ||
| from setuptools.command.build_ext import build_ext as _build_ext |
There was a problem hiding this comment.
Ok. I think we should then import setuptools before from distutils.core import Extension, to mark the dependency. Otherwise, this would stop working if the import order in setup.py changed.
|
LGTM 👍 Thanks for keeping on this one |
|
Thanks |
When cross-compiling for Windows ARM64 (the most likely scenario), the
VSCMD_ARG_TGT_ARCHvariable is set toarm64. In this case, we still want to grab the ARM64 binaries instead of those matching the host (build) platform.This variable is the same one that is used inside distutils/setuptools to tell when cross-compiling, so everything else works fine. It is set by default in a Visual Studio cross-compilation environment, but can also be set manually and setuptools will pick up the right settings by itself.