Simple example of using PyO3 to call a Rust function from Python.
This code assumes both Rust and Python are installed.
- Create virtual environment:
python -m venv .venv
- Activate virtual environment:
source .venv/bin/activate
- Install requirements:
pip install -r requirements.txt
- Install the Rust package inside the Python virtualenv:
maturin develop
To run the Python example: python main.py