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

Cross Compilation in Build Hook #1636

Open
JP-Ellis opened this issue Jul 23, 2024 · 5 comments
Open

Cross Compilation in Build Hook #1636

JP-Ellis opened this issue Jul 23, 2024 · 5 comments

Comments

@JP-Ellis
Copy link
Contributor

Summary

What are the best practices for detecting the target architecture when cross-compiling a platform-specific wheel using a Hatch build script?

Background

I am building a wheel which includes a binary extension compiled using cffi. I have a custom build hook which performs the following steps:

  1. Detect the architecture, using packaging's sys_tags
  2. Download the pre-compiled library for the target architecture
  3. Build the binary extension

I recently tried to enable support for Windows ARM builds; however, ran into issues when trying to build the wheels using cibuildwheel due to a mismatch between what sys_tags returns, and the actual target achitecture. I was wondering first whether it was an issue with cibuildwheel and asked the question over at

Also from the cibuildwheel docs:

Cross-compilation on Windows relies on a supported build backend. Supported backends use an environment variable to specify their target platform (the one they are compiling native modules for, as opposed to the one they are running on), which is set in cibuildwheels/windows.py before building. Currently, setuptools>=65.4.1 and setuptools_rust are the only supported backends.

It is unclear, at this stage, what should be changed. I can see a couple options:

  1. cibuildwheel is updated to ensure compatibility with packaging (or vice-versa),
  2. hatch exposes an API so that a build script can know what target is being built.

I do wonder whether you think (2) should be implemented regardless. Hatch evidently has some logic to determine the tags, but that is (afaik) hidden and not otherwise accessible.

@JP-Ellis JP-Ellis changed the title Cross Compilation in Build Hookd Cross Compilation in Build Hook Jul 23, 2024
@JP-Ellis
Copy link
Contributor Author

It isn't obvious to me that target_name will give my the interpreter/ABI/platform triple 🤔.

If it does have all that information, it might be worth updating the docs and/or providing examples of values this target_name might take.

I'll take a look this afternoon though 👍

@ofek
Copy link
Sponsor Collaborator

ofek commented Jul 23, 2024

sorry that is correct, I skimmed and saw the word target which refers to something specific in Hatch-land, I will read this further tomorrow

@JP-Ellis
Copy link
Contributor Author

I just did a really quick check, and I'm finding that target_name takes on the value 'wheel' which is not quite what I'm looking for :/

Appreciate you looking into this though!

@JP-Ellis
Copy link
Contributor Author

JP-Ellis commented Sep 4, 2024

Just following up on this ticket in case you identified anything useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants