Skip to content

Commit

Permalink
Automatically treat nested modules as submodules
Browse files Browse the repository at this point in the history
fixes PyO3#4286
  • Loading branch information
alex committed Jul 2, 2024
1 parent ee9123a commit efebf51
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions newsfragments/4308.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Nested declarative `#[pymodule]` are automatically treated as submodules (no `PyInit_` entrypoint is created)
1 change: 1 addition & 0 deletions pyo3-macros-backend/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ pub fn pymodule_module_impl(
)? {
set_module_attribute(&mut item_mod.attrs, &full_name);
}
item_mod.attrs.push(parse_quote!(#[pyo3(submodule)]));
}
}
Item::ForeignMod(item) => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_declarative_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ mod declarative_module {
}
}

#[pymodule(submodule)]
#[pymodule]
#[pyo3(module = "custom_root")]
mod inner_custom_root {
use super::*;
Expand Down

0 comments on commit efebf51

Please sign in to comment.