maturin

repository·main·Indexed 26 days ago

https://github.com/pyo3/maturin

A tool for building and publishing Rust-based Python packages. It supports PyO3, CFFI, and UniFFI bindings, allowing developers to package Rust binaries as high-performance Python modules. Maturin provides CLI commands for project creation, building wheels, and development installation, and supports PEP 621 for Python package metadata.

Tokens
28.5K
Snippets
117
Records
214
Agent score
90%

What's inside maturin

  1. Test free-threaded stable ABI (abi3t) support

    main

    The pyo3-abi3t crate is a specialized test crate used to verify maturin's support for the free-threaded stable ABI (abi3t).

    To use this test crate, you must use a specific version of PyO3 that supports these features. Specifically, it requires the opaque-pyobject branch of the ngoldbaum/pyo3 repository, which implements the abi3t and abi3t-py3XY features that maturin's testing suite detects.

  2. Check Maturin platform and architecture support

    main

    Maturin supports a wide range of platforms and architectures for building wheels and downloadable binaries:

    • Windows: 32-bit x86, 64-bit x86, and arm64
    • Linux: x86, x86_64, armv7, aarch64, ppc64le (musl), and s390x (gnu)
    • macOS: x86_64 and aarch64

    All architectures included in manylinux (aarch64, armv7l, ppc64le, ppc64, i686, x86_64, s390x) are supported.

  3. Rename the Rust module to avoid IDE conflicts

    main

    If your Rust module has the same name as your Python package, IDEs may struggle with type completion. You can rename the internal Rust module (e.g., to _my_project) to distinguish it.

    1. In pyproject.toml, set module-name = "<package>.<rust_module_name>".
    2. In your Rust code, either rename the function in lib.rs or use the #[pyo3(name = "...")] attribute on the #[pymodule] declaration.
    [tool.maturin]
    module-name = "my_project._my_project"
    #[pymodule]
    #[pyo3(name = "_my_project")]
    fn my_project(...) 
  4. Enable full features when bootstrapping from sdist in maturin 0.15

    main
    When bootstrapping maturin from an sdist, version 0.15 builds with --no-default-features by default. To enable full features for distro packaging, set the MATURIN_SETUP_ARGS environment variable.
  5. Install maturin via Homebrew

    main

    On macOS, you can install maturin using Homebrew.

    Warning: Installing via Homebrew will also install Rust as a dependency. If you already have Rust installed via rustup, this may result in two separate Rust installations, which can cause conflicts. If you use rustup, consider installing maturin from source with cargo instead.

    brew install maturin