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

Builds are failing on free-threaded Python #476

Open
jeertmans opened this issue Dec 13, 2024 · 2 comments
Open

Builds are failing on free-threaded Python #476

jeertmans opened this issue Dec 13, 2024 · 2 comments

Comments

@jeertmans
Copy link

jeertmans commented Dec 13, 2024

Hi!

I searched quite a lot, but I could not find any issue mentioning the fact that one cannot build this library with free-threaded Python, which can arise automatically with recent PyO3 versions and the use of --find-interpreter to build the library, which finds Python3.13t on Linux platforms.

So with the recent releases of PyO3 (started with 0.23.2, I think), my CI builds started failing. I noticed the following issue:

error[E0432]: unresolved import `pyo3::sync::GILProtected`
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/numpy-0.23.0/src/datetime.rs:63:12
   |
63 | use pyo3::{sync::GILProtected, Bound, Py, Python};
   |            ^^^^^^^^^^^^^^^^^^ no `GILProtected` in `sync`
   |
note: found an item that was configured out
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.23.3/src/sync.rs:47:12
   |
47 | pub struct GILProtected<T> {
   |            ^^^^^^^^^^^^
note: the item is gated here
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.23.3/src/sync.rs:46:1
   |
46 | #[cfg(not(Py_GIL_DISABLED))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved import `pyo3::sync::GILProtected`
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/numpy-0.23.0/src/strings.rs:15:5
   |
15 |     sync::GILProtected,
   |     ^^^^^^^^^^^^^^^^^^ no `GILProtected` in `sync`
   |
   = note: unresolved item `crate::datetime::units::GILProtected` exists but is inaccessible
note: found an item that was configured out
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.23.3/src/sync.rs:47:12
   |
47 | pub struct GILProtected<T> {
   |            ^^^^^^^^^^^^
note: the item is gated here
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.23.3/src/sync.rs:46:1
   |
46 | #[cfg(not(Py_GIL_DISABLED))]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0432`.

The use of GILProtected seems quite restricted in your project, and I was wondering if this issue could be solved by using a Mutex instead, as done by @davidhewitt in the jiter module, see crates/jiter/src/py_string_cache.rs.

If free-threaded Python is incompatible with this project, maybe it could be better to emit a compile_error!(...) instead?

@Icxolu
Copy link
Contributor

Icxolu commented Dec 14, 2024

We are working on supporting the free-threaded build over in #471. We still need to make sure that we get rust-numpys dynamic borrow checking correct in the new environment, which is a bit more involved than just replacing the GILProtected.

@jeertmans
Copy link
Author

Thanks for pointing to that PR @Icxolu!

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

No branches or pull requests

2 participants