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 windows free-threaded build issues #4690

Merged
merged 7 commits into from
Nov 8, 2024

Conversation

ngoldbaum
Copy link
Contributor

@ngoldbaum ngoldbaum commented Nov 7, 2024

Fixes #4685.

This fixes a number of issues in the free-threaded build on Windows.

Before, we were linking libpython313.dll but we really wanted libpython313t.dll. This is the correct thing to do on all platforms so I also updated the build config to always look for a dynamic library with the t suffix. This may matter for packaging on Linux distros, depending on how they decide to package the free-threaded build.

It also updates the logic to get sysconfig data from the interpreter at build time on Windows. Before, we always ignored the sysconfigdata because it was never populated, but as of 3.13 this has been fixed, so I only return a blank sysconfig on Python < 3.13.

I also had to account for the fact that Python.h doesn't do #define Py_GIL_DISABLED on windows for the ffi check.

@ngoldbaum
Copy link
Contributor Author

With this the pytests pass on my Windows dev machine. I just need to fix up the clippy warnings and add Windows CI and this should be ready.

@ngoldbaum ngoldbaum changed the title use the correct library name for the free-threaded build Fix windows free-threaded build issues Nov 8, 2024
@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Nov 8, 2024
@davidhewitt davidhewitt marked this pull request as ready for review November 8, 2024 21:14
),
"python3.7md",
);

// PyPy 3.9 includes ldversion
assert_eq!(
super::default_lib_name_unix(PythonVersion { major: 3, minor: 9 }, PyPy, None),
super::default_lib_name_unix(PythonVersion { major: 3, minor: 9 }, PyPy, None, false),
Copy link
Contributor Author

@ngoldbaum ngoldbaum Nov 8, 2024

Choose a reason for hiding this comment

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

It would be nice to flesh out these tests now that we support the free-threaded build. I ran out of steam this week.

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough; some tidying for post-0.23 perhaps.

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.

Awesome, this looks good to me; thanks very much! Just one small suggestion.

Comment on lines 1124 to 1125
let script = String::from("import sys;print(sys.version_info < (3, 13))");
let stdout = run_python_script(interpreter.as_ref(), &script)?;
Copy link
Member

Choose a reason for hiding this comment

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

Let's please move this inside the if cfg!(windows) block? Otherwise we launch an extra Python interpreter run on every build :)

@ngoldbaum ngoldbaum added this pull request to the merge queue Nov 8, 2024
Merged via the queue into PyO3:main with commit de709e5 Nov 8, 2024
46 checks passed
@ngoldbaum ngoldbaum deleted the gil-disabled-build-config branch November 8, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytests crash on windows free-threaded interpreter
2 participants