安裝
從軟體包管理器安裝
PyPI
maturin 以 Python 二進制 wheel 的形式發佈於 PyPI,您可以使用 pipx 進行安裝:
pipx install maturin
There are some extra dependencies for certain scenarios:
zig: use zig as linker for easier cross compiling and manylinux compliance.patchelf: repair wheels that links other shared libraries.
For example, to install patchelf dependencies: pipx install maturin[patchelf].
Note
pip install maturinshould also work if you don’t want to use pipx.
Homebrew
On macOS maturin is in Homebrew and you can install maturin from Homebrew:
brew install maturin
Note: Installing maturin with Homebrew will also install Rust as a dependency, even if you already have Rust installed via rustup. This results in two separate Rust installations, which can cause conflicts. If you’ve already installed Rust with rustup, consider installing maturin with a method other than Homebrew (such as from source with cargo).
conda
Installing from the conda-forge channel can be achieved by adding conda-forge to your conda channels with:
conda config --add channels conda-forge
conda config --set channel_priority strict
Once the conda-forge channel has been enabled, maturin can be installed with:
conda install maturin
Alpine Linux
On Alpine Linux, maturin is in community repository and can be installed with apk after enabling the community repository:
apk add maturin
從 GitHub Releases 下載
You can download precompiled maturin binaries from the latest GitHub Releases.
You can also use cargo-binstall to install maturin from GitHub Releases:
# Run `cargo install cargo-binstall` first if you don't have cargo-binstall installed.
cargo binstall maturin
從來源碼建置
crates.io
您可以使用 cargo 從 crates.io 安裝 maturin:
cargo install --locked maturin
Git 儲存庫
cargo install --locked --git https://github.com/PyO3/maturin.git maturin