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

Fix platform tags when cross-compiling universal2 #2153

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

tuxu
Copy link
Contributor

@tuxu tuxu commented Jul 23, 2024

When cross-compiling for universal2-apple-darwin, the platform tags of the resulting wheel were not properly derived. This is because with forcing target_triple to None as before, it was not detected that we are in fact cross-compiling for a different target and thus the wheels were wrongly tagged for the host platform.

To make the inference work, set target_triple to a valid triple instead.

When cross-compiling for `universal2-apple-darwin`, the platform tags of
the resulting wheel were not properly derived. This is because with
forcing `target_triple` to `None` as before, it was not detected that we
are in fact cross-compiling for a different target and thus the wheels
were wrongly tagged for the host platform.

To make the inference work, set `target_triple` to a valid triple
instead.
Copy link

netlify bot commented Jul 23, 2024

Deploy Preview for maturin-guide ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit f643815
🔍 Latest deploy log https://app.netlify.com/sites/maturin-guide/deploys/669f86a9f8a9910008784e59
😎 Deploy Preview https://deploy-preview-2153--maturin-guide.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@tuxu
Copy link
Contributor Author

tuxu commented Jul 23, 2024

For reference, the behavior before and after this change.

maturin 1.7.0:

root@ce3c3013b66d:/tmp/hello# uname -a
Linux ce3c3013b66d 6.6.26-linuxkit #1 SMP Sat Apr 27 04:13:19 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

root@ce3c3013b66d:/tmp/hello# maturin build --release --target universal2-apple-darwin -i python3.9                  
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.9
🐍 Not using a specific python interpreter
📡 Using build options features from pyproject.toml
💻 Using `MACOSX_DEPLOYMENT_TARGET=11.0` for aarch64-apple-darwin by default
    Finished `release` profile [optimized] target(s) in 0.04s
💻 Using `MACOSX_DEPLOYMENT_TARGET=10.12` for x86_64-apple-darwin by default
    Finished `release` profile [optimized] target(s) in 0.01s
💥 maturin failed
  Caused by: Error checking for manylinux/musllinux compliance
  Caused by: Goblin failed to parse the elf file
  Caused by: Invalid magic number: 0x2000000bebafeca

With --skip-auditwheel:

[...]
📦 Built wheel for abi3 Python ≥ 3.9 to /tmp/hello/target/wheels/hello-0.1.0-cp39-abi3-linux_aarch64.whl

With the changes of this PR:

[...]
📦 Built wheel for abi3 Python ≥ 3.9 to /tmp/hello/target/wheels/hello-0.1.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Copy link
Member

@messense messense left a comment

Choose a reason for hiding this comment

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

Thanks!

@messense messense enabled auto-merge July 23, 2024 10:50
@messense messense added this pull request to the merge queue Jul 23, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jul 23, 2024
@messense messense merged commit 46cce03 into PyO3:main Jul 23, 2024
28 checks passed
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

Successfully merging this pull request may close these issues.

2 participants