Skip to content

fix(availability): match PyPI versions in any PEP 440 spelling - #488

Merged
M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/availability-pypi-version-match
Nov 16, 2026
Merged

M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/availability-pypi-version-match

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

A lockfile names a PyPI version in its normalized form (uv writes 0.6rc11), the proxy's cached page as the files spell it (setuptools-0.6c11). The batch availability check compared strings, so it answered not_found for versions pip installs, and missed curation rules written against the file spelling (the page served to pip hides those files; the check said not_found, not held).

pkg/pyversion gains Canonical (PEP 440 normalized form, local label kept; matches packaging.utils.canonicalize_version on the test cases; fuzz target). pypisimple's release grouping uses it for PEP 440 versions, so minimum age and hosted uploads treat 1.0-1 / 1.0.post1 and 1.0alpha1 / 1.0a1 as one release, as pip and Warehouse do. A proxy hook (VersionKey, PyPI only) lets the batch look a version up in any spelling and have the gate judge the spelling the proxy serves.

Checked end to end against a PyPI proxy to pypi.org: setuptools 0.6rc11 is available (dated like 0.6c11), 0.6rc12 not_found, and a block rule on 0.6c* holds 0.6rc11 while the served page omits those files. Hosted members still match the stored spelling; left as a follow-up.

🤖 Generated with Claude Code

A lockfile names a PyPI version in its normalized form (uv writes 0.6rc11,
1.0.0rc1), while the proxy's cached project page lists it as the file names
spell it (setuptools-0.6c11, foo-1.0.0-rc1). The batch availability check
compared the two as strings, so POST /availability, check_dependencies and
oa check answered not_found for a version pip installs, and missed a curation
rule written against the file spelling: the page served to pip hides the
files, the check said not_found instead of held.

- pkg/pyversion: Canonical, the PEP 440 normalized form with trailing zeros
  dropped and the local label kept ("2.0+cpu" and "2.0+cu121" stay apart).
  It agrees with packaging.utils.canonicalize_version on the test cases;
  a fuzz target checks it is a fixed point that keeps the order.
- pypisimple.canonicalVersion uses it for PEP 440 versions (and keeps the
  old lenient rule for the rest), so the release grouping behind the
  minimum age, the single-version availability and the hosted upload's
  "one release per version" now treat 1.0-1 and 1.0.post1, or 1.0alpha1 and
  1.0a1, as one release, as pip and Warehouse do. It only ever was an
  in-memory key.
- proxy.Hooks.VersionKey (pypi: pypisimple.VersionKey) and
  proxy.VersionKey: the batch looks a queried version up by that key among
  the cached versions and has the gate judge the listed spelling, as the
  proxy does when it serves the files. Other formats compare as before.

Hosted PyPI members still match the stored spelling (version_key is the
version as uploaded); modern build tools write normalized versions, so that
is left for a follow-up.

Checked end to end against a PyPI proxy to pypi.org: setuptools 0.6rc11
from a uv.lock is available (dated 2009-10-20 like 0.6c11), 0.6rc12 is
not_found, and a block rule on "0.6c*" holds 0.6rc11 while the project page
the proxy serves to pip omits the 0.6c11 files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@M0Rf30
M0Rf30 merged commit 4efa7b3 into openartifact:main Nov 16, 2026
23 checks passed
M0Rf30 pushed a commit that referenced this pull request Nov 26, 2026
A pypi proxy matched a rule's version pattern against the version exactly as
the file name spells it, while pip reads many spellings as one version. A
block rule for 2.0.0 left the files spelled 2.0, 2.0.0.0, 02.0.0 and v2.0.0
on the project page and downloadable, and the local build 2.0.0+x, which
"==2.0.0" also selects (and prefers), as well.

curation.Set now matches a pypi version in more than one form: the spelling,
its lowercase (PEP 440 ignores case), its canonical form
(pyversion.Canonical) and, for a local version, the canonical public
version. A plain version pattern is put in canonical form when the set is
built, so it matches every spelling of the release and its local builds; a
local pattern ("2.0.0+cpu") that build only. A glob is lowercased and
matched against the spelling and the canonical form: "2.0.*" keeps
matching 2.0.0 and 2.0.5 through their spelling although the canonical form
drops trailing zeros, and does not cover a release spelled "2.0" (canonical
"2"); the docs say to add the plain rule for that. A block on any form
still beats an allow. Other formats compare versions as before.

Every path goes through Set.Evaluate (Gate.Hidden): the project page filter,
file downloads, and both availability checks. The single check
(explainProxy) now also takes the spelling from the cached project page, as
the batch does since #488, so a glob written against the file spelling
("0.6c*") holds the version a lockfile names ("0.6rc11") in both; before,
the batch said held and the single check available.

Tests: the spelling, local-version, glob and allowlist cases in curation (18
of them fail without the fix); the report reproduced through the pypi proxy
(page and downloads); the single and batch checks agreeing on 0.6rc11.

GHSA-8483-q77r-q9xm

Co-Authored-By: Claude Opus 5.5 <[email protected]>
M0Rf30 added a commit that referenced this pull request Nov 26, 2026
#525)

A pypi proxy matched a rule's version pattern against the version exactly as
the file name spells it, while pip reads many spellings as one version. A
block rule for 2.0.0 left the files spelled 2.0, 2.0.0.0, 02.0.0 and v2.0.0
on the project page and downloadable, and the local build 2.0.0+x, which
"==2.0.0" also selects (and prefers), as well.

curation.Set now matches a pypi version in more than one form: the spelling,
its lowercase (PEP 440 ignores case), its canonical form
(pyversion.Canonical) and, for a local version, the canonical public
version. A plain version pattern is put in canonical form when the set is
built, so it matches every spelling of the release and its local builds; a
local pattern ("2.0.0+cpu") that build only. A glob is lowercased and
matched against the spelling and the canonical form: "2.0.*" keeps
matching 2.0.0 and 2.0.5 through their spelling although the canonical form
drops trailing zeros, and does not cover a release spelled "2.0" (canonical
"2"); the docs say to add the plain rule for that. A block on any form
still beats an allow. Other formats compare versions as before.

Every path goes through Set.Evaluate (Gate.Hidden): the project page filter,
file downloads, and both availability checks. The single check
(explainProxy) now also takes the spelling from the cached project page, as
the batch does since #488, so a glob written against the file spelling
("0.6c*") holds the version a lockfile names ("0.6rc11") in both; before,
the batch said held and the single check available.

Tests: the spelling, local-version, glob and allowlist cases in curation (18
of them fail without the fix); the report reproduced through the pypi proxy
(page and downloads); the single and batch checks agreeing on 0.6rc11.

GHSA-8483-q77r-q9xm

Co-authored-by: Areef <[email protected]>
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.

2 participants