Skip to content

tags: free-threaded ABI, distro baselines, pre-11 macOS, PyPy ABI (rstudio/package-manager#18766) - #29

Merged
jonyoder merged 9 commits into
mainfrom
feat/18766-tags-gaps
Aug 10, 2026
Merged

jonyoder merged 9 commits into
mainfrom
feat/18766-tags-gaps

Conversation

@jonyoder

@jonyoder jonyoder commented Aug 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes the four tags/ gaps deferred from #18632, tracked in rstudio/package-manager#18766.

Everything here was measured against pypa/packaging 26.2, not read out of the PEPs — tags/testdata/gen_goldens.py drives packaging.tags directly and records the ordered tag list it produces. 14 new fixtures; 2 existing macOS fixtures grow. (Earlier revisions of this description said "six new"; that undercounted.)

One of the 14 is not like the others and is the only thing making this suite non-circular: host_sys_tags_control.json is the output of a bare packaging.tags.sys_tags() — no arguments, no monkeypatching, no injected platform list, the same call pip makes — recorded with the Target fields describing the machine it ran on. 1412 tags, byte-identical in order. Every other fixture drives packaging with explicit inputs, so a consistent misunderstanding on our side of how to call it would be baked into fixture and implementation alike and they would agree anyway. This one closes that loop. Credit for the idea goes to the independent review; regeneration is host-gated (CPython on macOS 11+/Windows) and skips harmlessly elsewhere, while the committed fixture makes the test host-independent.

1. PEP 703 free-threaded ABI

New Target.FreeThreaded. The exact ABI becomes cp313-cp313t-<platform>, but the extra letter is not the interesting part: a free-threaded build does not accept abi3 wheels at all, because the GIL-enabled stable ABI is a different ABI rather than a superset. Upstream's _abi3_applies is explicitly false when threading, and PEP 803's abi3t takes its place — in the target's own slot and across the whole descending stable-ABI walk down to cp32. The cp313t fixture contains zero -abi3- tags and 420 -abi3t- ones (12 interpreter versions, cp313 down to cp32, across 35 platforms).

Gated to CPython 3.13+, matching the floor _cpython_abis puts on the t abiflag, and rejected outright for non-CPython implementations.

2. Pre-11 macOS

macOS changed its version scheme at 11, and so does the walk:

  • A declared 10.x target walks the minor version, macosx_10_15 down to macosx_10_4, and emits nothing below 10.4 — upstream's _mac_binary_formats returns an empty format list for x86_64 there, so the right output is no tag, not a bare macosx_10_3_x86_64.
  • An 11+ target keeps its major walk and now also carries the pre-11 compatibility tail it always should have: macosx_10_16 (macOS 11's own back-compat spelling) down to macosx_10_4, ranked below every 11+ tag. Full format list on x86_64; universal2 alone elsewhere, since a single-architecture pre-11 binary cannot contain arm64 code but the x86_64 half of a universal2 binary can declare a pre-11 minimum.

gen_goldens.py no longer filters macosx_10_* out of mac_platforms()' output.

One deliberate divergence from upstream: macOS 10.x is accepted for x86_64 only. packaging would answer a 10.x arm64 request with macosx_10_<n>_arm64 tags, because it only ever describes the host it is running on. Apple silicon shipped with macOS 11, so as a declared target that combination can only be a mistake. This preserves the rejection the existing test already asserted.

3. PyPy / non-CPython ABI

Implementation: "pp" plus new Target.ImplMajor/ImplMinor — the implementation's version, distinct from the Python version (PyPy 7.3 on Python 3.10 is pypy310_pp73). These route through upstream's generic_tags path rather than cpython_tags.

The spelling that is easy to get subtly wrong, and is pinned by both a fixture and a unit test: the compatible tier's interpreter-any entry is the major-only pp3-none-any, not pp310-none-any (sys_tags sets interp = "pp3" for PyPy). There is no abi3 tier; abi3 is a CPython concept. Unset ImplMajor/ImplMinor means "PyPy version unknown" and omits the implementation-ABI tier rather than fabricating pypy310_pp00.

Previously "pp" was rejected by Compile, so this only widens what is accepted.

4. glibc → distro baseline table

Baseline, Baselines, LookupBaseline, BaselinesFor — layered over the >= comparison PEP 600/656 actually specify. LookupBaseline("almalinux", "8").Apply(t) fills a Target's libc fields from a distribution name; BaselinesFor("manylinux_2_28_x86_64") answers the inverse, legacy manylinux1/2010/2014 aliases included.

Provenance, because a hardcoded distro table with no stated source is exactly what a future maintainer cannot safely update. tags/data/gen_distro_baselines.py derives every version from Repology's project API (aggregating the distributions' own package repositories), and the emitted JSON repeats its source, regeneration command and caveats so they travel with the data. The division of labor is deliberate: upstream supplies the libc version (easy to get wrong, impossible to verify by eye); a reviewed constant in the script supplies the release list (a human can check it; it changes twice a year). The script fails loudly rather than guessing when a listed release has no upstream row or more than one candidate.

Two of the three filters were found by the data being wrong, not by reading docs:

  • srcname must be exactly glibc/musl. Repology also reports compat-glibc (CentOS 6's 2.5 compat library) and glibc-doc-reference, whose version lags by a release — unfiltered, Ubuntu 26.04 came out as glibc 2.42 instead of 2.43.
  • Releases are listed per libc. A distro's libc is not "whatever libc it packages": Debian, Ubuntu and Fedora all ship an optional musl package, and the first version of this script recorded ubuntu 22.04 musl 1.2, which would have claimed a glibc distro as a musllinux target. It also produced ubuntu 14.04 musl 0.9.

Rolling/pre-release repos are excluded — a libc version that still moves is not a baseline. RHEL is absent and deliberately not aliased to its rebuilds: it has no public repository to derive from, and silently answering a "rhel" lookup with AlmaLinux would put a distro name in the result the caller never asked about. The equivalence is documented instead.

Review follow-up: version floors are now compared as versions

RoboRev flagged that BaselinesFor used b.LibcMajor == major && b.LibcMinor >= minor — a same-major test, not a version comparison. Auditing the file for the pattern found two more, plus one place where the same shape is correct and stays. All three now route through one lexicographic versionAtLeast helper whose doc comment names the wrong spelling so it doesn't come back.

  • BaselinesFor returned no glibc baselines for a lower-major floor like manylinux_1_0_x86_64, when every recorded glibc 2.x satisfies >= 1.0.
  • musllinuxTags returned nothing for a musl major other than 1 (a hardcoded musllinuxMajor = 1). Upstream's _musllinux.platform_tags uses the major it is given verbatim; the constant is gone.
  • cpTags gated the stable ABI on PyMajor == 3 && PyMinor >= 2, where upstream's _abi3_applies compares tuples (>= (3, 2)) and does emit cp40-abi3-<plat>.

Not overstating the impact: no currently constructible input reaches any of them. glibc's major has been 2 since 1997, every musl release is 1.x, there is no Python 4 — each case needs a version that does not exist, and I could not construct a realistic tag that hits one. They're fixed because a floor that isn't a comparison is wrong on its face, and this is the class of latent defect that becomes reachable the moment a tag is built from parsed input rather than a fixed list.

Red-then-green, and both hypothetical cases are pinned by fixtures generated from packaging 26.2 (cp312_musl23_x86_64, cp40_glibc239_x86_64) rather than hand-written — so even the unreachable expectations are measured. Before the fix, the musl 2.3 target produced only linux_x86_64 and the cp40 target was missing its entire abi3 tier. Reintroducing the original spelling inside versionAtLeast fails 13 test functions — re-measured, because both my earlier list (4) and the review's correction (6) understated it: TestBaselinesFor, TestBaselinesFor_MatchesCompiledTarget, TestFreeThreaded_SubstitutesABI3T, TestGolden, TestHostSysTagsControl, TestLinux_ArchDependentFloor, TestLinux_BareLinuxRankedLast, TestLinux_CrossGlibcMajor, TestLinux_NarrowNonX86Floors, TestMacOS_ArchFormats, TestMacOS_PreElevenWalks, TestMatcher_RankPrefersMoreSpecific, TestVersionAtLeast. (TestBaselinesFor_MatchesCompiledTarget's nine cases are table rows, not t.Run subtests, as an earlier revision called them.) So the fix is covered, not merely present.

manylinuxTags now mirrors upstream's cross-major walk. I initially kept a same-major walk, reasoning that copying upstream's _LAST_GLIBC_MINOR placeholder would invent tags for glibc releases that don't exist. That was the wrong trade, and my own rule decides it the other way: upstream's algorithm is something to measure, unlike a cp40t spelling for which no reference answer exists.

The asymmetry settles it. A tag naming a nonexistent glibc is inert — no wheel carries it, so it matches nothing and costs only list length. A tag we fail to emit is a false negative: on a glibc 3.x host we'd decline a manylinux_2_28 wheel that pip on that same host installs. The consumer of this list is pip's own tag logic, so wider than pip is free; narrower means a server disagreeing with the client it serves.

Measured before implementing, via tags._linux_platforms() with glibc detection monkeypatched. (An earlier revision of this description, and commit b71ab79's message, attributed these counts to _manylinux.platform_tags; that was wrong. _linux_platforms() wraps it and appends the bare linux_<arch>, so the manylinux-only figures are one lower — given in the second column.)

target _linux_platforms() _manylinux.platform_tags
glibc 2.39 / x86_64 (real) 39 38
glibc 3.5 / x86_64 56 55
glibc 3.5 / aarch64 42 41
glibc 1.5 / x86_64 7 6
glibc 4.1 / x86_64 103 102

The implementation reproduces all five exactly. Two are golden fixtures (both archs, since the floor differs: x86_64 bottoms out at 2.5 with three legacy aliases, other arches at 2.17 with manylinux2014 alone); glibc 1.5 and below-the-floor are unit tests.

No real target changes. Upstream's older-major loop is range(current.major - 1, 1, -1) — empty at major 2, and glibc's major has been 2 since 1997. Every pre-existing glibc 2.x fixture regenerates byte-identically, and a test asserts a 2.39 target emits no manylinux_1_*, no manylinux_3_*, and nothing above its declared minor. The "unreasonably long list on a real target" escape hatch was checked and not triggered: 39 tags, unchanged.

lastGlibcMinor = 50 is upstream's placeholder, copied deliberately so their eventual correction is inherited rather than diverged from. Their own "guess what the highest minor version might be… update the dictionary with the actual value" comment is quoted at the constant, and NOTICE cites the walk and the placeholder pinned at 6ce6143ac8eebd91b7b0d38e92618f0702e933af.

One divergence found in the opposite direction (not changed here)

manylinuxFloor claimed riscv64/loongarch64 are "architectures packaging's own manylinux support predates". That is stale: packaging 26.2 lists both in _ALLOWED_ARCHS and floors every non-x86 arch at glibc 2.17, so our uv-sourced 2.31/2.36 floors are narrower than upstream on two real architectures — the same failure mode this PR just fixed for glibc majors, except reachable. Comment corrected and flagged; deliberately not changed as a drive-by, since it's inherited from #18632 and deserves its own decision.

BaselinesFor vs tag generation

Now documented with tests both ways: BaselinesFor answers the PEP 600 question ("is this release's libc new enough"), while tag generation additionally bounds the walk to the arch's manylinux series. They part ways at both ends — manylinux_2_12_aarch64 and manylinux_1_0_x86_64 are reported by the former and not claimed by the latter. pip behaves like the latter, which is the point.

Free-threaded PyMajor == 3 stays an exact-major check (RoboRev suggested a floor). It's a statement about what has been measured against packaging.tags, not a prediction about future Pythons — there is no Python 4, so there's no reference to check a cp40t spelling against, and the free-threaded ABI is exactly the kind of thing whose spelling is easy to get subtly wrong. Emitting tags this package has never validated against anything is worse than refusing an input nobody can produce. The reasoning is now a comment at the check.

Review follow-up: pre-3.8 CPython got the wrong exact ABI

An independent review built its own differential harness (not reusing gen_goldens.py) and compared 229 declared targets order-sensitively against packaging 26.2: 226 matched, and it found no ordering defect anywhere. So the earlier claim that this "reproduces upstream exactly" was too strong — there were three divergence classes, two documented and one not. The undocumented one was a real bug:

The exact ABI is not always cp<XY>. _cpython_abis appends abiflags — pymalloc m below Python 3.8, UCS-4 u below 3.3 — so a cp37 target's exact ABI is cp37m, not cp37. Every real CPython 3.7 extension wheel on PyPI is tagged cp37-cp37m, so a matcher built from this declined all of them and silently fell back to sdist. Affected: all 2.x and 3.0–3.7; 3.8+ was already right. It's pre-existing from #18632, but this PR edits that exact expression to add the free-threaded t and makes the conformance claim, so it belongs here.

Red-then-green with fixtures generated from 26.2 for cp27, cp32, cp37. The suite immediately caught a bug in my own fix: I first wrote PyMajor < 3 || PyMinor < 8, a bare minor check, which put an m on the cp40 target — the exact defect class from the previous round, caught by the cp40 fixture within seconds. It now uses the lexicographic helper, since upstream's gates are py_version < (3, 8) and < (3, 3).

⚠️ One part is only right for Linux, and I've documented rather than silently "fixed" it. Upstream derives the UCS-4 flag from the running interpreter (Py_UNICODE_SIZE, falling back to sys.maxunicode), not the requested version, so it answers u for any declared 2.x target regardless of OS. But UCS-4 was the Unix default while Windows and macOS CPython 2.x were UCS-2 — that's the cp27mu vs cp27m split on PyPI. This PR reproduces upstream, so a Windows or macOS 2.x target names an ABI no real wheel carries. Doing better means deliberately diverging from the reference (emitting both variants, or keying u off Target.OS), which is a decision I'd rather surface than make inside a review round. Recorded in doc.go's divergence list and at cpythonExactABI.

Review follow-up: the riscv64/loongarch64 gap is bigger than I said

Two things my earlier note missed, both verified against 26.2:

  • legacy: nil independently drops manylinux2014_<arch>. _LEGACY_MANYLINUX_MAP is keyed by glibc version alone — arch-independent — so pip emits manylinux2014_riscv64. Fixing only the floor number would still not produce it.
  • Below the floor we emit zero manylinux tags, not a shortened list. Measured, cp312, order-sensitive: loongarch64/glibc 2.35 → upstream 582, ours 42 (bare linux_ only), 540 missing. riscv64/glibc 2.28 → 393 vs 42. glibc 2.35 loongarch64 is a real configuration (Loongnix, Debian) that would be offered no manylinux wheel at all.

Floors left unchanged per the reachability call (PPM does not import tags/), but the documentation now carries this as a third bullet in doc.go's "Notable divergences" — where a consumer actually looks — with the magnitude and the legacy-map cause spelled out. doc.go's "otherwise matched tag for tag and in order" was contradicted by both findings and is rewritten: conformance is now stated as verified-by-fixture with the divergences enumerated, including the new UCS-4 one.

TestLinux_NarrowNonX86Floors pins the current narrower output so a future floor change is a deliberate test update. It's hand-written, not generated — a fixture from packaging would record the wider answer — and it carries the upstream counts plus a note telling anyone who widens the floors to add the legacy alias too.

Also in this round

  • The generator no longer "defensively" reorders the bare linux_<arch> tag last (gen_goldens.py). It was inert because upstream already does — and the day it stopped being inert would be the day upstream changed its ordering, which is precisely what these fixtures exist to detect. A generator that repairs its reference cannot measure it. Removing it changed no fixture, confirming it was inert.
  • The LookupBaseline(...).Apply(t) snippet in CHANGELOG.md didn't compile — it returns (Baseline, bool). Fixed, and expanded into a real code block.

Air-gap

The table is compiled in, never fetched. go list -deps ./tags/ contains no net/* package at all — the generator's network access is authoring-time only.

The null-result problem

Order is semantically load-bearing here (a resolver takes the first match), so "same set, different order" is a real defect. Rather than trust a passing comparison, the harness was checked for discrimination with five deliberate mutations, each reverted:

mutation caught by
emit none before the stable ABI (pure reordering, identical set) 15 of 20 golden fixtures; the 5 abstainers structurally cannot catch it, having no stable-ABI tier to reorder (3 PyPy, 1 pure-py, cp27 which predates abi3)
drop the PyPy minor from the ABI spelling both pp fixtures + unit test
move the pre-11 floor 10.4 → 10.5 5 fixtures + 2 unit tests
weaken BaselinesFor's >= to > differential, 7 of 9 tags
corrupt one row of the embedded JSON known-values test
reintroduce the same-major floor bug in versionAtLeast TestBaselinesFor, 9 differential subtests, TestGolden, TestVersionAtLeast
wrong lastGlibcMinor (50 → 49) both glibc-3.5 fixtures + TestLinux_CrossGlibcMajor

A membership-only comparison would have passed the first of those. The generator's own guard rail was also verified to fire (a bogus release exits 1 and writes nothing).

Both generators are reproducible: re-running them produces a byte-for-byte identical tree.

Verification

Run from the module root on this branch: go build ./..., go vet ./..., go test ./... all pass; golangci-lint run ./... (v2.11.2, CI config) reports 0 issues. with config verify clean; gofmt -l . clean under Go 1.25.5, matching what CI pins, not the local 1.26.4.

NOTICE records the added upstream attribution. No files outside tags/ are touched apart from CHANGELOG.md and NOTICE.

Closes three of the four gaps deferred from #18632, each measured against
pypa/packaging 26.2 via tags/testdata/gen_goldens.py rather than read out of
the PEPs. Six new golden fixtures; two existing macOS fixtures grow.

Free-threaded CPython (PEP 703). New Target.FreeThreaded selects the
"t"-suffixed ABI: cp313-cp313t-<plat> instead of cp313-cp313-<plat>. The
consequence that matters is not the extra letter, though. A free-threaded
build does NOT support abi3 -- packaging's _abi3_applies is explicitly false
when threading -- so the entire stable-ABI tier, including the descending walk
down to cp32, switches from abi3 to PEP 803's abi3t. Measured, not assumed:
the cp313t fixture contains zero "-abi3-" tags and 420 "-abi3t-" ones (12
interpreter versions, cp313 down to cp32, across 35 platforms). Gated to
CPython 3.13+, matching the floor _cpython_abis puts on the "t" abiflag.

Pre-11 macOS. macOS changed its version scheme at 11, and so does the walk. A
declared 10.x target walks the MINOR version (macosx_10_15 down to macosx_10_4,
below which _mac_binary_formats defines no x86_64 format at all, so nothing is
emitted rather than a bare macosx_10_3_x86_64). An 11+ target keeps its major
walk and now also carries the pre-11 compatibility tail it always should have:
macosx_10_16 (macOS 11's own back-compat spelling) down to macosx_10_4, with
the full format list on x86_64 and universal2 alone elsewhere, since a
single-architecture pre-11 binary cannot contain arm64 code but the x86_64 half
of a universal2 binary can declare a pre-11 minimum. gen_goldens.py no longer
filters macosx_10_* out of mac_platforms' output.

macOS 10.x is accepted for x86_64 only. Apple silicon shipped with macOS 11, so
a 10.x arm64 host has never existed; pypa/packaging would answer such a request
with macosx_10_<n>_arm64 tags because it only ever describes the host it runs
on, but this package describes declared targets, where the combination can only
be a mistake. This preserves the rejection the existing test already asserted.

PyPy. Implementation "pp" now routes through packaging's generic_tags path
rather than cpython_tags: pp310-pypy310_pp73-<plat> (new ImplMajor/ImplMinor
name the PyPy-side version, 7.3), then pp310-none-<plat>, then the compatible
tier -- whose interpreter-any entry is the MAJOR-only pp3-none-any, not
pp310-none-any, which is the spelling that is easy to get wrong and is pinned by
both a fixture and a unit test. There is no abi3 tier; abi3 is a CPython
concept. With no ImplMajor/ImplMinor the target simply has no
implementation-ABI tier instead of fabricating pypy310_pp00.

The golden harness was checked for discrimination rather than trusted. Three
deliberate mutations, each reverted: emitting "none" before the stable ABI (a
pure reordering, same set) failed 9 of 13 fixtures; dropping the PyPy minor
from the ABI spelling failed both pp fixtures; moving the pre-11 floor from
10.4 to 10.5 failed 5 fixtures and 2 unit tests. A membership-only comparison
would have passed the first of those.
Closes the fourth gap from #18766. Baseline/Baselines/LookupBaseline/BaselinesFor
map well-known Linux distribution releases to the libc version they ship, so a
caller who knows "we support RHEL 8 and newer" can get to glibc 2.28 without
looking it up by hand:

  base, _ := tags.LookupBaseline("almalinux", "8")
  m, _ := base.Apply(tags.Target{...}).Compile()

and BaselinesFor("manylinux_2_28_x86_64") answers the inverse -- which recorded
releases can run a wheel carrying that tag -- including the legacy manylinux1 /
2010 / 2014 aliases, resolved through the same arch-dependent alias table that
generates them.

The table is embedded, never fetched. tags' dependency graph contains no net/*
package at all, which is the property that matters for the air-gapped
deployments consuming this library.

PROVENANCE, because a hardcoded distro table with no stated source is precisely
what a future maintainer cannot safely update. data/gen_distro_baselines.py
derives every version number from Repology's project API, which aggregates the
distributions' own package repositories, and the emitted JSON repeats its
source, its regeneration command and its caveats so they travel with the data.
The division of labor is deliberate: upstream supplies the libc VERSION, the
part that is easy to get wrong and impossible to verify by eye, and a reviewed
constant in the script supplies the RELEASE LIST, the part a human can check and
that changes twice a year. The script fails loudly rather than guessing when a
listed release has no upstream row or has more than one candidate version.

Three filters were needed, and two of them were found by the data being wrong
rather than by reading docs:

  - srcname must be exactly glibc/musl. Repology also reports compat-glibc
    (CentOS 6's 2.5 compatibility library) and glibc-doc-reference, whose
    version lags the real library by a release. Unfiltered, Ubuntu 26.04 came
    out as glibc 2.42 instead of 2.43.
  - status must not be "legacy", which is Repology's marker for a superseded
    row still present in a repo.
  - releases are listed per libc. A distro's libc is NOT "whatever libc it
    packages": Debian, Ubuntu and Fedora all ship an optional musl package, and
    the first version of this script duly recorded "ubuntu 22.04 musl 1.2" --
    which would have claimed a glibc distro as a musllinux target. It also
    produced "ubuntu 14.04 musl 0.9".

Rolling and pre-release repos are excluded: Debian forky, Fedora rawhide,
openSUSE Tumbleweed, Alpine edge and in-progress Ubuntu interims all have a
libc version that still moves, and a moving version is not a baseline.

RHEL is absent, and deliberately not aliased to its rebuilds. It has no public
package repository to derive a version from; AlmaLinux N and Rocky Linux N are
1:1 rebuilds shipping the same glibc, but silently answering a "rhel" lookup
with one of them would put a distribution name in the result the caller never
asked about. The equivalence is documented instead.

TESTS. The convenience layer is checked against the thing it is a convenience
for: for every recorded glibc baseline and nine manylinux tags,
BaselinesFor's verdict must equal whether a Target built from that same baseline
actually accepts a wheel carrying the tag. That differential was verified to
discriminate -- weakening the comparison from >= to > fails it across seven of
the nine tags -- as was the known-values table, which catches a single corrupted
row in the embedded JSON. Two rows are additionally pinned against
manylinuxFloor's legacy aliases, since manylinux2010 and manylinux2014 are
DEFINED as the glibc of CentOS 6 and CentOS 7 and must not drift from it.

One documented divergence, with a test: BaselinesFor answers the PEP 600
question ("is this release's glibc new enough"), which is not the same as
whether an arch's manylinux series reaches back that far. A
manylinux_2_12_aarch64 wheel runs anywhere aarch64 glibc is >= 2.12, so CentOS 6
is a truthful answer, while an aarch64 Target claims no manylinux tag older than
2.17.
@jonyoder
jonyoder force-pushed the feat/18766-tags-gaps branch from 22d2571 to 6a8d1cf Compare August 10, 2026 15:44
Three (major, minor) floors in this package were spelled
"major == floor.major && minor >= floor.minor". That is not a version
comparison: it answers "below the floor" for every input whose major differs,
including every input ABOVE the floor. They now all route through one
lexicographic helper, versionAtLeast, whose doc comment names the wrong spelling
so it does not come back.

RoboRev reported the first of these on #29. Auditing the file for the pattern, as
asked, turned up two more -- and one case where the same shape is correct and
should stay.

  - BaselinesFor returned NO glibc baselines for a lower-major floor such as
    manylinux_1_0_x86_64, when every recorded glibc 2.x satisfies >= 1.0.
  - musllinuxTags returned no tags at all for a musl major other than 1. This
    was a hardcoded musllinuxMajor = 1; upstream's _musllinux.platform_tags
    simply uses the major it is given, yielding
    musllinux_{major}_{minor} down to _0. The constant is gone.
  - cpTags gated the stable ABI on "PyMajor == 3 && PyMinor >= 2", where
    upstream's _abi3_applies compares tuples (>= (3, 2)) and so DOES emit
    cp40-abi3-<plat> for a 4.0 target.

Not overstating this: no currently constructible input reaches any of them.
glibc's major has been 2 since 1997, every musl release is 1.x, and there is no
Python 4. Each case needs a version that does not exist, and I could not
construct a realistic tag that hits one. They are fixed because a floor that is
not a comparison is wrong on its face, and because this is exactly the class of
latent defect that becomes reachable the moment a tag is built from parsed input
rather than chosen from a fixed list.

Red first, then green. Both hypothetical cases are pinned by golden fixtures
GENERATED from pypa/packaging 26.2 (cp312_musl23_x86_64, cp40_glibc239_x86_64)
rather than hand-written, so even the unreachable expectations are measured
rather than reasoned about. Before the fix the musl 2.3 target produced only
linux_x86_64 and the cp40 target was missing its whole abi3 tier; both diffs are
in the fixtures' history. Reintroducing the original same-major spelling inside
versionAtLeast fails TestBaselinesFor, all nine subtests of
TestBaselinesFor_MatchesCompiledTarget, TestGolden and TestVersionAtLeast, so the
fix is covered rather than merely present.

manylinuxTags deliberately KEEPS the same-major behavior, and the reason is now
recorded there in full rather than left as an unexplained sibling. Matching
upstream across glibc majors requires _LAST_GLIBC_MINOR, a defaultdict returning
50 whose own upstream comment reads "guess what the highest minor version might
be, assume it will be 50 for testing. Once this actually happens, update the
dictionary with the actual value." Mirroring it would have this library
materialize up to ~50 tags per older major naming glibc releases that do not
exist, on the strength of a placeholder upstream flags as a guess. For a server
deciding which wheel to hand a client, a documented narrower answer beats a
confidently-invented wider one.

Also on review: the free-threaded PyMajor == 3 check stays an exact-major test,
with the reasoning made explicit. "3.13+" is a statement about what has been
measured against packaging.tags, not a prediction about future Pythons. There is
no Python 4, so there is no reference to check a cp40t spelling against, and the
free-threaded ABI is precisely the kind of thing whose spelling is easy to get
subtly wrong. Emitting tags this package has never validated against anything is
worse than refusing an input nobody can produce.
Reverses the one judgement call I flagged on #29. manylinuxTags kept a same-major
walk on the reasoning that copying upstream's _LAST_GLIBC_MINOR placeholder would
have us invent tags for glibc releases that do not exist. That was the wrong
trade, and my own stated rule -- widen where there is something to measure,
refuse where there is not -- decides it the other way: upstream's algorithm IS
something to measure, unlike a cp40t ABI spelling for which no reference answer
exists at all.

The asymmetry in consequences is what settles it. A tag naming a nonexistent
glibc is inert: no wheel is ever tagged with it, so it matches nothing and costs
only list length. A tag we fail to emit is a false negative -- on a glibc 3.x
host we would decline a manylinux_2_28 wheel that pip on that same host installs
happily. The consumer of this list is pip's own tag logic, so being wider than
pip is free while being narrower means a server disagreeing with the client it
serves. A library whose purpose is conformance should take the ecosystem's real
implementation as the reference rather than improve on it.

Measured first, then implemented. Probing packaging 26.2's
_manylinux.platform_tags with its glibc detection monkeypatched:

  glibc 2.39 x86_64   39 platform tags   <- real target
  glibc 3.5  x86_64   56
  glibc 3.5  aarch64  42
  glibc 1.5  x86_64    7
  glibc 4.1  x86_64  103

The implementation reproduces all five exactly. Two are now golden fixtures
generated from packaging (cp312_glibc35_x86_64, cp312_glibc35_aarch64 -- both
archs, because the floor differs: x86_64 bottoms out at 2.5 with all three legacy
aliases, every other arch at 2.17 with manylinux2014 alone). The glibc 1.5 and
below-the-arch-floor cases are pinned as unit tests.

NO REAL TARGET CHANGES. Upstream's older-major loop is
range(current.major - 1, 1, -1), which is empty for a major-2 target, and glibc's
major has been 2 since 1997. Every pre-existing glibc 2.x fixture regenerates
byte-identically, and TestLinux_CrossGlibcMajor asserts a 2.39 target emits no
manylinux_1_*, no manylinux_3_*, and nothing above its declared minor. The
escape hatch for "unreasonably long list on a real target" was checked and not
triggered: 39 tags, unchanged.

lastGlibcMinor = 50 is upstream's placeholder, copied deliberately rather than
replaced with a judgement of our own, so upstream's correction is inherited when
glibc 3 actually ships. Their own comment ("guess what the highest minor version
might be, assume it will be 50 for testing. Once this actually happens, update
the dictionary with the actual value") is quoted at the constant so the
provenance travels with the number, and NOTICE now cites
_manylinux.platform_tags' cross-major walk and the placeholder, pinned at
6ce6143ac8eebd91b7b0d38e92618f0702e933af (packaging 26.2).

Reintroducing a wrong placeholder (50 -> 49) fails both fixtures and
TestLinux_CrossGlibcMajor, so the new path is covered rather than merely present.

Two accuracy fixes found while in here, both comments rather than behavior:

  - versionAtLeast's doc said manylinuxTags deliberately avoids it because it
    wants a same-major test. That is now stale; it avoids it because it walks
    majors explicitly, so a single boolean floor is the wrong shape there.
  - manylinuxFloor claimed riscv64 and loongarch64 are "architectures
    packaging's own manylinux support predates". packaging 26.2 lists both in
    _ALLOWED_ARCHS and floors every non-x86 arch at 2.17, so our uv-sourced
    2.31/2.36 floors are NARROWER than upstream on two real architectures -- the
    opposite direction from this fix, and reachable, unlike the glibc-3 case.
    Comment corrected and the divergence flagged; deliberately not changed as a
    drive-by, since it is inherited from #18632 and deserves its own decision.

Also documented, with tests both ways: BaselinesFor answers the PEP 600 question
("is this release's libc new enough") while tag generation additionally bounds
the walk to the architecture's manylinux series, so they part ways at both ends
-- manylinux_2_12_aarch64 and manylinux_1_0_x86_64 are reported by the former and
not claimed by the latter. pip behaves like the latter, which is the point.
Comments only -- the diff contains no non-comment line. But a comment
describing the behavior a fix REMOVED is worse than no comment: a future
maintainer reading "yields nothing", observing tags, and "correcting" the code
would reintroduce exactly the narrower-than-pip false negatives the previous
commit removed, and the stale comment would vindicate them.

RoboRev caught one on #29; auditing both files for the same class found five
more, each verified against the code rather than taken on the audit's word.

  - manylinuxTags said "a declared version below its architecture's floor still
    yields nothing", which conflates the two cases the rewrite separated. Now
    spelled out: a version in the floor's OWN major but below its floor minor
    yields nothing (glibc 2.12 on aarch64), while a version in a LOWER major
    walks that major down to <major>_0 (glibc 1.5 on x86_64 emits
    manylinux_1_5..1_0). Plus a pointer for the reader who lands here because
    tags appeared where they expected none.

  - The same comment enumerated the floors as "2.5 on x86_64/i686, 2.17
    elsewhere". Its own table floors riscv64 at 2.31 and loongarch64 at 2.36.

  - The loongarch64 entry still read "pypa/packaging does not yet recognize this
    architecture at all", directly contradicting the retraction added 20 lines
    above it in the previous commit. The file asserted both halves.

  - generateTags' overview said the abi3 walk ends at "cp32-abi3-<plat>". The
    loop floors minor 2 within the target's OWN major, so a cp47 target ends at
    cp42; "cp32" was only true while the gate was PyMajor == 3.

  - linuxPlatformTags said both families walk "down to the architecture's
    floor". musllinux has no architecture floor at all, and cross-major
    manylinux bottoms out at <major>_0 outside the floor's major.

  - distro.go's BaselinesFor divergence note said "an x86_64 Target's series
    bottoms out at 2.5 and so does not claim manylinux_1_0_x86_64". True only
    for a glibc-2.x target now; qualified accordingly.

And one that was not stale but incomplete in a way that matters more than the
rest: versionAtLeast's doc said "use it for every (major, minor) floor in this
package" and named manylinuxTags as the sole non-caller. Target.validate's
free-threaded gate is also an exact-major test, deliberately -- it refuses an
unknown major rather than flooring it. A reader trusting that sentence would
have "fixed" it and changed behavior. Both exceptions are now listed with their
reasons, so "this one doesn't call the helper" is never on its own evidence of a
bug.
An independent differential over 229 declared targets found 226 matching and no
ordering defect, which means the "reproduces upstream exactly" claim in earlier
commit messages was too strong: there were three divergence classes, two
documented and one not. The undocumented one was a real bug.

THE BUG. The exact ABI is not always "cp<XY>". _cpython_abis appends abiflags --
pymalloc "m" below Python 3.8, UCS-4 "u" below 3.3 -- so a cp37 target's exact
ABI is cp37m. Every real CPython 3.7 extension wheel on PyPI is tagged
cp37-cp37m, so a matcher built from this declined all of them and fell back to an
sdist without saying so. All of 2.x and 3.0-3.7 were affected; 3.8+ was already
right. Pre-existing from #18632, but this commit's predecessor edits that exact
expression to add the free-threaded "t" and makes the conformance claim, so it
belongs here rather than in a follow-up.

Red first, with fixtures generated from packaging 26.2 for cp27, cp32 and cp37.
Worth recording: the suite caught a bug in the fix itself within seconds. I first
wrote the gates as "PyMajor < 3 || PyMinor < 8", a bare minor check, which put an
"m" on the cp40 target -- the identical defect class the previous commit
introduced versionAtLeast to eliminate, reproduced by me one commit later. The
cp40 fixture failed immediately. The gates now use versionAtLeast, matching
upstream's own tuple comparisons py_version < (3, 8) and < (3, 3).

⚠️ The UCS-4 half is only right for Linux, and is documented rather than
silently "fixed". Upstream derives that flag from the RUNNING interpreter
(Py_UNICODE_SIZE, falling back to sys.maxunicode), not from the requested
version, so it answers "u" for any declared 2.x target whatever OS the target
names. UCS-4 was the Unix default while Windows and macOS CPython 2.x were UCS-2
-- the cp27mu vs cp27m split on PyPI. This reproduces upstream, so a Windows or
macOS 2.x target names an ABI no real wheel carries. Doing better means
deliberately diverging from the reference, which is a decision to surface rather
than take unilaterally.

THE NON-CIRCULAR CONTROL, which is the best thing in the review and was missing
here. Every fixture in this package is generated by handing packaging explicit
platform and ABI lists, and the linux ones by monkeypatching its libc detection.
That exercises packaging's tag assembly but never its host detection -- so a
consistent misunderstanding of how to DRIVE packaging would be baked into fixture
and implementation alike, and they would agree. The suite would be
self-consistent and prove nothing.

host_sys_tags_control.json closes that loop exactly once: a bare
packaging.tags.sys_tags(), no arguments, nothing patched, the same call pip makes,
recorded with the Target fields describing the host it ran on. 1412 tags,
byte-identical in order. The fixture is committed so the test is
host-independent; only regeneration is host-gated (CPython on macOS 11+ or
Windows, since a linux host cannot report the libc version the Target needs) and
skips harmlessly elsewhere without touching the committed file.

RISCV64/LOONGARCH64, documented properly this time. My earlier note understated
it twice over. First, legacy: nil independently drops manylinux2014_<arch>:
_LEGACY_MANYLINUX_MAP is keyed by glibc version ALONE, so it is
architecture-independent and pip does emit manylinux2014_riscv64 -- correcting
only the floor number would still not produce it. Second, below its floor a
target emits ZERO manylinux tags rather than a shortened list, so the gap is not
marginal: measured for cp312 in order, loongarch64/glibc 2.35 gives upstream 582
tags against our 42, missing 540, and riscv64/glibc 2.28 gives 393 against 42.
glibc 2.35 loongarch64 is Loongnix and Debian, a real host that would be offered
no manylinux wheel whatsoever.

The floors stay as they are -- PPM does not import tags/, so this is latent --
but the documentation moves to where a consumer reads it: doc.go's "Notable
divergences" list, with the magnitude and the legacy-map cause. doc.go's
"otherwise matched tag for tag and in order" was contradicted by both findings
and is rewritten to state conformance as verified-by-fixture with the divergences
enumerated. TestLinux_NarrowNonX86Floors pins the current narrower output so a
floor change is a deliberate test update; it is hand-written rather than
generated, because a fixture from packaging would record the wider answer, and it
tells anyone who widens the floors to add the legacy alias too.

THE GENERATOR NO LONGER REPAIRS ITS REFERENCE. gen_goldens.py used to move the
bare linux_<arch> tag last "defensively", on the grounds that our design ranks it
there anyway. Upstream already emits it last, so the reorder was inert -- and the
day it stopped being inert would be the day upstream changed its ordering, which
is the one event these fixtures exist to detect. Removed; no fixture changed,
confirming it was inert.

Corrections to claims in earlier commit messages on this branch, since they are
part of the record:

  - "reproduces upstream exactly" -> 226 of 229 targets, three divergence
    classes, one of which this commit fixes.
  - b71ab79's glibc table (39/56/42/7/103) is attributed to
    _manylinux.platform_tags. Those are tags._linux_platforms(), which wraps it
    and appends the bare linux_<arch>; the manylinux-only counts are one lower
    (38/55/41/6/102). Substance right, function name wrong.
  - "9 of 13 fixtures" catch the stable-ABI reorder -> re-measured, 15 of 20; the
    5 abstainers have no stable-ABI tier to reorder (3 PyPy, 1 pure-py, and cp27,
    which predates abi3).
  - "six new golden fixtures" -> 14 added, 2 modified.
  - Reintroducing the versionAtLeast bug fails 13 test functions, not the 4 I
    listed; and TestBaselinesFor_MatchesCompiledTarget's nine cases are table
    rows, not t.Run subtests.

Also fixed: the LookupBaseline snippet in CHANGELOG.md did not compile, since it
returns (Baseline, bool).
…ered

Comments only; the diff contains no non-comment line. Records the decision to
keep upstream's UCS-4 behavior rather than diverge, and the reasoning behind it,
at both places a reader will look.

The three things the note now says plainly, where before it said the first two
only in passing and omitted the third:

(a) Upstream and this package answer different questions, and this one has no
    faithful answer available. packaging.tags asks what the RUNNING interpreter
    can install, so it reads Py_UNICODE_SIZE / sys.maxunicode. This package asks
    what a DECLARED target can install, and a declared 2.x target carries no
    Unicode width -- there is nothing to read. Reproducing upstream is therefore
    impossible in principle, every behavior is a choice, and this one is chosen:
    answer as upstream would.

(b) The consequence, concretely. UCS-4 was the Unix default while Windows and
    macOS CPython 2.x were UCS-2 -- the cp27mu vs cp27m split on PyPI -- so a
    Windows or macOS 2.x target names an ABI no real wheel carries and matches no
    CPython 2.x extension wheel at all.

(c) The likely fix if 2.x ever matters: emit BOTH variants and let ranking
    decide, NOT guess the width from Target.OS. Emitting both cannot miss a real
    wheel and the absent variant is inert; guessing from Target.OS is merely a
    better guess and still wrong for the UCS-2 Linux builds
    --enable-unicode=ucs2 could produce. Either choice gives up byte-identical
    conformance with the reference, which is this package's main safety net --
    the thing that caught a bad fix of mine one commit ago -- so the trade only
    pays once something reachable depends on it.

And why not now: Python 2 has been end-of-life since 2020 and is out of scope for
the native resolver this module serves, so the divergence would buy nothing
reachable. Written this way, whoever enables 2.x support inherits the analysis
instead of redoing it.
…s x64

The control fixture's Windows branch mapped only "AMD64", passing anything else
through raw. platform.machine() reports "ARM64" on Windows ARM64 while
Target.Compile() accepts only lowercase "arm64", so regenerating
host_sys_tags_control.json on a Windows ARM64 host produced an invalid target and
failed. Authoring-time only, and it fails loudly rather than writing a bad
fixture -- but the control fixture is the one thing making this package's golden
suite non-circular, so a regeneration path that works on only some hosts
undercuts exactly the property it exists to provide.

Audited all three branches rather than only the reported one, and the results
differ:

  - Windows: broken as described. "AMD64" mapped, "ARM64" and "x86" not.
  - macOS: passed platform.machine() through RAW. It happens to work, because
    macOS reports "arm64" and "x86_64" already lowercase -- correct by luck, not
    by design, and one Apple naming change from being wrong.
  - Linux: no such branch exists. The function returns early for any non-Darwin,
    non-Windows host, because sys_tags() does not report the glibc/musl version a
    linux Target needs. So there was nothing latent to fix there.

Replaced both call sites with one alias map plus a lowercase fallback, rather
than adding a second special case, so this cannot rot back into per-OS handling.
Verified against every string platform.machine() actually returns on a supported
host -- AMD64, ARM64, x86, X86, arm64, x86_64 -- each mapping to a value in
windowsArchs or macosArchs. Regenerating on this host reproduces
host_sys_tags_control.json byte-identically, so the fix is inert where it already
worked.
@jonyoder
jonyoder merged commit c4ebad6 into main Aug 10, 2026
2 checks passed
@jonyoder
jonyoder deleted the feat/18766-tags-gaps branch August 10, 2026 18:27
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.

1 participant