Maturin compiles Rust crates with PyO3, cffi, or uniffi bindings into Python wheels and sdists. It supports develop installs, cross-platform releases, and pyproject.toml-driven builds.
Overview
Maturin is the standard tool for packaging Rust code as Python modules on PyPI. Commands such as maturin new scaffold a crate, maturin develop installs into the active virtualenv, and maturin build emits wheels for distribution.
Bindings modes cover PyO3 extensions, cffi, uniffi, and pure Rust binaries exposed as console scripts. The tool reads metadata from Cargo.toml and pyproject.toml, merges dependency lists, and can generate typed stubs for agents.
Linux publishing integrates manylinux docker flows and auditwheel-compatible tagging, with GitHub Action guidance for CI releases. Mixed Rust and Python trees place sources beside Cargo.toml, and maturin copies native modules into the Python package on develop.
Install via pip, pipx, uv, or release binaries; Python 3.8+ targets are supported alongside basic PyPy and GraalPy notes in the user guide.
Key features
- maturin new, develop, and build workflows
- PyO3, cffi, and uniffi binding modes
- pyproject.toml PEP 621 metadata support
- manylinux and auditwheel compatibility checks
- Console script entrypoints from Rust binaries
- Sdist output when pyproject build-system is set
Use cases
- Ship performance-critical Rust as pip packages
- Iterate on PyO3 modules inside a virtualenv
- Publish audited manylinux wheels from CI