PyO3 / pyo3

Rust bindings for the Python interpreter
https://pyo3.rs
Other
11.44k stars 693 forks source link

Declarative modules submodules don't work with `#[pyo3::prelude::pymodule]` #4285

Open alex opened 1 week ago

alex commented 1 week ago

pyca/cryptography avoids using the prelude, and instead references things with their full name.

This does not work with declarative modules's submodules:

#[pyo3::prelude::pymodule]
mod foo {
    // `submod` won't actually be registered!
    #[pyo3::prelude::pymodule]
    mod submod {}
}

This is because we specifically look for #[pymodule], but don't allow the full name: https://github.com/PyO3/pyo3/blob/main/pyo3-macros-backend/src/module.rs#L213

We should allow the full name to work.