mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
ci: locate maturin-built .so via filesystem, not via import
The previous version of this step did `python -c "import headroom._core"`
to find the wheel's installed `.so` path. That failed in CI:
ModuleNotFoundError: No module named 'headroom._core'
— exactly the chicken-and-egg this step exists to fix. The editable
install (`pip install -e .`) puts the in-tree `headroom/` source dir
ahead of site-packages on `sys.path`. So `import headroom` finds the
in-tree dir (which doesn't yet have the `.so`), then
`import headroom._core` fails to find the submodule. The symlink we're
about to create is what makes the import work — but we can't import
to discover the symlink target before creating it.
Locate the `.so` via filesystem instead: read site-packages from
`site.getsitepackages()[0]`, glob for `_core.cpython-*.so` under
`<site-packages>/headroom/`, and symlink that into the in-tree dir.
The smoke test (`from headroom._core import DiffCompressor`) runs
*after* the symlink and confirms end-to-end resolution.
Also added `set -euo pipefail` and a sanity check with `ls -la` of the
site-packages dir if the glob comes up empty, so future failures
diagnose themselves.
This commit is contained in:
parent
7fd5b2196c
commit
dd0697a7c9
1 changed files with 13 additions and 1 deletions
14
.github/workflows/ci.yml
vendored
14
.github/workflows/ci.yml
vendored
|
|
@ -60,11 +60,23 @@ jobs:
|
|||
# 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.
|
||||
#
|
||||
# We locate the `.so` via filesystem (not via `import headroom._core`)
|
||||
# because the import would fail at this point — the editable install's
|
||||
# in-tree `headroom/` directory shadows site-packages and doesn't
|
||||
# contain the `.so` yet. That's exactly the problem this step fixes.
|
||||
- name: Build Rust extension (headroom._core)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
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())")
|
||||
SITE_PACKAGES=$(python -c "import site; print(site.getsitepackages()[0])")
|
||||
SO_FILE=$(ls "$SITE_PACKAGES"/headroom/_core.cpython-*.so 2>/dev/null | head -1)
|
||||
if [[ -z "$SO_FILE" ]]; then
|
||||
echo "error: could not find _core.cpython-*.so under $SITE_PACKAGES/headroom/" >&2
|
||||
ls -la "$SITE_PACKAGES/headroom/" || true
|
||||
exit 1
|
||||
fi
|
||||
ln -sf "$SO_FILE" "headroom/$(basename "$SO_FILE")"
|
||||
python -c "from headroom._core import DiffCompressor; print('headroom._core OK:', DiffCompressor)"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue