Can declarative modules work with inline included files? #4312
-
Consider https://pyo3.rs/v0.22.0/module#declarative-modules, for example, In #[pyo3::pymodule]
pub mod foo_module {
include!("./bar.rs");
} In #[pyo3::pymodule]
pub mod bar_module {
#[pyclass]
pub struct DataClass {
pub hash: i64
}
} After building If I slighty move that structure, like following, can work. #[pyo3::pymodule]
pub mod foo_module {
#[pyo3::pymodule]
pub mod bar_module {
pub struct DataClass {
pub hash: i64
}
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
We can't see through the What you can instead do is use mod bar;
#[pyo3::pymodule]
pub mod foo_module {
#[pymodule_export]
use bar::bar_module;
} |
Beta Was this translation helpful? Give feedback.
-
Issues other people might encountered when doing something similar to my above example code snippets is well-elaborated in #4285. And thanks to Alex and David, it is just now fixed in #4288. Thanks for such a amazing works guys. |
Beta Was this translation helpful? Give feedback.
We can't see through the
include!
macro.What you can instead do is use
#[pymodule_export]
: