pola-rs / pyo3-polars

Plugins/extension for Polars
MIT License
260 stars 42 forks source link

Compilation error with `pyo3` - `gil-refs` feature turned on #109

Open qqlearn123 opened 1 month ago

qqlearn123 commented 1 month ago

Error message encountered:

   Compiling pyo3-polars v0.17.0
error[E0277]: the trait bound `error::ColumnNotFound: HasPyGilRef` is not satisfied
  --> /users/guest/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-polars-0.17.0/src/error.rs:63:1
   |
63 | create_exception!(exceptions, ColumnNotFound, PyException);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `pyo3::PyNativeType` is not implemented for `error::ColumnNotFound`, which is required by `error::ColumnNotFound: HasPyGilRef`
   |
   = help: the following other types implement trait `pyo3::PyNativeType`:
             CancelledError
             IncompleteReadError
             InvalidStateError
             LimitOverrunError
             PanicException
             PyArithmeticError
             PyAssertionError
             PyAttributeError
           and 101 others
   = note: required for `error::ColumnNotFound` to implement `HasPyGilRef`
note: required by a bound in `PyTypeInfo`
  --> /users/guest/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pyo3-0.22.2/src/type_object.rs:62:38
   |
62 | pub unsafe trait PyTypeInfo: Sized + HasPyGilRef {
   |                                      ^^^^^^^^^^^ required by this bound in `PyTypeInfo`
   = note: this error originates in the macro `$crate::create_exception_type_object` which comes from the expansion of the macro `create_exception` (in Nightly builds, run with -Z macro-backtrace for more info)

Cargo.toml

polars = { version = "0.43", features = ["dtype-struct", "performant"] }
pyo3 = { version = "0.22", features = ["abi3-py38", "extension-module", "gil-refs", "multiple-pymethods"] }
pyo3-polars = { version = "0.17", features = ["derive", "dtype-struct"] }

There are also some other errors along the same line as the one showed above, so I choose to not to include them all here.

Not sure whether pyo3-polars is incompatible with pyo3's gil-refs feature or my setup is somehow incorrect.

ritchie46 commented 1 month ago

Don't turn it on? I don't see why we need to support feature flags we don't use ourselves.

qqlearn123 commented 1 month ago

But another dependency needs this feature to be turned on. Curious why a pyo3 feature turned on can break pyo3-polars code?

Is it more of a design issue of pyo3?