Repository navigation
chore(python): lock the test dependencies with uv.lockj #1582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'stash': patch | ||
| --- | ||
|
|
||
| The `stash-supply-chain-security` skill now lists `uv` among the ecosystems Dependabot updates. The repository's Python SDK has a `uv.lock` for its test dependencies, and a Dependabot entry for it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,13 +24,11 @@ set -euo pipefail | |
| # one on PATH, and the one on PATH is the python3 `[tools]` names, the one | ||
| # the Rust tests link. A `.venv` made for another interpreter version is | ||
| # recreated, so a change to `[tools]` cannot leave the tests on the old one. | ||
| # No lockfile is written: `uv pip install` resolves against the index each | ||
| # time. The package has no runtime dependency. The only things resolved here | ||
| # are maturin, as the build backend, and the `test` extra: pytest, plus attrs, | ||
| # Pydantic and SQLAlchemy for the declaration tests. So a lockfile would fix | ||
| # test tooling versions alone. One comes, with its Dependabot entry, when the | ||
| # package gains a runtime dependency. See pyproject.toml for why the extra has | ||
| # no upper bounds. | ||
| # The `test` extra comes from uv.lock, with --locked, so a lock that does not | ||
| # match pyproject.toml fails the build. Dependabot updates the lock. The | ||
| # package has no runtime dependency, so the lock fixes test tooling versions | ||
| # alone. maturin, the build backend, is not in the lock. uv resolves it from | ||
| # the index in an isolated build environment, within pyproject.toml's range. | ||
| want="$(python3 -c 'import sys; print("%d.%d" % sys.version_info[:2])')" | ||
| have="$([ -x .venv/bin/python ] && .venv/bin/python -c 'import sys; print("%d.%d" % sys.version_info[:2])' || true)" | ||
| if [ "$have" != "$want" ]; then | ||
|
|
@@ -42,9 +40,13 @@ fi | |
| # `wheels` job in tests-python.yml builds release, because the time it records | ||
| # is the cost of the wheel a user would install. | ||
| export MATURIN_PEP517_ARGS="${MATURIN_PEP517_ARGS:---profile dev}" | ||
| # The package itself, built by maturin through the PEP 517 backend, plus the | ||
| # `test` extra. Always reinstall the package so a Rust change is picked up. | ||
| uv pip install --python .venv/bin/python --reinstall-package stackencrypt '.[test]' | ||
| # The `test` extra at the locked versions. The project itself is left out: | ||
| # uv sync would install it editable. | ||
| uv sync --locked --extra test --no-install-project --python .venv/bin/python | ||
| # The package itself, built by maturin through the PEP 517 backend. Always | ||
| # reinstall it so a Rust change is picked up. Its dependencies are the ones | ||
| # above, so none is resolved here. | ||
| uv pip install --python .venv/bin/python --reinstall-package stackencrypt --no-deps . | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor This Source: code-review · claude-sonnet-5-5 Generated by Claude Code |
||
| .venv/bin/python -c 'import stackencrypt as s; print("stackencrypt", s.__version__, "engine", s.__engine__)' | ||
| """ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: no test checks that
mise run buildinstalls thetestextra withuv sync --lockedand the package with--no-deps.Impact: The lock only works while both flags are there. If an edit removes
--locked, uv updates the lock when it does not match, and the build still passes. If an edit removes--no-deps,uv pip installresolves the extra's dependencies again from PyPI. In both cases CI installs versions the lock does not fix, with no error. Thelivejob has theCS_*credentials, so it would then install releases nobody checked.Evidence:
scripts/__tests__/python-ci.test.mjsreadslanguages/python/mise.tomlonly for task names and the Python version. It does not read thebuildtask body.e2e/tests/supply-chain.e2e.test.tschecks the Dependabot entry, not how the lock is installed.Fix: Add a test to
scripts/__tests__/python-ci.test.mjsthat reads thebuildtask body. It should expect exactly oneuv syncline with--locked, and--no-depson everyuv pip installline. It should also expectlanguages/python/uv.lockto exist.Found by 1 model: claude