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 abi3 interpreter discovery on Windows #2333

Merged
merged 3 commits into from
Nov 29, 2024

Conversation

davidhewitt
Copy link
Member

This is an attempt to fix #2325 (comment)

(Not tested yet, I wanted to push and see how this runs on CI as well as test locally.)

@davidhewitt
Copy link
Member Author

Looks like this is working well.

Without generate-import-lib enabled, setting 3.13t:

~\Dev\maturin> cargo run -- build --manifest-path ../pyo3-scratch/Cargo.toml -i 3.13t
   Compiling maturin v1.7.6 (C:\Users\david\Dev\maturin)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.28s
     Running `target\debug\maturin.exe build --manifest-path ../pyo3-scratch/Cargo.toml -i 3.13t`
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
⚠️  Warning: Failed to determine python platform
💥 maturin failed
  Caused by: Need a Python interpreter to compile for Windows without PyO3's `generate-import-lib` feature
  Caused by: Python interpreter `3.13t` doesn't exist
error: process didn't exit successfully: `target\debug\maturin.exe build --manifest-path ../pyo3-scratch/Cargo.toml -i 3.13t` (exit code: 1)

... and the same if I enable the generate-import-lib feature:

~\Dev\maturin> cargo run -- build --manifest-path ../pyo3-scratch/Cargo.toml -i 3.13t
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.23s
     Running `target\debug\maturin.exe build --manifest-path ../pyo3-scratch/Cargo.toml -i 3.13t`
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.8
⚠️  Warning: Failed to determine python platform
🐍 Not using a specific python interpreter (automatically generating windows import library)
⚠️ Warning: CPython 3.13t does not yet support abi3 so the build artifacts will be version-specific.
   Compiling pyo3-build-config v0.23.2 (C:\Users\david\Dev\pyo3\pyo3-build-config)
   Compiling pyo3-macros-backend v0.23.2 (C:\Users\david\Dev\pyo3\pyo3-macros-backend)
   Compiling pyo3-ffi v0.23.2 (C:\Users\david\Dev\pyo3\pyo3-ffi)
   Compiling pyo3 v0.23.2 (C:\Users\david\Dev\pyo3)
   Compiling pyo3-macros v0.23.2 (C:\Users\david\Dev\pyo3\pyo3-macros)
   Compiling pyo3-scratch v0.1.0 (C:\Users\david\Dev\pyo3-scratch)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.76s
📦 Built wheel for CPython 3.13t to C:\Users\david\Dev\pyo3-scratch\target\wheels\pyo3_scratch-0.1.0-cp313-cp313t-win_amd64.whl

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.

Comments skipped due to low confidence (2)

src/build_options.rs:413

  • The capitalization of 'automatically' has been corrected.
eprintln!("🐍 Not using a specific python interpreter (automatically generating windows import library)");

src/build_context.rs:237

  • The to_string method for interp does not include the major and minor versions, which could lead to incorrect output. Consider using format!("{}{}{}", interp, interp.major, interp.minor) to ensure the correct format.
.map(|interp| interp.to_string())
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 merged commit c72925f into PyO3:main Nov 29, 2024
37 of 38 checks passed
@messense
Copy link
Member

Tested in nh3 and it works great!

@davidhewitt
Copy link
Member Author

Great!

@ravenexp
Copy link
Contributor

Looks like this is working well.

Without generate-import-lib enabled, setting 3.13t:

  Caused by: Need a Python interpreter to compile for Windows without PyO3's `generate-import-lib` feature
  Caused by: Python interpreter `3.13t` doesn't exist

... and the same if I enable the generate-import-lib feature:

📦 Built wheel for CPython 3.13t to C:\Users\david\Dev\pyo3-scratch\target\wheels\pyo3_scratch-0.1.0-cp313-cp313t-win_amd64.whl

But does setting just PYO3_CROSS_LIB_DIR in cross-compile scenarios still work when generate-import-lib feature is not enabled?
From the diff it looks like it will now fail at https://github.com/PyO3/maturin/pull/2333/files#diff-d2936347274858bda2ad31e68e259a54467b075b0532f87a27e52b4b73366762R369. (I have not tested this.)

I'm not using this configuration myself since generate-import-lib had been merged, but it is documented and used to work for a long time.

@davidhewitt
Copy link
Member Author

Oof, good spot, I think you might be right. I'll try to circle back here and cover with some tests at the same time.

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.

3 participants