diff --git a/tools/parity_venv.sh b/tools/parity_venv.sh index bf465ec..460c19a 100755 --- a/tools/parity_venv.sh +++ b/tools/parity_venv.sh @@ -10,8 +10,10 @@ # tools/parity_venv.sh install from the Gitea registry # tools/parity_venv.sh --local install the local wheelhouse build # -# Then run whichever slice of the app suite the current increment claims: -# cd ../app && UV_PROJECT_ENVIRONMENT=.venv-ocp-parity uv run pytest backend/tests/test_geom_memo.py +# Then run whichever slice of the app suite the current increment claims — with +# the venv's own interpreter, NOT `uv run`, which re-syncs the environment +# against the manifest and so puts the stock wheel straight back: +# cd ../app && .venv-ocp-parity/bin/python -m pytest backend/tests/test_geom_memo.py set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) @@ -27,29 +29,46 @@ cd "$APP" export UV_PROJECT_ENVIRONMENT="$VENV_NAME" echo "--- syncing the app's dependencies into $VENV_NAME ---" -uv sync --all-groups +# 3.12 explicitly: the app's floor is >=3.12, so uv would otherwise pick the +# newest interpreter on the box and the parity venv would stop resembling what +# the image ships. +uv sync --all-groups --python 3.12 + +# `uv pip` does NOT honour UV_PROJECT_ENVIRONMENT — it discovers an environment +# the way pip does, which here means the app's own .venv. Without --python it +# swaps the wrong environment entirely, and the sanity check below still passes +# because `uv run` *does* honour the variable and reads the untouched parity +# venv. Pass the target explicitly to both commands. +PY_BIN="$APP/$VENV_NAME/bin/python" # Removal must precede installation: both distributions install a top-level # OCP/, so installing over the stock wheel would leave a half-overwritten mix. echo "--- removing the stock wheel ---" -uv pip uninstall cadquery-ocp-novtk || true +uv pip uninstall --python "$PY_BIN" cadquery-ocp-novtk || true echo "--- installing n3xd-ocp ($SOURCE) ---" if [ "$SOURCE" = "local" ]; then - uv pip install "$OCP_REPO"/wheelhouse/*.whl + uv pip install --python "$PY_BIN" "$OCP_REPO"/wheelhouse/*.whl else - uv pip install --index-url "$INDEX" --prerelease=allow n3xd-ocp + uv pip install --python "$PY_BIN" --index-url "$INDEX" \ + --prerelease=allow n3xd-ocp fi +# Everything below runs the venv's interpreter directly. `uv run` would re-sync +# the environment against the app's manifest first, which still asks for +# cadquery-ocp-novtk — reinstalling it on top of the swap. echo "--- sanity ---" -uv run python -c " +# Asserted, not printed: __occt_version__ exists only on our wheel, so this is +# also the check that the swap landed in the environment we meant. +"$PY_BIN" -c " import OCP +assert hasattr(OCP, '__occt_version__'), 'this is not n3xd-ocp — the swap missed' print('OCP', OCP.__version__, '/ OCCT', OCP.__occt_version__) print('modules:', len(OCP._OCP.__all_modules__)) " echo "--- coverage against the app's symbol inventory ---" -uv run python "$HERE/inventory.py" --check || \ +"$PY_BIN" "$HERE/inventory.py" --check || \ echo "(incomplete coverage is expected until the increments land)" # The binding's own suite, run from the swapped venv: this is what exercises the @@ -57,4 +76,4 @@ uv run python "$HERE/inventory.py" --check || \ # OCP/n3xd_ocp, so it works long before the app's own tests can collect (their # conftest imports n3xd.main, i.e. the whole OCP surface). echo "--- ocp suite under the swapped venv ---" -uv run pytest "$OCP_REPO/tests" -q +"$PY_BIN" -m pytest "$OCP_REPO/tests" -q