explaingit

pyo3/maturin

5,588RustAudience · developerComplexity · 3/5Setup · moderate

TLDR

Build tool that compiles Rust code into Python packages you can install with pip, handling the packaging complexity so Rust-backed Python libraries can be published to PyPI like any other package.

Mindmap

mindmap
  root((maturin))
    What it does
      Rust to Python packaging
      Wheel builder
      PyPI publishing
    Commands
      new project setup
      build wheel file
      develop local install
    Bindings supported
      pyo3
      cffi
      uniffi
    Output
      pip-installable packages
      Mixed Rust and Python
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a Python library with Rust performance-critical code and publish it to PyPI for pip installation

USE CASE 2

Create a new mixed Rust and Python project with the correct file structure using the new command

USE CASE 3

Develop and test Rust-backed Python extensions locally using maturin develop for fast iteration

USE CASE 4

Build Linux-compatible Python wheels that work across many Linux distributions

Tech stack

RustPythonpyo3cffiuniffi

Getting it running

Difficulty · moderate Time to first run · 30min

Requires both Rust toolchain and Python installed, Linux wheel builds need a manylinux Docker container for broad distribution compatibility.

In plain English

Maturin is a tool for building Python packages that contain code written in Rust. Rust is a programming language known for running fast, and Python developers sometimes use it to write performance-critical parts of their libraries while keeping a Python interface that end users interact with. Maturin handles the complicated process of compiling the Rust code and packaging it so it can be installed like any other Python package using pip. The tool supports several ways of connecting Rust code to Python: pyo3 (the most common approach), cffi, and uniffi. It can build packages for Python 3.8 and newer across Windows, Linux, macOS, and FreeBSD. Packages built with maturin can be uploaded to PyPI, the standard Python package repository, so other people can install them. There are three main commands. The new command creates a fresh project with the right file structure already set up. The build command compiles the Rust code into a wheel file, which is the standard format for installable Python packages. The develop command builds and installs the package directly into your current Python environment for quick testing during development. Maturin also supports projects that mix Rust and Python code in the same package. You place your Python files in a folder alongside the Rust source, and maturin figures out how to combine them during the build. Package metadata (name, version, dependencies, and so on) can be specified in a standard pyproject.toml file, the same format other Python build tools use. The README covers the full workflow: installation, the three main commands, how to structure mixed projects, how to specify metadata, and how to publish to PyPI. It also includes notes on building Linux packages compatible with many Linux distributions and on using maturin in GitHub Actions for automated publishing.

Copy-paste prompts

Prompt 1
I have a Python library with a slow function. Help me rewrite it in Rust using pyo3 and package it with maturin so I can install it with pip.
Prompt 2
Walk me through publishing my maturin-built Rust and Python package to PyPI using GitHub Actions.
Prompt 3
How do I set up a new mixed Rust and Python project with maturin that includes both a Python module and Rust extensions?
Prompt 4
My maturin build fails on Linux with a wheel compatibility error. How do I build a manylinux-compatible wheel?
Prompt 5
How do I specify package metadata like version, dependencies, and classifiers in pyproject.toml for a maturin project?
Open on GitHub → Explain another repo

← pyo3 on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.