Repository navigation
tags: free-threaded ABI, distro baselines, pre-11 macOS, PyPy ABI (rstudio/package-manager#18766) - #29
Merged
Conversation
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
force-pushed
the
feat/18766-tags-gaps
branch
from
August 10, 2026 15:44
22d2571 to
6a8d1cf
Compare
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.
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the four
tags/gaps deferred from #18632, tracked in rstudio/package-manager#18766.Everything here was measured against
pypa/packaging26.2, not read out of the PEPs —tags/testdata/gen_goldens.pydrivespackaging.tagsdirectly 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.jsonis the output of a barepackaging.tags.sys_tags()— no arguments, no monkeypatching, no injected platform list, the same call pip makes — recorded with theTargetfields describing the machine it ran on. 1412 tags, byte-identical in order. Every other fixture drivespackagingwith 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 becomescp313-cp313t-<platform>, but the extra letter is not the interesting part: a free-threaded build does not acceptabi3wheels at all, because the GIL-enabled stable ABI is a different ABI rather than a superset. Upstream's_abi3_appliesis explicitly false when threading, and PEP 803'sabi3ttakes its place — in the target's own slot and across the whole descending stable-ABI walk down tocp32. Thecp313tfixture contains zero-abi3-tags and 420-abi3t-ones (12 interpreter versions,cp313down tocp32, across 35 platforms).Gated to CPython 3.13+, matching the floor
_cpython_abisputs on thetabiflag, and rejected outright for non-CPython implementations.2. Pre-11 macOS
macOS changed its version scheme at 11, and so does the walk:
macosx_10_15down tomacosx_10_4, and emits nothing below 10.4 — upstream's_mac_binary_formatsreturns an empty format list for x86_64 there, so the right output is no tag, not a baremacosx_10_3_x86_64.macosx_10_16(macOS 11's own back-compat spelling) down tomacosx_10_4, ranked below every 11+ tag. Full format list on x86_64;universal2alone 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.pyno longer filtersmacosx_10_*out ofmac_platforms()' output.One deliberate divergence from upstream: macOS 10.x is accepted for
x86_64only.packagingwould answer a 10.x arm64 request withmacosx_10_<n>_arm64tags, 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 newTarget.ImplMajor/ImplMinor— the implementation's version, distinct from the Python version (PyPy 7.3 on Python 3.10 ispypy310_pp73). These route through upstream'sgeneric_tagspath rather thancpython_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, notpp310-none-any(sys_tagssetsinterp = "pp3"for PyPy). There is noabi3tier;abi3is a CPython concept. UnsetImplMajor/ImplMinormeans "PyPy version unknown" and omits the implementation-ABI tier rather than fabricatingpypy310_pp00.Previously
"pp"was rejected byCompile, 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 aTarget's libc fields from a distribution name;BaselinesFor("manylinux_2_28_x86_64")answers the inverse, legacymanylinux1/2010/2014aliases 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.pyderives 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:
srcnamemust be exactlyglibc/musl. Repology also reportscompat-glibc(CentOS 6's 2.5 compat library) andglibc-doc-reference, whose version lags by a release — unfiltered, Ubuntu 26.04 came out as glibc 2.42 instead of 2.43.muslpackage, and the first version of this script recordedubuntu 22.04 musl 1.2, which would have claimed a glibc distro as a musllinux target. It also producedubuntu 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
BaselinesForusedb.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 lexicographicversionAtLeasthelper whose doc comment names the wrong spelling so it doesn't come back.BaselinesForreturned no glibc baselines for a lower-major floor likemanylinux_1_0_x86_64, when every recorded glibc 2.x satisfies>= 1.0.musllinuxTagsreturned nothing for a musl major other than 1 (a hardcodedmusllinuxMajor = 1). Upstream's_musllinux.platform_tagsuses the major it is given verbatim; the constant is gone.cpTagsgated the stable ABI onPyMajor == 3 && PyMinor >= 2, where upstream's_abi3_appliescompares tuples (>= (3, 2)) and does emitcp40-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
packaging26.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 onlylinux_x86_64and the cp40 target was missing its entireabi3tier. Reintroducing the original spelling insideversionAtLeastfails 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, nott.Runsubtests, as an earlier revision called them.) So the fix is covered, not merely present.manylinuxTagsnow mirrors upstream's cross-major walk. I initially kept a same-major walk, reasoning that copying upstream's_LAST_GLIBC_MINORplaceholder 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 acp40tspelling 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_28wheel 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 commitb71ab79's message, attributed these counts to_manylinux.platform_tags; that was wrong._linux_platforms()wraps it and appends the barelinux_<arch>, so the manylinux-only figures are one lower — given in the second column.)_linux_platforms()_manylinux.platform_tagsThe 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
manylinux2014alone); 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 nomanylinux_1_*, nomanylinux_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 = 50is 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, andNOTICEcites the walk and the placeholder pinned at6ce6143ac8eebd91b7b0d38e92618f0702e933af.One divergence found in the opposite direction (not changed here)
manylinuxFloorclaimed riscv64/loongarch64 are "architectures packaging's own manylinux support predates". That is stale: packaging 26.2 lists both in_ALLOWED_ARCHSand 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.BaselinesForvs tag generationNow documented with tests both ways:
BaselinesForanswers 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_aarch64andmanylinux_1_0_x86_64are reported by the former and not claimed by the latter. pip behaves like the latter, which is the point.Free-threaded
PyMajor == 3stays an exact-major check (RoboRev suggested a floor). It's a statement about what has been measured againstpackaging.tags, not a prediction about future Pythons — there is no Python 4, so there's no reference to check acp40tspelling 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 againstpackaging26.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_abisappends abiflags — pymallocmbelow Python 3.8, UCS-4ubelow 3.3 — so a cp37 target's exact ABI iscp37m, notcp37. Every real CPython 3.7 extension wheel on PyPI is taggedcp37-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-threadedtand 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 anmon 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 arepy_version < (3, 8)and< (3, 3).Py_UNICODE_SIZE, falling back tosys.maxunicode), not the requested version, so it answersufor 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 thecp27muvscp27msplit 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 keyinguoffTarget.OS), which is a decision I'd rather surface than make inside a review round. Recorded indoc.go's divergence list and atcpythonExactABI.Review follow-up: the riscv64/loongarch64 gap is bigger than I said
Two things my earlier note missed, both verified against 26.2:
legacy: nilindependently dropsmanylinux2014_<arch>._LEGACY_MANYLINUX_MAPis keyed by glibc version alone — arch-independent — so pip emitsmanylinux2014_riscv64. Fixing only the floor number would still not produce it.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 indoc.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_NarrowNonX86Floorspins the current narrower output so a future floor change is a deliberate test update. It's hand-written, not generated — a fixture frompackagingwould 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
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.LookupBaseline(...).Apply(t)snippet inCHANGELOG.mddidn'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 nonet/*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:
nonebefore the stable ABI (pure reordering, identical set)py, cp27 which predatesabi3)ppfixtures + unit testBaselinesFor's>=to>versionAtLeastTestBaselinesFor, 9 differential subtests,TestGolden,TestVersionAtLeastlastGlibcMinor(50 → 49)TestLinux_CrossGlibcMajorA 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) reports0 issues.withconfig verifyclean;gofmt -l .clean under Go 1.25.5, matching what CI pins, not the local 1.26.4.NOTICErecords the added upstream attribution. No files outsidetags/are touched apart fromCHANGELOG.mdandNOTICE.