Skip to main content

Small example of a Rust extension module for Python using PyO3 + maturin.

Project description

hello-rust-pyo3

Minimal Rust extension for Python using PyO3 + maturin.

Quick test (local)

python -m venv .venv
# Windows: py -3.12 -m venv .venv
source .venv/bin/activate  # Windows: .\.venv\Scripts\Activate.ps1
python -m pip install -U pip maturin
maturin develop  # builds & installs into the venv

python -c "import hello_rust_pyo3 as m; print(m.add(2,3), m.greet('Sequa'))"

Build wheels / sdist

maturin build --release --out dist           # wheels
maturin build --release --sdist --out dist   # add sdist

Verify & Publish

python -m pip install -U twine
python -m twine check dist/*
# TestPyPI
python -m twine upload -r testpypi -u __token__ -p <TESTPYPI_TOKEN> dist/*
# PyPI
python -m twine upload -r pypi -u __token__ -p <PYPI_TOKEN> dist/*

Notes (Windows/macOS/Linux)

  • Install Rust toolchain: https://rustup.rs/
  • Windows: install Microsoft C++ build tools (Visual Studio Build Tools).
  • macOS: Xcode Command Line Tools (xcode-select --install).
  • Linux: ensure gcc/clang and Python dev headers are installed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hello_rust_pyo3-0.1.0-cp39-cp39-win_amd64.whl (100.1 kB view details)

Uploaded CPython 3.9Windows x86-64

File details

Details for the file hello_rust_pyo3-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for hello_rust_pyo3-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a887bb67b634281703b89e1d47c3423f42caddbf7887c0a70bd195924fdd8228
MD5 bd2fef663c52b7bcbf19e37f1bc81b9a
BLAKE2b-256 c2ad8c04e93635e9611e1a0ed0b3f23bf38ca3b006ef97b4b540a0347f032df6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page