Skip to content

Builds are failing on free-threaded Python #476

Open
@jeertmans

Description

@jeertmans

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?

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions