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/clangand Python dev headers are installed.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hello_rust_pyo3-0.1.0-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: hello_rust_pyo3-0.1.0-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 100.1 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a887bb67b634281703b89e1d47c3423f42caddbf7887c0a70bd195924fdd8228
|
|
| MD5 |
bd2fef663c52b7bcbf19e37f1bc81b9a
|
|
| BLAKE2b-256 |
c2ad8c04e93635e9611e1a0ed0b3f23bf38ca3b006ef97b4b540a0347f032df6
|