Skip to content

uv.lock: refuse targets outside the lock's [tool.uv] environments instead of reporting false gaps - #654

Merged
patrickballard merged 7 commits into
mainfrom
uv-lock-environments
Nov 21, 2026
Merged

patrickballard merged 7 commits into
mainfrom
uv-lock-environments

Conversation

@patrickballard

Copy link
Copy Markdown
Collaborator

What

A uv.lock made with [tool.uv] environments (the lock's supported-markers) is now checked only where uv installs it.

  • A target that was asked for (-t, [tool.wheelgap] targets, --dockerfile, a -p) and is outside the lock's environments is an error: exit code 2, the usual wheelgap: error: line, and the error object with --json. It names the targets the lock doesn't cover, the markers, and the asked-for targets it does cover.
  • The built-in default platforms are narrowed to the ones the lock covers, with a note on stderr (dropped with -q; --json's targets shows what was checked). A default platform covered for only some of the requested Pythons stays and is the error above.
  • If no marker holds for sure and one can't be decided for a target (platform_release, platform_machine on win32, a patch-level python_full_version, a marker that doesn't parse), wheelgap says it can't tell and stops (exit 2) rather than guess.
  • Targets inside the environments get exactly the answers they got before. The Python API (check_lockfile), wheelgap diff and the MCP tools go through the same check.

Why

uv locks such a project for its environments only. It leaves out the packages that only other environments need and the wheels for other platforms, and uv sync fails anywhere else. wheelgap read the lock as complete, so the left-out platforms showed as source/missing with no note: a wrong answer.

On the 300 most-starred Python repos, 8 of 82 root uv.lock files have supported-markers. With -p 3.13 -t linux-x86_64,linux-aarch64,macos-arm64,win-amd64 --offline, 6 of the 8 had cells outside their environments:

repo main this PR, same -t this PR, default targets
paperless-ngx win-amd64: 50 source, 2 missing error 3 covered targets, same counts as main
getsentry/sentry win-amd64: 52 missing error 3 covered targets, same counts
bojieli/ai-agent-book linux-aarch64: 195 source, 42 missing error 3 covered targets, same counts
ArchiveBox win-amd64: 29 source, 2 missing error 3 covered targets, same counts
exo-explore/exo win-amd64: 38 source, 25 missing error 3 covered targets, same counts
NousResearch/hermes-agent (python_version >= '3.14') all four targets answered for 3.13 error error (3.13 isn't covered)
spotDL, streamlit covered everywhere unchanged unchanged

How it follows uv

  • Read (uv 0.13.9 source): supported-markers is [tool.uv] environments (crates/uv-lock/src/lock/mod.rs, LockWire); required-markers is required-environments and doesn't limit where the lock installs. uv sync refuses a platform where none of the supported markers holds (uv-environment-operations/src/sync.rs), and Lock::from_resolution drops the wheels that can't be reached inside the environments.
  • Ran (uv 0.13.1, the installed one): a project with environments = ["sys_platform == 'linux' and platform_machine == 'x86_64'"] and colorama; sys_platform == 'win32'. uv lock wrote a lock without colorama and without markupsafe's Windows and macOS wheels; uv sync --dry-run on macOS failed with "The current Python platform is not compatible with the lockfile's supported environments"; uv sync --dry-run --python-platform x86_64-unknown-linux-gnu worked. That lock is the new fixture tests/fixtures/uvenvironments. A marker that is always true inside requires-python is written as an empty supported-markers list, which means no limit here too.
  • Markers are evaluated with the three-valued evaluator packages' markers already use (check.marker_value), so python_full_version is probed across the minor's patch releases.

The model is the one a pip installation report already has (check_report_targets): an input resolved for some environments is refused on others. The requires-python case (note, then a re-check on the index) doesn't fit here, because an index lookup can add wheels but not the packages the lock left out.

Issue #71 (default targets from required-environments) works as before; its tests pass unchanged.

Open question

For targets that were asked for, this PR stops the whole run (exit 2) rather than dropping the uncovered targets and checking the rest. That never gives a wrong answer, and the message lists the covered targets to rerun with, but -t all on a Linux-only lock is now an error instead of a partial table. Dropping them with a note and a --json key would be friendlier; it would also pass a CI run that asked for a platform nobody checked. wheelgap diff and the Python API don't narrow default platforms (only the command line and the MCP check_lockfile tool, which runs it, do).

Verified

  • New tests fail on main (14 of the 22 new CLI cases; the other 8 pin that covered targets are unchanged) and pass here. Full suite, ruff check, ruff format --check, mypy pass locally.
  • The corpus table above: both columns run with this branch and with main at 18bbad8.

Made with Claude Code.

🤖 Generated with Claude Code

patrickballard and others added 7 commits November 21, 2026 14:44
A uv.lock made with environments (supported-markers) leaves out the packages and wheels other platforms need, and uv sync fails there. wheelgap read it as complete and reported those platforms as source/missing: false gaps in 8 of 82 root uv.lock files of the 300 most-starred Python repos. A requested target outside the environments is now an error (as for a pip report made for another environment), and the built-in default platforms are narrowed to the ones the lock covers.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The entry for the PR, now that it has a number.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…e Python API; drop uncovered advisory targets

Review found that wheelgap diff, the Action's compare step, MCP diff_lockfiles and check_lockfile() with no targets failed outright on an environments-limited lock, and that an --advisory target outside the environments failed the run. Targets the user named stay an error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…latform; say what diff drops

Review found that wheelgap diff and MCP diff_lockfiles with a requirements file on one side dropped the platforms the uv.lock gave up instead of refusing them, and that the docs said diff keeps the platforms both locks cover when it drops only those both leave out.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	CHANGELOG.md
#	src/wheelgap/cli.py
…on below the lock's requires-python

With no targets the default Python is the running one; on 3.11 that is below the fixture's >=3.12, which wheelgap rechecks on PyPI as it always has.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant