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

describe the need for module-name #1604

Merged
merged 4 commits into from
May 18, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ You can specify a different python source directory in `pyproject.toml` by setti
```toml
[tool.maturin]
python-source = "python"
module-name = "my_project._lib_name"
```

then the project structure would look like this:
Expand Down Expand Up @@ -153,12 +154,24 @@ my-project
├── my_project
│   ├── __init__.py
│   ├── bar.py
│   └── my_project.cpython-36m-x86_64-linux-gnu.so
│   └── _lib_name.cpython-36m-x86_64-linux-gnu.so
├── README.md
└── src
   └── lib.rs
```

When doing this also be sure to set the module name in our code to match the Cargo.toml's `lib.name`
Copy link
Member

Choose a reason for hiding this comment

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

It's actually the last part of module-name (split by .), lib.name in Cargo.toml doesn't matter when using module-name.


```
#[pymodule]
#[pyo3(name="_lib_name")]
fn my_lib_name(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_class::<MyPythonRustClass>()?;
Ok(())
}
```


## Python metadata

maturin supports [PEP 621](https://www.python.org/dev/peps/pep-0621/), you can specify python package metadata in `pyproject.toml`.
Expand Down