Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cross-compiling for Windows ARM64 #343

Merged
merged 4 commits into from May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion buildlibxml.py
Expand Up @@ -38,7 +38,9 @@ def download_and_extract_windows_binaries(destdir):
if release_path in filename
]

if platform.machine() == 'ARM64':
# Check for native ARM64 build or the environment variable that is set by
# Visual Studio for cross-compilation (same variable as setuptools uses)
if platform.machine() == 'ARM64' or os.getenv('VSCMD_ARG_TGT_ARCH') == 'arm64':
zooba marked this conversation as resolved.
Show resolved Hide resolved
arch = "win-arm64"
elif sys.maxsize > 2**32:
arch = "win64"
Expand Down
2 changes: 1 addition & 1 deletion setupinfo.py
Expand Up @@ -5,7 +5,7 @@
import subprocess
from distutils.core import Extension
scoder marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably ok to change this since we're importing setuptools anyway. What was the reason why this was necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

scoder marked this conversation as resolved.
Show resolved Hide resolved
from versioninfo import get_base_dir

try:
Expand Down