Python for Cedarling#
Cedarling provides a binding for Python programs via the pyo3 library. This allows Python developers to use the cedarling crate in their code directly.
Requirements#
- Rust 1.63 or greater
- CPython 3.10 or greater
- For linux systems, installing
build-essentialusing your distribution's package manager is recommended
Building#
The recommended way to include cedarling in a Python project is to compile it to a python wheel via Maturin. Follow these steps to compile the wheel:
- Install
maturinin an isolated environment. Usingvenvis recommendedpython -m venv venv source venv/bin/activate pip install maturin - For linux, install
maturin[patchelf]instead to get the necessary dependencies - Clone the jans repository and change your working directory to that location
- Navigate to
jans-cedarling/bindings/cedarling_python - Compile the binding:
maturin build --release - The wheel will be available in
target/wheels/
Including in projects#
If you are developing a simple project in a venv setup, in the previous section you can run maturin develop --release and maturin will install the wheel into the currently activated virtual environment. After that, you may run your code directly from the command line.
In case of more complicated projects with a dependency manager such as poetry, you can either install the wheel via the command line:
poetry add path/to/wheel.whl
pyproject.toml:
...
[tool.poetry.dependencies]
cedarling_python = {path = "path/to/wheel.whl"}
For other dependency managers, please check their documentation on how to include static wheels in a project.
Usage#
Once the wheel is included in your project, you may use classes from the cedarling_python module in your code, which acts as a Python wrapper around cedarling's functions. See the usage document for details.
Created: 2024-10-09