Skip to content
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

refs #4286 -- allow setting submodule on declarative pymodules #4301

Merged
merged 1 commit into from
Jul 2, 2024

Conversation

alex
Copy link
Contributor

@alex alex commented Jun 29, 2024

No description provided.

@alex alex force-pushed the pymodule-submodule branch 2 times, most recently from f4c04ca to 6fdcf0e Compare June 29, 2024 20:28
@davidhewitt
Copy link
Member

This makes a lot of sense, thanks. I wonder, should we go further and make it so that submodule is set by default when nested, similar to what we already do with module setting?

That way, explicitly marking submodule is only necessary if the module is "top-level" as far as Rust source structure goes.

Maybe that makes the rules too magical and complex 🤔. I think it's hopefully quite intuitive though?

@alex
Copy link
Contributor Author

alex commented Jul 1, 2024 via email

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, a follow up seems ok to me.

Just a couple of final thoughts on this PR in that case 👍

pyo3-macros/src/lib.rs Show resolved Hide resolved
pymodule_module_impl(module, is_submodule)
}
Item::Fn(function) => {
parse_macro_input!(args as Nothing);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it seems reasonable to me for function modules to also support submodule?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's relevant for function modules -- there's never been a need to use #[pymodule] for submodules with functions.

@alex alex force-pushed the pymodule-submodule branch 2 times, most recently from 1e6dd87 to 9c154b5 Compare July 1, 2024 22:48
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks! One tiny nit & then please merge :)

pyo3-macros-backend/src/module.rs Outdated Show resolved Hide resolved
@alex alex force-pushed the pymodule-submodule branch from 9c154b5 to db2d069 Compare July 2, 2024 11:03
@alex alex enabled auto-merge July 2, 2024 11:03
@alex alex added this pull request to the merge queue Jul 2, 2024
Merged via the queue into PyO3:main with commit ccd0447 Jul 2, 2024
40 of 41 checks passed
@alex alex deleted the pymodule-submodule branch July 2, 2024 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants