Skip to content

Repo checker: trim PyPI JSON before passing it to Pyodide - #216

Merged
patrickballard merged 2 commits into
wheelgap:mainfrom
benjibunbun:fix/206-trim-pypi-json
Nov 21, 2026
Merged

patrickballard merged 2 commits into
wheelgap:mainfrom
benjibunbun:fix/206-trim-pypi-json

Conversation

@benjibunbun

Copy link
Copy Markdown
Contributor

Closes #206.

Trim PyPI metadata immediately after parsing in both check() and fixes(), including the release maps retained between checks. The helpers preserve missing and malformed shapes so an invalid response still produces an unknown result.

Fields retained for the pinned wheelgap 0.13.0:

Field Reader
info.version pypi._fill_json_data; _newest_matching fallback
info.project_urls, info.home_page pypi._fill_json_data
File filename pypi._files, _fill_json_data, suggest._has_wheel
File requires_python pypi._supports_python, for checks and suggestions
File yanked _fill_json_data, _newest_matching, suggest._has_wheel

urls, releases and their version keys retain their structure. The helper comments flag the need to re-audit consumers when the pin changes.

For unpinned numpy, scipy, pandas and matplotlib, using the same responses saved on 2026-11-21, the string passed to driver.check() shrank from 10,858,768 to 1,392,913 UTF-8 bytes (87.17%). JavaScript string length: 10,858,685 → 1,392,913 code units. These captures use the actual worker functions under Node with stand-in fetch/driver boundaries. Replaying both payloads through the pinned Python driver gives identical complete check/fix results across 32 targets. Browser heap and mobile recovery were not measured; download size is unchanged.

Local verification on macOS:

  • Python suite: 563 passed, 2 expected module skips; pinned driver/parity suite: 80 passed, 6 existing skips (gapwheels is absent from 0.13.0).
  • Site tests: 146 passed. Note validation, JS syntax and diff checks passed.
  • New tests cover both fetch paths, cache reuse, malformed responses and trimmed/full check/fix and CLI parity for pins, ranges and bare names. Both worker regressions fail on the original implementation.

Hosted CI and a browser/Pyodide run remain untested.

Assisted by Codex.

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks @benjibunbun! This looks good overall: both fetch paths trim right after parsing, the release lists kept for fixes are the trimmed ones, and malformed or missing shapes are passed through untouched so a bad answer stays "unknown" rather than turning into a gap. Running the page's real trimmers from the driver and CLI parity tests, instead of a second Python copy, is a nice touch.

#206 is a help wanted issue and this is a larger change (about 550 lines with the recorded fixture), so Patrick will review and merge this one himself. One thing he'll look at is that the Python tests now start Node through subprocess. Nothing more needed from you for now.

(Review assisted by Claude.)

The page now trims PyPI's JSON to the fields wheelgap 0.13.0 reads. Only the new numpy case compared the CLI with the driver on trimmed answers, so a later wheelgap pin that reads another field (upload_time_iso_8601 for exclude-newer, say) could pass the parity test and still be wrong on the page. fetch_lookups() now trims with the worker's own trimProject, as the worker does, and the WHEELGAP pin in worker.mjs points at the trimmers.

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

Copy link
Copy Markdown
Contributor

Adding to the review above: we listed every field of PyPI's JSON that the pinned wheelgap 0.13.0 and the checker read, and the trim keeps exactly those, so no answer changes. A 200 answer without urls still ends as unknown.

We made two small changes:

  • The parity test now trims with the worker's own trimProject for every looked-up format, so a field dropped by mistake fails a test for requirements files, pyproject.toml, Pipfile.lock and pixi.lock, not only for the numpy case.
  • A comment at the wheelgap pin names the trimmers and the wheelgap functions to re-read when the pin moves.

It'll merge once a final review passes.

(Review assisted by Claude.)

@patrickballard
patrickballard merged commit 0345995 into wheelgap:main Nov 21, 2026
1 check passed
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @benjibunbun! The final review built its own list of every field the pinned wheelgap reads, from the 0.13.0 source, and it matches what the trim keeps. After the deploy the live checker gives the same answers as before on a requirements-only repo, a pyproject.toml-only repo and a uv.lock repo, with no console errors.

If you would like another, #207 is open and unclaimed: on a clean result, offer the README badge right under the green verdict.

(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: trim PyPI's project JSON to the fields the driver reads before it goes into Pyodide

2 participants