maturin-pants-plugin
A Pantsbuild plugin for building and publishing Rust-backed Python wheels with
maturin.
Status: alpha.
pants packageandpants publishwork formaturin_wheeltargets; only*.whloutputs are supported.
Installation
Add the plugin to pants.toml and enable its backend. The plugin needs the Python backend too:
[GLOBAL]
plugins = ["maturin-pants-plugin==<version>"]
backend_packages.add = ["pants.backend.python", "maturin_pants_plugin"]
cargo, rustc and the interpreters listed in [maturin].interpreter MUST be on the PATH of the shell that runs
Pants: the plugin passes PATH, HOME, CARGO_HOME and RUSTUP_HOME into the build sandbox.
Usage
Declare a maturin_wheel target in the directory holding the crate's Cargo.toml and pyproject.toml:
maturin_wheel(
name="wheel",
# Files `maturin build` needs that are not matched by the default `sources` globs.
dependencies=[":readme", "python/my_pkg"],
# Registries for `pants publish`. `@name` is a `.pypirc` section, anything else a `--repository-url`.
repositories=["@pypi"],
)
file(name="readme", source="README.md")
By default sources covers Cargo.toml, Cargo.lock, pyproject.toml, build.rs, src/**/*.rs, tests/**/*.rs
and python/**. cargo_toml and pyproject_toml default to the files of those names next to the BUILD file; both
MUST be matched by sources, and pyproject.toml MUST sit beside Cargo.toml.
pants package path/to/crate:wheel # runs `maturin build`, writes dist/<name>-<version>-<tags>.whl
pants publish path/to/crate:wheel # runs `maturin upload` once per entry of `repositories`
maturin upload reads credentials from MATURIN_PYPI_TOKEN, or MATURIN_USERNAME and MATURIN_PASSWORD, or your
~/.pypirc. Targets without repositories, or with skip_maturin_upload=True, are skipped by pants publish
without being built.
Options
Configure the [maturin] section of pants.toml. Run pants help-advanced maturin for the full list.
| Option | Default | Effect |
|---|---|---|
bindings |
pyo3 |
maturin build --bindings |
compatibility |
pypi |
maturin build --compatibility |
interpreter |
["python3.12", "python3.13", "python3.14"] |
One --interpreter per entry; [] omits it |
jobs |
unset | maturin build --jobs |
profile_guided_optimization |
false |
maturin build --pgo |
release |
true |
maturin build --release |
skip |
false |
Skip every maturin_wheel during pants publish |
skip_existing |
false |
maturin upload --skip-existing |
extra_env_vars |
[] |
Extra NAME or NAME=value entries for maturin |
Cargo's target/ directory lives in a Pants named cache, so repeated builds are incremental.
Regenerating the tool lockfile
The plugin ships a lockfile for the maturin tool itself. It is generated through the maturin resolve declared in
the repo's pants.toml and the maturin-tool requirement in provides/maturin-pants-plugin/BUILD:
pants generate-lockfiles --resolve=maturin
Supported versions
| Plugin | Pants | Python |
|---|---|---|
0.x |
2.33 |
3.14 |
Pants loads plugins into its own interpreter, so the plugin requires the Python version Pants runs on.
Releases
Wheels are published to PyPI. Release notes live in the changelog and on the GitHub releases page.
Contributing, Bug Reports and Feature Requests
This plugin lives in the pants-plugin-depot repo. See its CONTRIBUTING.md, or open an issue.
Metadata
Release files for maturin-pants-plugin 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| maturin_pants_plugin-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / maturin_pants_plugin-0.2.1-py3-none-any.whl
| Download URL | maturin_pants_plugin-0.2.1-py3-none-any.whl |
|---|---|
| Size | 20.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5108a96027b5400f2bb7ef43d858dbdb8b140a24770614cd252a19dafdfa4a51
|
|
BLAKE2b-256 checksum How to use checksums |
72003041e27c100fcf4ff8cb3ec3abbd79b1ea05c0f9e6cf1e2cb588f0f80d84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.
Transparency log