Skip to main content

maturin-pants-plugin

A Pantsbuild plugin for building and publishing Rust-backed Python wheels with maturin.

Status: alpha. pants package and pants publish work for maturin_wheel targets; only *.whl outputs 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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for maturin-pants-plugin 0.1.0
File Interpreter ABI Platform
maturin_pants_plugin-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / maturin_pants_plugin-0.1.0-py3-none-any.whl

Download URL maturin_pants_plugin-0.1.0-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de1c88375d4e68e369a56f6b70ede5c93dc7c1aaa5ad0156a4062fd9b62b9bb9
BLAKE2b-256 checksum
How to use checksums
629d86930689ffa63c29528b5593be92a2c2952322d9dbd46e6b234572865372
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

Release history Release notifications | RSS feed

0.2.1

1 release file

0.2.0

1 release file

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page