Skip to main content

maturin-pants-plugin

PyPI Version

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. The plugin needs the Python backend too:

[GLOBAL]
plugins = ["maturin-pants-plugin==<version>"]
backend_packages.add = ["pants.backend.python"]

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.3.4

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.3.4
File Interpreter ABI Platform
maturin_pants_plugin-0.3.4-py3-none-any.whl Python 3 none any Details

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

Download URL maturin_pants_plugin-0.3.4-py3-none-any.whl
Size 21.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cff64ff7c15ebfb5c41068e86b65de03e9dfa1cd98f6e9367bd878e5095cbb70
BLAKE2b-256 checksum
How to use checksums
066e2275d2152f1abbbd4006d15bd79c473e8233530d905bd4c1f9fb2ef7c5df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 21, 2026.

Transparency log

Security for maturin-pants-plugin 0.3.4

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.

Full provenance

All 1 file in this release has been uploaded with provenance metadata.

Attestation for maturin_pants_plugin-0.3.4-py3-none-any.whl

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 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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