parity_venv.sh: swap the environment it claims to swap
The script exported UV_PROJECT_ENVIRONMENT and then reached for `uv pip`, which does not honour it — it discovers an environment the way pip does, so the uninstall and install landed in the app's own .venv. The sanity check that follows could not notice, because `uv run` *does* honour the variable and so read the untouched parity venv. Net effect: the swap happened in the wrong place and reported success. Inc 0's parity claim never exercised the parity venv at all. Two fixes, since the second only surfaced once the first was in: - `uv pip` gets --python pointing at the parity venv. - everything afterwards runs that venv's interpreter directly. `uv run` re-syncs the environment against the app's manifest before running, and the manifest still asks for cadquery-ocp-novtk, so it reinstalled the stock wheel on top of the swap. The usage note at the top said to drive the app's tests that way too; it now says to use the venv's python. Also pins `uv sync --python 3.12`, so the parity venv keeps resembling what the image ships instead of following whatever interpreter is newest on the box, and turns the sanity print into an assertion on __occt_version__ — an attribute only our wheel defines, which makes it a check that the swap landed. Verified end to end against the published 7.9.3.1.dev2: installs anonymously from the Gitea index, 31 modules, ocp suite 48 passed, and the app's main venv is left on stock. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DfriM8XUkn7uYf5Dwe2xo6
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user