Skip to content

Cross-check the scan against pip and publish the agreement rate - #48

Merged
patrickballard merged 3 commits into
mainfrom
pip-agreement
Nov 12, 2026
Merged

patrickballard merged 3 commits into
mainfrom
pip-agreement

Conversation

@patrickballard

@patrickballard patrickballard commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #19

Made with Claude Code.

What changed

  • scripts/check_pip.py: for the scan's top 200 (by rank) on 3.13 linux-x86_64, 3.13 linux-aarch64, 3.13 musl-aarch64 and 3.13 win-arm64, it asks pip what it would install of the version the scan checked: pip install --dry-run --ignore-installed --no-deps --only-binary=:all: --report … --python-version 3.13 --implementation cp --abi cp313 --platform … NAME==VERSION. A dry run picks a file the same way pip download does, but fetches only the wheel's metadata. It compares pip's answer with the scan's results, wheel against everything else.

    • "No wheel" needs positive evidence. pip prints "No matching distribution found" even when it can't reach PyPI. So pip runs with -vv, and "no wheel" counts only if the log has Fetched page https://pypi.org/simple/<name>/ and no Retrying ( or Could not fetch URL line. Anything else is an error.
    • Outages don't publish. If pip couldn't answer more than 5% of the cells (the scan's own 5% rule), nothing is written and the script exits 1, so the previous file stays. A crash exits 2.
    • pip is isolated. It runs with --isolated --no-cache-dir --disable-pip-version-check, every PIP_* variable is removed from its environment, and its only output is a small report in a temp folder deleted after each run.
    • Same wheelgap as the scan. The installed wheelgap must be the one recorded in coverage.json; otherwise the script exits 2. The tags come from its targets.py, using the glibc, musl and macOS baselines recorded with the scan.
  • data/agreement.json: schema, date, scan, wheelgap, pip, top, targets, packages, checks, matched, mismatches ({name, version, target, wheelgap, pip, file}), compiled ({packages, checks, matched} for the packages without a pure-Python wheel), skipped (cells the scan couldn't look up) and errors (cells pip couldn't answer). The README lists each field.

  • scan.yml: the cross-check is now its own job, pip-check, so it can't use up the scan job's 60 minutes or cause the scan to be cancelled before upload. It needs: scan, has contents: read, persist-credentials: false, continue-on-error, a 25-minute job timeout and a 15-minute step timeout. It downloads coverage.json from the data artifact, runs the check with the scan's $WHEELGAP and a pinned PIP: "pip==26.3", and uploads agreement.json as a separate agreement artifact, only if one was written.

    • The commit job runs whatever happened to pip-check (!cancelled() && needs.scan.result == 'success'). It downloads the agreement artifact if there is one. It commits the file only if it's a regular file and passes scripts/check_agreement.py, a stdlib-only check: 1 MB cap, valid JSON, exactly the expected keys, non-negative integer counts, short printable strings, one entry per mismatch, and at most 5% errors. Otherwise it warns and keeps the previous file. So the commit job still runs no third-party code, and only named files under data/ are added.
    • publish now checks needs.scan.result and needs.commit.result directly instead of !failure(). Otherwise a failed pip-check, an ancestor through commit, could block publishing.
  • Site: under the scan line it says, for example, "Cross-checked against pip on 2026-11-12, with wheelgap's own tag lists on both sides: they agree on 100% of 800 checks, and on 100% of the 144 for the 36 packages without a pure-Python wheel (the rest install everywhere). 0 skipped, 0 without an answer from pip. Details".

    • It's built only with textContent and createElement.
    • It's shown only when the counts are sane integers and date is YYYY-MM-DD and at most three days old.
    • Rates are rounded down, so a single mismatch never shows as 100%.
  • Tests, all offline:

    • test_check_pip.py:
      • the agreement maths, including the compiled counts and lookup errors being skipped;
      • the 5% refusal;
      • run_pip with a faked subprocess.run: a wheel, a real no-wheel, retry-then-no-match, Could not fetch URL, another project's page, a timeout, a non-zero exit with a wheel in the report, exit 0 without a wheel, exit 0 with two wheels, and PIP_* dropped;
      • wheelgap_tags with a stand-in wheelgap.targets (it keeps the libc versions and refuses pyodide);
      • an atomic write;
      • main's exit codes and the version refusal.
    • test_check_agreement.py: the validator.
    • test_site_agreement.py: renderAgreement in node with a stub DOM. It's skipped without node; the Check workflow has node.

    I checked that the main guards are covered by changing each one and seeing a test fail.

Where the tags come from

As the issue says, the platform tags come from wheelgap's targets.py, in the release that made the scan. So the tracker has no copy of the tag lists to drift, and both sides use wheelgap's lists, as the site says. This checks which wheels wheelgap finds in each release (abi3, per-Python and free-threaded builds, sdists), not the tag lists themselves. wheelgap's weekly accuracy check (wheelgap/wheelgap#252) covers those, deliberately with tags written out independently from AGENTS.md.

Known difference: pip is asked about NAME==VERSION, which lets it take a yanked wheel when nothing else fits (PEP 592). The scan looked the release up unpinned and skipped yanked files. A release whose only fitting wheel is yanked would therefore show up as a mismatch, with the file named.

Verification

  • A local default run against the committed coverage.json, with the scan's own wheelgap (0.7.0) and pip 26.3: 800 of 800 checks agree, and 144 of 144 for the 36 packages without a pure-Python wheel, with 0 mismatches, 0 skipped and 0 errors. It took 4 min 49 s with 8 workers, within the 15-minute step timeout; -vv makes pip slower than the first version's plain downloads (2 min 24 s). scripts/check_agreement.py accepts the file it wrote. With wheelgap 0.9.0 installed instead, the script refuses to run (exit 2).

  • With real pip, a dead HTTPS_PROXY and a 404 index both come out as errors, not "no wheel". The same classification code was checked on the wheelgap side.

  • uvx --python 3.14 [email protected] (189 passed), python3 scripts/check_notes.py and node --check site/app.js all pass.

For the maintainer

  • The issue asks to open a wheelgap issue for each kind of mismatch. None turned up, and per my instructions I filed nothing; the workflow doesn't file issues either.
  • The committed coverage.json still says wheelgap 0.7.0 while scan.yml pins 0.9.0. The nightly run regenerates coverage.json with $WHEELGAP before pip-check, so the versions match there. Locally, run it with --with wheelgap==<the scan's version>.

.github/ and scripts/ changed, so this gets the closer review.

🤖 Generated with Claude Code

patrickballard and others added 2 commits November 12, 2026 18:45
scripts/check_pip.py asks pip (`pip download NAME==VERSION --no-deps
--only-binary=:all:`) about the top 200 on four 3.13 targets, with the
platform tags from the scan's own wheelgap release, and writes
data/agreement.json. scan.yml runs it after the scan without ever
failing it, uploads the file and commits it by name; the site shows the
rate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for #48:
- pip prints "No matching distribution found" when it can't reach PyPI
  too, so "no wheel" now needs pip's -vv log to show the package's page
  was fetched, with no retry and no failed fetch. pip runs as
  `install --dry-run --report` (metadata only), isolated from pip.conf
  and PIP_* variables, pinned in scan.yml.
- Nothing is written (exit 1) when pip couldn't answer more than 5% of
  the cells; a crash exits 2; the installed wheelgap must be the scan's.
- The check is its own read-only job after the scan, so it can't use up
  the scan's time or fail it. The commit job takes its artifact only if
  there is one and scripts/check_agreement.py (stdlib) accepts it.
- agreement.json adds counts for packages without a pure-Python wheel;
  the site shows them, the skipped and error counts, and that both sides
  use wheelgap's tag lists, and hides the line after three days.
- Tests for run_pip with a faked subprocess.run, wheelgap_tags, main,
  write, the validator and the site line (node).

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.

Cross-check the scan against pip, and publish the agreement rate

1 participant