Skip to content

Declare free-threaded support for PyModule#4588

Merged
davidhewitt merged 41 commits into
PyO3:mainfrom
ngoldbaum:module-support
Nov 5, 2024
Merged

Declare free-threaded support for PyModule#4588
davidhewitt merged 41 commits into
PyO3:mainfrom
ngoldbaum:module-support

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented Oct 1, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Comment thread tests/ui/invalid_pymodule_args.stderr Outdated
@ngoldbaum

Copy link
Copy Markdown
Contributor Author

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

Comment thread pyo3-macros-backend/src/module.rs Outdated
Comment thread examples/sequential/src/module.rs
Comment thread pyo3-ffi/build.rs Outdated
Comment thread examples/decorator/src/lib.rs
@ngoldbaum

Copy link
Copy Markdown
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
Comment thread src/macros.rs Outdated
Comment thread src/types/module.rs Outdated

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown
Member

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 :)

Comment thread examples/decorator/src/lib.rs
Comment thread examples/sequential/src/module.rs
Comment thread examples/string-sum/src/lib.rs
Comment thread pyo3-ffi/build.rs Outdated
Comment thread pyo3-ffi/src/moduleobject.rs
Comment thread pyo3-ffi/src/moduleobject.rs
Comment thread guide/src/free-threading.md Outdated
Comment thread src/types/module.rs Outdated
Comment thread tests/ui/invalid_pymodule_args.stderr Outdated
@davidhewitt davidhewitt mentioned this pull request Oct 25, 2024
5 tasks
Comment thread examples/maturin-starter/src/lib.rs Outdated
@ngoldbaum

ngoldbaum commented Oct 31, 2024

Copy link
Copy Markdown
Contributor Author

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

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown
Member

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...

Comment thread pyo3-ffi/examples/string-sum/src/lib.rs
Comment thread pyo3-macros-backend/src/module.rs Outdated
Comment thread pyo3-macros-backend/src/module.rs Outdated
Comment thread pytests/tests/test_free_threaded.py Outdated
Comment thread src/types/module.rs Outdated
Comment thread guide/src/free-threading.md

@davidhewitt davidhewitt left a comment

Copy link
Copy Markdown
Member

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
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