/pyo3-hatch-experiment

Experiment in combining PyO3 and Hatch

Primary LanguagePythonMIT LicenseMIT

pyo3-hatch-experiment

This is an experiment in combining PyO3 and Hatch, instead of using maturin or setuptools-rust. Cargo gets called via a custom build hook implemented in cargo_build.py. The hook is configured in pyproject.toml to run only for the wheel target, because there's no point in building the library for a source distribution.

What's experimental?

  • The hook assumes that the working directory of hatchling is also where the Rust package exists (with Cargo.toml, etc.), and where the compiled module for Python should be placed.
  • Using custom build targets may need some extra care depending on whether the hook should or shouldn't run. The hook class itself doesn't check the target.