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

Free-threaded build config fixes #4719

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ngoldbaum
Copy link
Contributor

@ngoldbaum ngoldbaum commented Nov 18, 2024

Fixes #4709.

Trying to get a library name or build pyo3-ffi against a free-threaded ABI for Python earlier than 3.13 now panics.

Also adds tests for the panics and for the free-threaded library names as followup for #4690 where I ran out of steam to add new tests.

While working on this I noticed that there was code to work around python/cpython#101614 which was fixed in CPython for 3.10 and newer, so I modified the workaround code path to only apply for Python 3.9 and older.

major: 3,
minor: 13,
};
#[allow(dead_code)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is leftover from a mistaken refactoring that removed the only internal use of this outside tests and should be deleted

@@ -1642,24 +1645,33 @@ fn default_lib_name_windows(
debug: bool,
gil_disabled: bool,
) -> String {
if debug {
if debug && version.minor < 10 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe define a PY310 constant?

@davidhewitt
Copy link
Member

👍 thanks, do you want me to review before the above comments are resolved?

@ngoldbaum
Copy link
Contributor Author

Go ahead.

Tiny bit of context: I often look at PRs on my phone since it helps me catch things if I look over code in a different context from where I wrote it.

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks, this seems reasonable to me 👍

Comment on lines 116 to 117
if version < PythonVersion::PY313 {
panic!(
Copy link
Member

Choose a reason for hiding this comment

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

This should use ensure! rather than panic!, it leads to a friendlier presentation of the error to users.

@davidhewitt
Copy link
Member

See also PyO3/maturin#2310 (comment), can probably adjust here.

@davidhewitt davidhewitt mentioned this pull request Nov 22, 2024
@ngoldbaum
Copy link
Contributor Author

Along with some changes to maturin on top of PyO3/maturin#2310 (which I'll create a separate PR for) this latest push lets more of the maturin tests pass on my local dev setup.

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

Successfully merging this pull request may close these issues.

Setting configs incompatible with Py_GIL_DISABLED should error harder
2 participants