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 compiling abi3 for windows arm failed with v1.7.7+ #2368

Closed
2 tasks
kahojyun opened this issue Dec 5, 2024 · 9 comments
Closed
2 tasks

Cross compiling abi3 for windows arm failed with v1.7.7+ #2368

kahojyun opened this issue Dec 5, 2024 · 9 comments
Labels
bug Something isn't working cross-compile Something related to cross compilation

Comments

@kahojyun
Copy link

kahojyun commented Dec 5, 2024

Bug Description

Cannot build abi3 aarch64 Windows wheel on Github Action x86 Windows runner.

A minimal reproduction repo is here. The build succeeds if I remove the abi3-py39 feature or use maturin v1.7.6.

Your maturin version (maturin --version)

1.7.8

Your Python version (python -V)

NA

Your pip version (pip -V)

NA

What bindings you're using

pyo3

Does cargo build work?

  • Yes, it works

If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)?

  • Yes

Steps to Reproduce

https://github.com/kahojyun/winarm64-maturin-1-7-8

https://github.com/kahojyun/winarm64-maturin-1-7-8/actions

@kahojyun kahojyun added the bug Something isn't working label Dec 5, 2024
@messense
Copy link
Member

messense commented Dec 6, 2024

Probably related to #2333 cc @davidhewitt

@messense messense added the cross-compile Something related to cross compilation label Dec 6, 2024
@davidhewitt
Copy link
Member

On first inspection it looks like maturin is doing the right thing, so I've opened PyO3/pyo3#4773

@kahojyun
Copy link
Author

I found that maturin v1.7.6 uses xwin for cross-compiling by default. For maturin v1.7.8, if I set MATURIN_USE_XWIN to 1 the build succeeds.

@Ousret
Copy link

Ousret commented Dec 15, 2024

The plot thicken. I think there's more than what appear.


Using MATURIN_USE_XWIN does help, but not in every cases. Curiously, It succeed every time, but produced wheel cannot be trusted.

See https://github.com/jawah/wassima/actions/runs/12336830906/job/34429848274

Things that caught my attention:

  • ⚠️ Warning: failed to determine the path to python for 't * C:\hostedtoolcache\windows\Python\3.13.0\x64-freethreaded\python3.13t.exe': The filename, directory name, or volume label syntax is incorrect. (os error 123)
  • Wheel contain arch amd64 when target is aarch64
⚠️ Warning: CPython 3.13t at C:\hostedtoolcache\windows\Python\3.13.0\x64-freethreaded\python.exe does not yet support abi3 so the build artifacts will be version-specific.
🛠️ Using xwin for cross-compiling to aarch64-pc-windows-msvc
   Compiling pyo3-build-config v0.23.3
   Compiling pyo3-ffi v0.23.3
   Compiling pyo3-macros-backend v0.23.3
   Compiling pyo3 v0.23.3
   Compiling pyo3-macros v0.23.3
   Compiling wassima v1.1.6 (D:\a\wassima\wassima)
    Finished `release` profile [optimized] target(s) in 10.03s
📦 Built wheel for CPython 3.13t to dist\wassima-1.1.6-cp313-cp313t-win_amd64.whl

@kahojyun
Copy link
Author

It appears to be a bug in pyo3-build-config, and I have submitted a PR to address it: PyO3/pyo3#4800. As a temporary solution for existing pyo3 versions, set the environment variable PYO3_CROSS to 1.

@Ousret
Copy link

Ousret commented Dec 16, 2024

As a temporary solution for existing pyo3 versions, set the environment variable PYO3_CROSS to 1.

It does not work unfortunately. See https://github.com/jawah/wassima/actions/runs/12340559151/job/34438218682 for example.

regards,

@kahojyun
Copy link
Author

As a temporary solution for existing pyo3 versions, set the environment variable PYO3_CROSS to 1.

It does not work unfortunately. See jawah/wassima/actions/runs/12340559151/job/34438218682 for example.

regards,

Try enabling generate-import-lib feature in pyo3
https://www.maturin.rs/distribution#cross-compile-to-windows
https://pyo3.rs/main/building-and-distribution#building-abi3-extensions-without-a-python-interpreter

@Ousret
Copy link

Ousret commented Dec 16, 2024

Better but did go back to same initial result. wheel is invalid.

🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.7
⚠️  Warning: failed to determine the path to python for `t *       C:\hostedtoolcache\windows\Python\3.13.0\x64-freethreaded\python3.13t.exe`: The filename, directory name, or volume label syntax is incorrect. (os error 123)
🐍 Not using a specific python interpreter (automatically generating windows import library)
📡 Using build options features from pyproject.toml
🛠️ Using xwin for cross-compiling to aarch64-pc-windows-msvc
   Compiling shlex v1.3.0
   Compiling target-lexicon v0.12.16
   Compiling once_cell v1.20.2
   Compiling proc-macro2 v1.0.92
   Compiling cc v1.2.4
   Compiling windows_aarch64_msvc v0.52.6
   Compiling unicode-ident v1.0.14
   Compiling autocfg v1.4.0
   Compiling libc v0.2.168
   Compiling windows-targets v0.52.6
   Compiling heck v0.5.0
   Compiling windows-sys v0.59.0
   Compiling python3-dll-a v0.2.11
   Compiling memoffset v0.9.1
   Compiling quote v1.0.37
   Compiling syn v2.0.90
   Compiling rustls-pki-types v1.10.1
   Compiling pyo3-build-config v0.23.3
   Compiling schannel v0.1.27
   Compiling rustls-pemfile v2.2.0
   Compiling pyo3-macros-backend v0.23.3
   Compiling pyo3-ffi v0.23.3
   Compiling pyo3 v0.23.3
   Compiling indoc v2.0.5
   Compiling cfg-if v1.0.0
   Compiling unindent v0.2.3
   Compiling rustls-native-certs v0.7.3
   Compiling pyo3-macros v0.23.3
   Compiling wassima v1.1.6 (D:\a\wassima\wassima)
    Finished `release` profile [optimized] target(s) in 52.82s
📦 Built wheel for abi3 Python ≥ 3.7 to dist\wassima-1.1.6-cp37-abi3-win_arm64.whl
⚠️ Warning: CPython 3.13t at C:\hostedtoolcache\windows\Python\3.13.0\x64-freethreaded\python.exe does not yet support abi3 so the build artifacts will be version-specific.
🛠️ Using xwin for cross-compiling to aarch64-pc-windows-msvc
   Compiling pyo3-build-config v0.23.3
   Compiling pyo3-macros-backend v0.23.3
   Compiling pyo3-ffi v0.23.3
   Compiling pyo3 v0.23.3
   Compiling pyo3-macros v0.23.3
   Compiling wassima v1.1.6 (D:\a\wassima\wassima)
    Finished `release` profile [optimized] target(s) in 9.68s
📦 Built wheel for CPython 3.13t to dist\wassima-1.1.6-cp313-cp313t-win_amd64.whl

https://github.com/jawah/wassima/actions/runs/12346071103/job/34451209764

and PYO3_CROSS=1 is set.

regards,

@kahojyun
Copy link
Author

Better but did go back to same initial result. wheel is invalid.

I forget to mention that MATURIN_USE_XWIN should be unset 🙇. Additionally, it's important to be aware that pyo3 automatically enables cross-compiling mode if the PYO3_CROSS environment variable is present, regardless of its value.

I have another sad news: the combination of the abi3 and generate-import-lib flags seems to fail with pyo3=0.23. I am currently looking into this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cross-compile Something related to cross compilation
Projects
None yet
Development

No branches or pull requests

4 participants