-
Notifications
You must be signed in to change notification settings - Fork 776
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
Compile errors with 0.21.1 #4036
Comments
If you add pub(crate) on that class, does it work?
…On Tue, Apr 2, 2024, 2:11 PM Nick Drozd ***@***.***> wrote:
Bug Description
Updated to 0.21.1, now getting several of this error:
error[E0624]: associated constant `_PYO3_DEF` is private
--> src/lib.rs:25:1
|
25 | #[pymodule]
| ^^^^^^^^^^^ private associated constant
This is using declarative modules. I assume it's related to #4009
<#4009>. Compiling with 0.21.0 works
fine.
Steps to Reproduce
mod whatever;
use pyo3::prelude::*;
#[pymodule]
mod rust_stuff {
#[pymodule_export]
use crate::whatever::SomePyClass;
}
Backtrace
*No response*
Your operating system and version
Ubuntu
Your Python version (python --version)
3.12
Your Rust version (rustc --version)
rustc 1.79.0-nightly (5f2c7d2bf 2024-03-25)
Your PyO3 version
0.21.1
How did you install python? Did you use a virtualenv?
...
Additional Info
*No response*
—
Reply to this email directly, view it on GitHub
<#4036>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAAGBE2VAV4CUMVR2V3R5LY3LYE5AVCNFSM6AAAAABFT3T2NWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIZDCMJTGIZTSNQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The errors are coming both from |
Yep this makes sense, in #4009 when I added the constants I didn't think about visibility. Should be a relatively easy fix, I will get to it by the end of the week if nobody else fancies taking a bite at this sooner. |
In case anyone arrives here, and it needs a workaround for v0.21.1 (current latest published release), wrapping the class in the other file (or non-pythonified module) in a further module makes it accessible. use pyo3::prelude::*;
mod othermod {
use pyo3::prelude::*;
#[pymodule]
pub mod wrapper {
use pyo3::prelude::*;
#[pyclass]
pub struct Struct;
}
}
#[pymodule]
mod myext {
#[pymodule_export]
use super::othermod::wrapper;
} Ok, having this extra |
In In Exceptions are created like this: // rules.rs
create_exception!(rules, UnknownRule, PyException); Then exported like this: // lib.rs
mod rules;
#[pymodule]
mod rust_stuff {
#[pymodule_export]
use crate::rules::UnknownRule;
} Error looks like:
If there is a better way to create exceptions, I would be happy to switch to that. |
Thanks for reporting! I have opened #4086 which should fix it. |
Bug Description
Updated to 0.21.1, now getting several of this error:
This is using declarative modules. I assume it's related to #4009. Compiling with 0.21.0 works fine.
Steps to Reproduce
Backtrace
No response
Your operating system and version
Ubuntu
Your Python version (
python --version
)3.12
Your Rust version (
rustc --version
)rustc 1.79.0-nightly (5f2c7d2bf 2024-03-25)
Your PyO3 version
0.21.1
How did you install python? Did you use a virtualenv?
...
Additional Info
No response
The text was updated successfully, but these errors were encountered: