ci: use maturin build + pip install instead of maturin develop

`maturin develop` requires a virtualenv (it errors with "Couldn't find a
virtualenv or conda environment"). CI's setup-python provides a bare
system Python without a venv, so the dev script's build path doesn't
work there.

This switches CI to build a release wheel via `maturin build` and
install it with `pip install --force-reinstall --no-deps`. Then symlink
the installed `.so` into the in-tree `headroom/` package so the
editable install resolves `import headroom._core` past the source-dir
shadowing of site-packages.

`scripts/build_rust_extension.sh` is unchanged — it stays optimized for
local dev (where there IS a venv).
This commit is contained in:
chopratejas 2026-04-26 10:04:06 -07:00
parent 7c3516aad5
commit 7fd5b2196c

View file

@ -55,9 +55,18 @@ jobs:
run: |
pip install 'maturin>=1.5,<2.0'
# `scripts/build_rust_extension.sh` uses `maturin develop` which requires
# a virtualenv. CI runs against bare setup-python with no venv, so build
# a wheel + pip-install it instead. Then symlink the `.so` into the
# in-tree `headroom/` package so the editable install resolves
# `import headroom._core` past the source dir shadowing site-packages.
- name: Build Rust extension (headroom._core)
run: |
bash scripts/build_rust_extension.sh
maturin build --release -m crates/headroom-py/Cargo.toml --out dist
pip install --force-reinstall --no-deps dist/headroom_core_py-*.whl
SO_FILE=$(python -c "import headroom._core, pathlib; print(pathlib.Path(headroom._core.__file__).resolve())")
ln -sf "$SO_FILE" "headroom/$(basename "$SO_FILE")"
python -c "from headroom._core import DiffCompressor; print('headroom._core OK:', DiffCompressor)"
- name: Run linting
if: matrix.python-version == '3.12'