8000 Docs: Update rust-as-submodule instructions by NMertsch · Pull Request #2613 · PyO3/maturin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Docs: Update rust-as-submodule instructions #2613

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

Merged

Conversation

NMertsch
Copy link
Contributor
@NMertsch NMertsch commented May 20, 2025

Summary

The instructions in Import Rust as a submodule of your project are incomplete.

This PR adds instructions on how to update the Rust module name.

Fixes #2455

Current status

When updating the tool.maturin.module-name in pyproject.toml like this:

[tool.maturin]
module-name = "my_project._my_project"

maturin build emit the following warning:

⚠️ Warning: Couldn't find the symbol PyInit__my_project in the native library. Python will fail to import this module. If you're using pyo3, check that #[pymodule] uses _my_project as module name

What is added

This PR adds documentation on how to update the module name in lib.rs:

Either:

#[pymodule]
- fn my_project(...)
+ fn _my_project(...)

Or (if using pyo3 bindings):

#[pymodule]
+ #[pyo3(name = "_my_project")]
fn my_project(...)

Alternatives

I used the diff markup to highlight what needs to be changed. Some people might prefer the rust markup to display the desired state:

#[pymodule]
fn _my_project(...)

and

#[pymodule]
#[pyo3(name = "_my_project")]
fn my_project(...)

(Thanks for this awesome project!)

Add steps on how to rename the Rust submodule.

Fixes PyO3#2455
@messense messense merged commit a2b72ba into PyO3:main May 20, 2025
6 checks passed
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.

"Import Rust as a submodule of your project" docs are incomplete
3 participants
0