Attribute Macro pyo3::pymodule

source · []
#[pymodule]
Available on crate feature macros only.
Expand description

A proc macro used to implement Python modules.

The name of the module will be taken from the function name, unless #[pyo3(name = "my_name")] is also annotated on the function to override the name. Important: the module name should match the lib.name setting in Cargo.toml, so that Python is able to import the module without needing a custom import loader.

Functions annotated with #[pymodule] can also be annotated with the following:

AnnotationDescription
#[pyo3(name = "...")]Defines the name of the module in Python.

For more on creating Python modules see the module section of the guide.