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

Can't cross compile to windows "cannot set a minimum Python version 3.8 higher than the interpreter version 3.7" #2436

Closed
1 of 2 tasks
CastilloDel opened this issue Jan 13, 2025 · 5 comments · Fixed by #2437
Labels
bug Something isn't working

Comments

@CastilloDel
Copy link

CastilloDel commented Jan 13, 2025

Bug Description

I have a crate that I'm trying to cross compile to windows using:

maturin build --target x86_64-pc-windows-gnu --release

and it fails with

2025-01-13T09:20:49.800386Z  INFO into_build_context: maturin::build_options: close time.busy=1.62µs time.idle=5.93µs
2025-01-13T09:20:49.800528Z DEBUG maturin::project_layout: Found pyproject.toml in working directory at "/home/xxxx/xxxx/xxx-client-python/pyproject.toml"
2025-01-13T09:20:49.800950Z DEBUG maturin::project_layout: Using cargo manifest path from working directory: "/home/xxxx/xxxx/xxx-client-python/Cargo.toml"
2025-01-13T09:20:49.801616Z DEBUG resolve_cargo_metadata: maturin::project_layout: Resolving cargo metadata from "/home/xxxx/xxxx/xxx-client-python/Cargo.toml"
2025-01-13T09:20:50.127090Z  INFO resolve_cargo_metadata: maturin::project_layout: close time.busy=325ms time.idle=1.60µs
2025-01-13T09:20:50.127541Z DEBUG maturin::project_layout: Project layout resolved project_root=/home/xxxx/xxxx/xxx-client-python python_dir=/home/xxxx/xxxx/xxx-client-python rust_module=/home/xxxx/xxxx/xxx-client-python/xxxx python_module=/home/xxxx/xxxx/xxx-client-python/xxxx extension_name=xxxx module_name=xxxx
🍹 Building a mixed python/rust project
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
🐍 Not using a specific python interpreter (automatically generating windows import library)
2025-01-13T09:20:50.187353Z DEBUG build_wheels: maturin::compile: Running env -u CARGO PYO3_CONFIG_FILE="/home/xxxx/xxxx/target/maturin/pyo3-config-x86_64-pc-windows-gnu-3.7.txt" "cargo" "rustc" "--target" "x86_64-pc-windows-gnu" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/xxxx/xxxx/xxx-client-python/Cargo.toml" "--release" "--lib"
   Compiling zerovec v0.10.4
   Compiling pyo3-build-config v0.23.3
   Compiling version_check v0.9.5
   Compiling tower-layer v0.3.3
   Compiling atomic-waker v1.1.2
   Compiling serde v1.0.216
   Compiling rustversion v1.0.18
   Compiling indexmap v1.9.3
error: failed to run custom build command for `pyo3-build-config v0.23.3`

Caused by:
  process didn't exit successfully: `/home/xxxx/xxxx/target/release/build/pyo3-build-config-ae3b6beb0c714554/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=PYO3_CONFIG_FILE
  cargo:rerun-if-changed=/home/xxxx/xxxx/target/maturin/pyo3-config-x86_64-pc-windows-gnu-3.7.txt

  --- stderr
  error: cannot set a minimum Python version 3.8 higher than the interpreter version 3.7 (the minimum Python version is implied by the abi3-py38 feature)
warning: build failed, waiting for other jobs to finish...
2025-01-13T09:20:53.137270Z  INFO build_wheels: maturin::build_context: close time.busy=2.95s time.idle=1.59µs
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_CONFIG_FILE="/home/xxxx/xxxx/target/maturin/pyo3-config-x86_64-pc-windows-gnu-3.7.txt" "cargo" "rustc" "--target" "x86_64-pc-windows-gnu" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/xxxx/xxxx/xxx-client-python/Cargo.toml" "--release" "--lib"`

Some relevant parts of the Cargo.toml:

pyo3 = { version = "0.23", features = ["extension-module", "generate-import-lib", "abi3-py38"] }
pyo3-async-runtimes = { version = "0.23", features = ["tokio-runtime"] }

It seems very misleading, because it mentions python3.7, when I'm not using or specifying that version anywhere. It seems that while it says Not using a specific python interpreter (automatically generating windows import library) it's using 3.7 to some extent under the hood. The same configuration used to work with a lower version of PyO3, I'm not sure if I should report it there.

Your maturin version (maturin --version)

1.8.1

Your Python version (python -V)

Python 3.12.3

Your pip version (pip -V)

pip 24.0

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

maturin build --target x86_64-pc-windows-gnu --release

@CastilloDel CastilloDel added the bug Something isn't working label Jan 13, 2025
@messense
Copy link
Member

messense commented Jan 13, 2025

I think it's gonna be hard for anyone else to reproduce it, so this is going to take time to resolve unless you're interested in investigating further.

Anyway, what's the version of python3 in $PATH?

@CastilloDel
Copy link
Author

It's 3.12.3, as I wrote in the issue.

I can reproduce it easily with docker in a small project (and a different python version 3.11). You can find it here: https://github.com/CastilloDel/MaturinBug .

Just running podman build . -t repro && podman run --rm -it -v $(pwd):/repro localhost/repro bash and then cd repro && maturin build --target x86_64-pc-windows-gnu --release should get you the error.

For my case, I'm also installing some mingw dependencies that were needed for the croscompilation, so I wouldn't expect this example to fully work, but it reproduces the error (and I don't think it's related to the mingw deps).

I hope this helps you reproduce it!

@messense
Copy link
Member

Thanks, that was helpful, this should be fixed in #2437.

@messense
Copy link
Member

In the meantime, I think you can workaround it by setting requires-python = ">=3.8" in pyproject.toml.

@CastilloDel
Copy link
Author

Thanks, that was helpful

Thanks to you!

I think you can workaround it by setting requires-python = ">=3.8" in pyproject.toml

I actually had already tried this. It doesn't seem to work in my project or in the example I made.

@CastilloDel CastilloDel changed the title Can't cross compile to windows Can't cross compile to windows "cannot set a minimum Python version 3.8 higher than the interpreter version 3.7" Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants