Skip to content

Repo checker: check requirements files, pyproject.toml and Pipfile.lock by looking packages up on PyPI from the browser - #195

Merged
patrickballard merged 4 commits into
wheelgap:mainfrom
bfs2021:fix/checker-pypi-lookups
Nov 20, 2026
Merged

patrickballard merged 4 commits into
wheelgap:mainfrom
bfs2021:fix/checker-pypi-lookups

Conversation

@bfs2021

@bfs2021 bfs2021 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Problem

The repo checker only checked lockfiles that list every package's files (OFFLINE in site/check/driver.py). A repo with only a requirements.txt, requirements.lock, Pipfile.lock or pixi.lock got "needs PyPI lookups … Run uvx wheelgap in a checkout instead", and a repo with only a pyproject.toml got "No lockfile found" — turned away before seeing a single gap (issue #186).

Root cause

driver.plan() only listed wheelgap's LOCKFILES, driver.check() refused anything not in OFFLINE, and the page's runCheck() short-circuited every non-offline lockfile to needsIndex(). The worker already fetches https://pypi.org/pypi/<name>/json for --suggest's fixes, and pypi.org is already in the page's connect-src — what was missing was a driver step that names the lookups and one that fills packages from the fetched JSON.

Fix

  • driver.plan() also lists pyproject.toml files, after the lockfiles in the same folder (a uv.lock next to one is still picked first), still capped at MAX_LOCKFILES.
  • New driver.needs(root, path): loads the file with sources.load_file() and returns the lookups pypi.fill() would make — each package that isn't skipped and has no files (or has partial_files), with its canonical name and pinned version or null, only names pypi.may_look_up(p.registry, None) allows. A package from another index (a requirements file's --index-url, a Pipfile.lock source) is marked skip = "private index" and never reaches pypi.org, as the CLI does.
  • Requirements includes (-r, -c): a missing include comes back from needs() as an error naming it (kind: "include"), and worker.mjs fetches it from the same repo and ref (at most 10 round trips) and retries.
  • worker.mjs fetches https://pypi.org/pypi/<name>/<version>/json for a pinned package and .../<name>/json for a range, 6 at a time, capped at 300; the project JSON lands in the releases cache, which fixes() now reads .releases out of.
  • driver.check(root, lockfile, options, lookups) for these inputs fills each package the way pypi.fill() does (pypi._resolve_pythons(pkg, pythons, lambda p, py: pypi._fill_json_data(p, data, py, base), python), so a range resolves per Python) and builds its rows from api.check([source], targets) — api._check_lockfile refuses a pyproject.toml without deps=True, so this path can't go through it. A package with no answer is an error, so it shows as unknown, never as a gap. The result keeps the same JSON shape as before, so the table, the fixes and the prompt need no new code.
  • Page copy: noLockfile() and needsIndex() now describe what's left (no checkable file at all; an offline lock that doesn't list every package's files), the lockfile picker labels lookups files "(looks packages up on PyPI)", and a requirements file or pyproject.toml result carries an alert that it was checked for its direct requirements, as uvx wheelgap requirements.txt does, with --deps for the whole tree. A lockfile that lists its files makes the same requests as today: none to PyPI before the fixes (a needs() on a uv.lock comes back empty).

Not in this issue: --deps (the whole tree) and PEP 723 scripts.

Testing

uvx --python 3.14 --with "wheelgap==0.13.0" is the CI pin; locally CPython with wheelgap==0.13.0 installed:

  • python -m pytest tests/test_check_driver.py: 20 passed. New tests (per the issue's list) feed needs() and check() canned PyPI JSON for: a pinned package, a range that resolves to different releases on two Pythons, a 404 (unknown, never a gap), a private-index package (needs() doesn't list it; check() reports it skipped), a -r include (named as kind: "include" when missing, then works once fetched), a pyproject.toml (its own project skipped), and a Pipfile.lock; plus plan() ordering, a uv.lock needing no lookups, and fixes() reading the same releases mapping.
  • python -m pytest -q (whole suite): 531 passed, 229 subtests passed, 4 failed — all 4 in tests/test_bundled.py, which fail identically on main (399a2e7) before this change, so they're pre-existing.
  • Browser end-to-end (Pyodide, Network tab) not run here; the driver tests cover the wheelgap-side behavior and the worker only adds the fetches described above.

Fixes #186

…ck by looking packages up on PyPI from the browser

Fixes wheelgap#186.
@bfs2021
bfs2021 force-pushed the fix/checker-pypi-lookups branch from e37faf3 to 090bee5 Compare November 20, 2026 21:39
@bfs2021

bfs2021 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (which now includes #193 and #194) after the PR went CONFLICTING: the checker files overlap #193's gap-wheel work. The merge keeps both — the offline path passes check_rows from _check_lockfile to the new gap_wheels() support, and the online-lookups path supplies the same rows from api.check(). Tests re-run after the rebase: tests/test_check_driver.py 20 passed (+ #193's 6 gap-wheel cases skipped locally via importorskip, they run in CI), full suite 536 passed + 229 subtests with the same 4 test_bundled.py failures as clean main.

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks @bfs2021, this is a big step for the repo checker: requirements files, pyproject.toml and Pipfile.lock can now get an answer in the browser instead of a "run it locally" message. Keeping the private-index packages away from pypi.org, and showing a package with no answer as unknown rather than a gap, are both the right calls.

It looks good overall. Because #186 is a help wanted issue, Patrick will review and merge this one himself. One thing he'll want to look at: driver.py calls private wheelgap helpers (pypi._resolve_pythons, pypi._fill_json_data), which could break when the checker's wheelgap pin is bumped for a release.

(Review assisted by Claude.)

… Pythons, a pixi.lock and a pyproject.toml

Found reviewing wheelgap#195, each against wheelgap 0.13.0 on the same input:

- The page's Pythons went to the per-Python resolution as written (3.14t). Requires-Python is compared with a version and 3.14t isn't one, so with only free-threaded Pythons picked every pinned package with a Requires-Python read as can't install (a false gap), and with 3.13 + 3.14t as unknown. They're now the targets' major.minor, as the CLI passes them.
- A pixi.lock never says its input is PyPI-only, so every one of its packages was skipped as a private index and the page showed no gaps. It's placed package by package, as the CLI does; a requirements file, pyproject.toml or Pipfile.lock that names another index is still left off pypi.org as a whole.
- A pyproject.toml's requires-python made targets outside it uncounted, with the uv.lock message about re-locking. PyPI has every Python's files and the CLI checks those targets anyway.
- A requirement no target installs (its marker) was counted as a package; rows now go through the same r.needed filter as api._check_lockfile.
- Rows are marked for a fix lookup by origin.known_pypi in both paths, so a pixi.lock's gaps are not looked up, as with --suggest.
- needs() asks for nothing for a lockfile that is read offline, lists each lookup once, and gives an include outside the repo no path to fetch.
- The result says which skipped packages were left off pypi.org (private) and whether the files came from PyPI (looked_up), for the page's messages.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@bfs2021

bfs2021 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review digest. Acknowledged on the private helpers: the two calls at site/check/driver.py:234 mirror pypi.fill()'s inner loop, just fed browser-fetched JSON instead of HTTP responses, so a pin bump that renames them would break the lookup path. If you'd like, I can follow up in a separate PR — either promoting the two helpers to public API in wheelgap, or wrapping the call so a signature drift marks the affected packages unknown instead of raising. Leaving this PR as-is for now so it stays reviewable.

…result with nothing checked

Found reviewing wheelgap#195:

- The worker kept a pinned release's JSON in the cache fixes() reads. That JSON has no release list, and its name being cached stopped fixes() from fetching one, so every gap of a pinned requirements file, Pipfile.lock or pixi.lock stayed "not looked up". Only a project's JSON (a range's lookup) is kept now, as its release list.
- pickLockfile still preferred a lockfile that lists its files, so a uv.lock in a subfolder outranked the root's requirements.txt, and the folder a URL named lost to a lockfile elsewhere. Every listed file can be checked now, so it's plan()'s order: the file wheelgap would pick.
- A pyproject.toml is listed without knowing whether it has [project] dependencies. One the page picked itself that wheelgap can't read (tool settings only) gives way to the repo's next file, with the reason under What was read, instead of ending on an error with no picker. An unreadable file comes back from the driver's check as a result rather than as a worker failure, so this works for looked-up files too.
- With every package skipped (a requirements file with --extra-index-url, say) the verdict read "All 0 packages have a wheel" in green over all-wheels bars. It now says no packages were checked, shows no bars or table, and an alert names the packages left off pypi.org and why.
- The stale-check guard sat before the lookups, so a check superseded while it looked packages up still reached the driver's check, whose targets fixes() reads. It's now checked before every read, the remaining requests of a superseded check aren't made, and the driver is always handed JSON text, never a JS null.
- A pyproject.toml fetched to be checked is removed before another file is read: wheelgap reads the one beside a uv.lock for [tool.uv] settings, so a uv.lock checked after it could answer differently from the same uv.lock checked first.
- The page's caveat and lede no longer say every check reads a lockfile's own files.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@patrickballard

Copy link
Copy Markdown
Contributor

Adding to the review above: we read the change in full against uvx wheelgap==0.13.0 and made these changes so it can go in.

  • Free-threaded Pythons (3.14t) now resolve the way the CLI does. Before, pinned packages could show as "can't install" there.
  • A pixi.lock is now actually checked (every package was being skipped), and a pyproject.toml is checked on the Pythons picked even outside its requires-python, as uvx wheelgap pyproject.toml does.
  • Fix suggestions now show for pinned requirements files. The release-list cache was being filled with a pinned release's JSON, which has no release list.
  • The page picks the file wheelgap would (a root requirements.txt before a lockfile in a subfolder) and moves on from a pyproject.toml with no [project] dependencies.
  • When every package is kept off pypi.org (an --extra-index-url line, say), the page says nothing was checked and why, not a green "All 0 packages".
  • A check superseded mid-lookup stops making requests and can't overwrite the newer result.
  • New tests cover the worker, the pick order and each driver case above.

On the private helpers: the driver tests run against the pinned wheelgap in CI, so a pin bump that breaks them fails there before it reaches the site. No follow-up needed for that.

It'll merge once a final review passes.

(Review assisted by Claude.)

…gap or a pass

Found in the second review of wheelgap#195:

- A 200 answer with no `urls` list (not PyPI's JSON) read as a release with no files, so a pinned or bare requirement showed as "can't install". It's unknown now, like any other lookup with no answer.
- A platform's tile showed a ✓ over "N unknown" when no package was known to lack a wheel, so with pypi.org unreachable every tile read as a pass. It shows a ? there; a ✓ only when every package was checked.
- The page said packages couldn't be checked, but not why. The worker now counts the lookups over the 300 cap, the ones PyPI doesn't have and the ones that failed, and the page says so.
- A lookup that stalls is given up on after 30 seconds and counts as failed, so one request can't hold the check.
- Removing a pyproject.toml that's already gone from the worker's files is no longer an error on every later check.
- A pyproject.toml the page picked itself that lists no dependencies gives way to the repo's next file, as an unreadable one does. The driver's result counts the packages the file lists, so one whose packages are only skipped, or not installed on the targets picked, still stands.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@patrickballard
patrickballard merged commit 18f121e into wheelgap:main Nov 20, 2026
1 check passed
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @bfs2021! The repo checker now answers for requirements files, pyproject.toml, Pipfile.lock and pixi.lock, where it used to send people to the command line. It is live, and on wagtail/bakerydemo and scikit-learn it gives the same answer as uvx wheelgap.

The final review added one more commit before merging:

  • If PyPI's answer for a package is not its usual JSON, the package shows as unknown. Before, it could show as "can't install".
  • A platform tile shows a ✓ only when every package was checked. If some could not be, it shows "?" with the count, so an unreachable pypi.org no longer looks like a pass.
  • The page says why packages are unknown: beyond the 300 lookups it makes for one file, lookups that failed or timed out (30 seconds each), or names PyPI does not have.
  • A pyproject.toml the page picked itself that lists no dependencies gives way to the repo's next file.

If you would like another, #189 is open and unclaimed, and it follows on from this: a test that the checker's answer matches uvx wheelgap for every format it reads.

(Reply assisted by Claude.)

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.

Repo checker: check requirements files, pyproject.toml and Pipfile.lock too, looking packages up on PyPI from the browser

2 participants