skillfed

setuptools-rust

Setuptools Rust extension plugin

setuptools-rust v1.13.0 6.9M downloads/30d#1,809 on PyPI677
Permissive license Active released

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-rust

uv

uv add setuptools-rust

poetry

poetry add setuptools-rust

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIXProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Version Control

Tags

rust python extensionsetuptools rust pluginpyo3 packagingcompile rust to pythonrust cpython bindingsbuild rust modulespython rust integration
rust-bindingsextension-buildingpackaging

More Version Control packages