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

Declare free-threaded support for PyModule #4588

Merged
merged 41 commits into from
Nov 5, 2024

Conversation

ngoldbaum
Copy link
Contributor

@ngoldbaum ngoldbaum commented Oct 1, 2024

Adds a supports_free_threaded argument to the pymodule macro and a supports_free_threaded method to PyModule.

Updates the tests and examples to mark that they support free-threading.

Removes UNSAFE_PYO3_BUILD_FREE_THREADED=1 from the build config.

@ngoldbaum
Copy link
Contributor Author

Just a note that this should probably only be merged once all the "RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module foo" warnings in the python tests are fixed in the free-threaded build.

@ngoldbaum
Copy link
Contributor Author

Just a note that this should probably only be merged once all the "RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module foo" warnings in the python tests are fixed in the free-threaded build.

This is done now and I think all the tests are passing so I'm going to move this out of draft phase and update the PR description.

@ngoldbaum ngoldbaum marked this pull request as ready for review October 21, 2024 23:31
@ngoldbaum ngoldbaum changed the title WIP: declare free-threaded support in pymodule macro Declare free-threaded support for PyModule Oct 21, 2024
@ngoldbaum
Copy link
Contributor Author

This probably needs some discussion in the new guide section on free-threading support.

pyo3-ffi/build.rs Outdated Show resolved Hide resolved
@ngoldbaum
Copy link
Contributor Author

woohoo! looks like tests are passing except for the codecov issue affecting all PRs right now.

@ngoldbaum ngoldbaum force-pushed the module-support branch 2 times, most recently from 599a58e to 8f86b9e Compare October 23, 2024 21:57
src/macros.rs Outdated Show resolved Hide resolved
src/types/module.rs Outdated Show resolved Hide resolved
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, broadly looks great to me, a bunch of various thoughts :)

examples/decorator/src/lib.rs Outdated Show resolved Hide resolved
examples/sequential/src/module.rs Outdated Show resolved Hide resolved
examples/string-sum/src/lib.rs Outdated Show resolved Hide resolved
pyo3-ffi/build.rs Outdated Show resolved Hide resolved
pyo3-ffi/src/moduleobject.rs Outdated Show resolved Hide resolved
pyo3-ffi/src/moduleobject.rs Show resolved Hide resolved
guide/src/free-threading.md Outdated Show resolved Hide resolved
src/types/module.rs Outdated Show resolved Hide resolved
tests/ui/invalid_pymodule_args.stderr Outdated Show resolved Hide resolved
@davidhewitt davidhewitt mentioned this pull request Oct 25, 2024
5 tasks
@ngoldbaum
Copy link
Contributor Author

ngoldbaum commented Oct 31, 2024

It occurred to me while working on something else that this PR should remove the UNSAFE_PYO3_BUILD_FREE_THREADED uses in the CI scripts a well.

EDIT: done

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, I think this is looking pretty much there. Just some final tidy ups...

pyo3-ffi/examples/string-sum/src/lib.rs Show resolved Hide resolved
pyo3-macros-backend/src/module.rs Outdated Show resolved Hide resolved
pyo3-macros-backend/src/module.rs Outdated Show resolved Hide resolved
pytests/tests/test_free_threaded.py Outdated Show resolved Hide resolved
src/types/module.rs Outdated Show resolved Hide resolved
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.

Super, this looks ready to ship! Thanks very much for all the work here and on the rest of the freethreading PRs 🚀

@davidhewitt davidhewitt added this pull request to the merge queue Nov 5, 2024
Merged via the queue into PyO3:main with commit 76f4503 Nov 5, 2024
44 checks passed
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.

4 participants