setuptools-rust
Setuptools Rust extension plugin
What it is and what it does
setuptools-rust bridges the gap between Rust and Python packaging by acting as a setuptools plugin that knows how to compile Rust code into Python extension modules. It handles the build process for extensions written with PyO3 or rust-cpython, letting you distribute them as wheels just like C extensions. The plugin reads configuration from pyproject.toml, invokes the Rust toolchain (cargo), and integrates the compiled binaries into your Python package.
You use it by declaring Rust extension modules in your pyproject.toml, pointing to your Cargo.toml and specifying the binding framework (PyO3 or rust-cpython). It then manages compilation during package installation or wheel building. The plugin supports both library modules (for import) and binary executables, and handles cross-compilation via tools like crossenv or cargo-zigbuild.
Use it for:
- Package a performance-critical Python library written in Rust for distribution on PyPI.
- Build a Python extension module that calls Rust code for CPU-intensive tasks.
- Distribute a Rust binary tool alongside Python code as a single wheel.
- Create a namespace package that mixes Rust extension modules with pure Python code.
- Cross-compile Rust extensions for deployment on different architectures.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
setuptools-rust is a setuptools plugin that compiles and packages Python extensions written in Rust, using PyO3 or rust-cpython bindings.
Yes, if you are writing Python extensions in Rust. The plugin is actively maintained, has no known vulnerabilities, low install friction, and permissive licensing. It is the standard way to package Rust extensions for PyPI distribution. Install it only in your build-system requirements (pyproject.toml), not as a runtime dependency.
Install
setuptools-rust on PyPI
pip
pip install setuptools-rustuv
uv add setuptools-rustpoetry
poetry add setuptools-rustInstalling setuptools-rust
Before you install
Low install friction; pure Python wheel with only setuptools and semantic_version as runtime dependencies. Actively maintained with recent releases and 677 repository stars.
License in practice
MIT-licensed under permissive terms, allowing use in commercial and private projects without significant restrictions.
Quickstart
# In pyproject.toml:
[build-system]
requires = ["setuptools", "setuptools-rust"]
build-backend = "setuptools.build_meta"
[[tool.setuptools-rust.ext-modules]]
target = "my_module._lib"
binding = "PyO3"
# Then build and install:
python -m pip install -e .
Requires Rust toolchain (rustc, cargo) installed on the build system; Python 3.9 or later.
Verify before relying
- Whether cross-compilation support (crossenv, cross, cargo-zigbuild) is production-ready or experimental.
- Performance overhead or compilation time impact compared to C extensions.
- Whether binary wheel distribution is supported on all major platforms (Linux, macOS, Windows).
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — setuptools, semantic_version |
| Maintenance | actively maintained — 48 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,925,523/month — #1,809 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: setuptools_rust-1.13.0-py3-none-any.whl
Keywords: distutils, setuptools, rust
Tags
More Version Control packages
Automatically extracts and manages Python…
permissive · top 1,000 on PyPI
dulwichDulwich provides pure Python access to Git…
unclear · top 1,000 on PyPI
pygit2pygit2 provides Python bindings to libgit2,…
copyleft · top 5,000 on PyPI
poetry-dynamic-versioningA Poetry plugin that automatically derives and…
permissive · top 5,000 on PyPI
whatthepatchParses and applies patch files in multiple diff…
permissive · top 5,000 on PyPI
versioningitAutomatically determines your Python package's…
permissive · top 5,000 on PyPI
maturinMaturin builds and publishes Python packages…
permissive · top 5,000 on PyPI
puccinialinInstalls Rust and Cargo into a temporary cache…
permissive · top 5,000 on PyPI
resultProvides a Rust-inspired Result type for Python…
permissive · top 5,000 on PyPI
advent-of-codeProvides pre-computed solutions to Advent of…
unclear · top 15,000 on PyPI
cargo-lambdacargo-lambda is a Cargo subcommand that…
permissive · top 15,000 on PyPI
retworkxA deprecated package name for rustworkx, a…
permissive · top 15,000 on PyPI
pybigtoolspybigtools is a Python wrapper around a Rust…
permissive · top 15,000 on PyPI
chia-rsProvides Python bindings to Rust crates for…
unclear · top 15,000 on PyPI
pip-hello-worldA minimal test package demonstrating setuptools…
permissive · top 15,000 on PyPI
moviepilot-rustProvides Rust-accelerated parsing and filtering…
unclear · top 15,000 on PyPI