Skip to content
Discussion options

You must be logged in to vote

Yes, you can use #[pymodule_init] to apply the same trick.

#[pymodule_init]
fn init(m: &Bound<'_, PyModule>) -> PyResult<()> {
    let modules = PyModule::import(m.py(), "sys")?.getattr("modules")?;
    modules.set_item("maturin_starter.submodule", m.getattr("submodule")?)?;
    Ok(())
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@j-g00da
Comment options

@davidhewitt
Comment options

Answer selected by j-g00da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants