Maturin is a build tool designed to create and publish Python packages that incorporate Rust code via PyO3, cffi, or uniffi bindings, as well as standalone Rust binaries. It automates much of the complex build process for hybrid Python-Rust projects, including wheel and sdist generation. The current version is 1.12.6, and it sees frequent minor releases to address bugs and add features.
pip install maturinVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a new PyO3-based Python project with Maturin, then build and install it in editable mode for development. The `maturin develop` command handles compiling the Rust code and making it available to your Python environment.
Replace `maturin upload` with `twine upload dist/*` after building your wheels and sdists. Ensure `twine` is installed (`pip install twine`).
Install the Rust toolchain by following instructions on https://rustup.rs/ (recommended method using `rustup`).
Consult the `maturin` and `pyo3` documentation for recommended version pairings. Update `pyo3` in your `Cargo.toml` and potentially `maturin` itself if necessary. `maturin` will often provide helpful error messages for major incompatibilities.
Always test your generated wheels on the target platforms. For complex scenarios, explicitly specify target platforms using `maturin build --target <TRIPLE>`. Ensure you are on the latest `maturin` version, as many platform-specific issues are actively addressed.
To run `maturin` or other shell commands from a Python script, use Python's `subprocess` module (e.g., `subprocess.run(['maturin', 'new', '--binding', 'pyo3', 'my_rust_package'], check=True)`).
Ensure `maturin` commands are executed in a shell environment, or use `subprocess.run(['maturin', 'new', '--binding', 'pyo3', 'my_rust_package'], check=True)` in Python scripts to execute them correctly.
No dependency data recorded yet.