Skip to content

fix(check): check PyPI packages when requirements use PyTorch --extra-index-url - #233

Merged
patrickballard merged 5 commits into
wheelgap:mainfrom
dev-burnern:fix/check-pytorch-extra-index
Nov 22, 2026
Merged

patrickballard merged 5 commits into
wheelgap:mainfrom
dev-burnern:fix/check-pytorch-extra-index

Conversation

@dev-burnern

Copy link
Copy Markdown
Contributor

Closes #219

What this changes

  • site/check/driver.py:
    • Adds a reviewed PUBLIC_EXTRA_INDEXES allowlist starting with download.pytorch.org (PyTorch Foundation), mapping to {"torch", "torchvision", "torchaudio"}.
    • Adds _public_extra_indexes(root, path) to inspect option lines in a requirements file and its fetched -r/-c includes: allows PyPI lookups only when every index option is a credential-free --extra-index-url on an allowlisted host and no sibling pyproject.toml/uv.toml configures an index. Any --index-url, --find-links, --no-index, unlisted host, URL with credentials, or unreadable line keeps the entire file private.
    • Marks packages served by the allowlisted extra index (torch, torchvision, torchaudio) as unknown with "reason": "may be installed from download.pytorch.org, which this page doesn't read" instead of querying PyPI, while checking all other packages on PyPI.
    • Returns "extra_indexes" (allowlisted hostnames only, never full URLs) in check()'s JSON output.
  • site/check/check.mjs:
    • Shows a warning alert for each entry in r.extra_indexes: <lockfile> also installs from <host> (--extra-index-url). This page checked PyPI only.
    • Updates the private-index alert advice to suggest uvx wheelgap <lockfile> in a checkout (checking PyPI's files) rather than misleadingly suggesting uvx wheelgap --index-url.
  • tests/test_check_driver.py & tests/site/check-page.test.mjs:
    • Covers PyTorch --extra-index-url (PyPI lookup + torch/torchvision unknown with reason), mixed --index-url (private), credentialed URL on listed host (private, URL never leaked in output), --extra-index-url in an included file, test_a_private_index_package_is_never_looked_up_on_pypi unchanged, and the new alert wording in renderVerdict().

AI tools used (if any): Antigravity (Gemini)

Checklist

  • pytest tests/test_check_driver.py -k "private or pytorch" passes
  • node --check site/check/check.mjs and node --test tests/site/check-page.test.mjs pass (13/13)

@patrickballard

Copy link
Copy Markdown
Contributor

Thanks, @dev-burnern! An allowlist that names who runs each host, plus hostnames only (never URLs) in the output, is the right shape for this, and the credential and --index-url cases fail closed as they should.

The review found a few inputs where the new option reader sees a line differently from pip and wheelgap 0.13.0, and where it does, private names would be sent to pypi.org. Because this changes what the checker keeps private, Patrick will take this one himself:

  • Attached and abbreviated options aren't caught. pip and wheelgap read -ihttps://corp/simple, -f./wheels, --index URL, --extra URL and --no-i as index options, but _public_extra_indexes() only matches exact flag names. With the PyTorch line present, the file is then treated as public.
  • The same goes for includes. An include like -rcorp.txt (no space) or --requirem corp.txt isn't followed, so an --index-url inside corp.txt is never seen.
  • A byte-order mark hides a first-line option. The file is read as utf-8, not utf-8-sig, unlike wheelgap.
  • The sibling pyproject.toml/uv.toml check can't fire in the browser, because the worker doesn't fetch those files (and dropOtherProjects() removes other pyprojects).
  • A row's reason isn't shown on the page. check.mjs never reads it, so torch gets a plain "unknown".

A likely direction is to reuse wheelgap's own sources helpers for the option lines and fail closed on anything else, but that's Patrick's call.

(Review assisted by Claude.)

patrickballard and others added 2 commits November 22, 2026 11:31
…osed

_public_extra_indexes() matched exact flag names, so lines pip and wheelgap 0.13.0 read as another index (-ihttps://corp, -f./wheels, --index URL, --extra URL, --no-i), includes it didn't follow (-rcorp.txt, --requirem corp.txt) and a first-line option behind a byte-order mark left the file public, and its names went to pypi.org. It now takes the lines sources._read_requirements() collects as index options (the file and its includes, utf-8-sig, pip's line joining and abbreviations) and accepts only a whole '--extra-index-url URL' line on a listed https host with a plain path; anything else, or any error, keeps the file private. Checked against pip 25.3's own requirements parser on the same files. The browser never fetches a uv.toml, pyproject.toml or pdm.toml beside the file, so plan() now lists them and the worker passes the list: one in the file's folder or above, or no list, keeps it private too. A row's reason is now its Fix text and is named in the alert, and the 'uvx wheelgap FILE checks PyPI's files' advice is kept to requirements files and pyproject.toml (the CLI skips a Pipfile.lock's or pixi.lock's pinned index too).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When GitHub truncates the tree, plan()'s configs can miss a root uv.toml or pyproject.toml, so an --extra-index-url file could be taken as public. The worker now passes null then, which the driver treats as uncertain and keeps the file private.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
patrickballard and others added 2 commits November 22, 2026 12:36
Resolved with wheelgap#235 as its reviewer set out. Main's CONFIG_NAMES, plan() configs (any case), configs_for, configsJson, fetchConfigs, dropOtherProjects(py, repo, keep) and the truncated-tree null replace wheelgap#233's own; worker.mjs is now main's. check() uses main's _reads_offline. _public_extra_hosts() now starts with _unread_configs(), since _private() returns before it reads source.pypi_only for a file taken as public and would otherwise skip wheelgap#235's fail-closed check; it still refuses any settings file listed beside or above the file, read or not; its docstring no longer says the browser doesn't fetch them. The reader-based advice moved into privateText()'s names-an-index branch, so unread or unknown settings keep their own text; renderTable's Fix text shows an unknown row's reason. Tests: main's harnesses taken, wheelgap#233's tests kept with the renderVerdict harness given privateText, privatePyprojectReason and cliCommand, plus driver tests that an extra-index file is never looked up when a nearby settings file couldn't be fetched, the list is unknown or a read one sits beside it, and privateText's reader cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a plain uvx wheelgap for withheld names

pip shlex-splits an option line and expands ${VAR} in it, but wheelgap 0.13.0's collector splits on whitespace. So -'i' URL, --"index-url" URL, --ext\\ra-index-url URL, --no-ind''ex and -${OPT} URL are index options to pip (checked with pip 25.3's own parser), but the collector misses them, and the PyTorch line beside one made the file public. Now any option line in the file or its includes with a quote, a backslash or a $ keeps it private. The 'uvx wheelgap FILE in a checkout checks them on PyPI's files' advice is gone too: wheelgap's CLI looks a requirements file's packages up on PyPI unless --index-url names another index, so following it would send the withheld names there. The names-an-index branch is main's --index-url sentence again, and the unread and unknown branches (wheelgap#235) now say to pass --index-url with the project's index, and why.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@patrickballard
patrickballard merged commit 760077a into wheelgap:main Nov 22, 2026
1 check passed
@patrickballard

Copy link
Copy Markdown
Contributor

Merged, thanks @dev-burnern! This one needed the most care, since a mistake here would send private package names to pypi.org. Before merging, we made the page refuse any option line it can't read exactly as pip does (quotes, backslashes, ${VAR}), and refuse when a settings file beside the file couldn't be read. We also kept the --index-url advice, since uvx wheelgap FILE on its own would look those names up on PyPI.

(Posted with help from 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: a requirements.txt with PyTorch's --extra-index-url ends in "No packages were checked"

2 participants