Skip to content

Commit a3934dc

Browse files
authored
fix(ci-lint): PKG-006 release-verify matches any component of a compound wheel platform_tag (#29)
Found in zackees/template-python-rust-cmd#30 (round 5, issue #6): a real, correctly cross-compiled manylinux_2_17 wheel was flagged "matches no declared [platforms] entry" because maturin filed it as `manylinux_2_17_aarch64.manylinux2014_aarch64` -- a PEP 425 compound platform_tag (both components describe the identical floor; manylinux2014 IS glibc 2.17). `_match_platform` matched the WHOLE compound string against one `^...$` pattern, which can never succeed. Splits `platform_tag` on "." and matches if any component matches, same convention wheel filenames already use for `python_tag`/`abi_tag` (e.g. `py2.py3`). Adds a regression test using the existing fixture.
1 parent 4a6870b commit a3934dc

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎ci_lint/release.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,23 @@ def discover_staged_artifacts(dist_dir: Path) -> StagedArtifacts:
115115

116116

117117
def _match_platform(wheel: StagedWheel, patterns: dict[str, re.Pattern[str]]) -> str | None:
118+
# PEP 425 (the wheel filename spec): `platform_tag` may itself be a
119+
# "."-joined list of tags the wheel is compatible with -- the SAME
120+
# convention `python_tag`/`abi_tag` use (e.g. `py2.py3`). maturin
121+
# emits exactly this for a Linux wheel whose measured glibc floor
122+
# equals one of the legacy manylinux1/2010/2014 aliases: a real,
123+
# correctly-built `manylinux_2_17_aarch64` wheel is filed as
124+
# `manylinux_2_17_aarch64.manylinux2014_aarch64` (both tags describe
125+
# the identical floor -- manylinux2014 IS glibc 2.17 -- found via a
126+
# live run, zackees/template-python-rust-cmd#30 round 5: linux-arm64
127+
# was flagged PKG-006 "matches no declared [platforms] entry" despite
128+
# being built through the correct manylinux_2_17 cross sysroot).
129+
# Matching the whole compound string against a single `^...$` pattern
130+
# can never succeed for one of these; each dot-separated component is
131+
# its own complete, independently valid tag, so a match on ANY one of
132+
# them is what "this wheel is compatible with platform X" means.
118133
for platform_id, pattern in patterns.items():
119-
if pattern.match(wheel.parts.platform_tag):
134+
if any(pattern.match(tag) for tag in wheel.parts.platform_tag.split(".")):
120135
return platform_id
121136
return None
122137

‎ci_lint/tests/test_release.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,26 @@ def test_green_set_has_no_pkg_006_findings(self) -> None:
9090
self.assertEqual("0.1.0", report.version)
9191
self.assertEqual(3, len(report.artifacts)) # 2 wheels + 1 sdist
9292

93+
def test_compound_platform_tag_matches_any_component(self) -> None:
94+
# PEP 425: `platform_tag` may be a "."-joined list of tags the
95+
# wheel is compatible with. maturin emits exactly this for a
96+
# Linux wheel whose measured glibc floor equals a legacy
97+
# manylinux1/2010/2014 alias -- e.g. a real, correctly-built
98+
# manylinux_2_17 wheel is filed as
99+
# `manylinux_2_17_x86_64.manylinux2014_x86_64` (both describe the
100+
# identical floor). Before this fix, `_match_platform`'s
101+
# `pattern.match(...)` against the WHOLE compound string could
102+
# never match a single `^...$` pattern -- found via a live run,
103+
# zackees/template-python-rust-cmd#30 round 5.
104+
_build_wheel(self.dist, platform_tag="manylinux_2_17_x86_64.manylinux2014_x86_64")
105+
_build_wheel(self.dist, platform_tag="win_amd64", cli_bytes=PE_X64)
106+
_write_sdist(self.dist)
107+
report = verify_staged_artifacts(
108+
self.ci, self.dist, candidate_sha=CANDIDATE_SHA, ci_toml_digest="deadbeef"
109+
)
110+
pkg006 = [f for f in report.findings if f.rule == "PKG-006"]
111+
self.assertEqual([], pkg006, [f.render() for f in pkg006])
112+
93113
def test_missing_platform_wheel_is_pkg_006(self) -> None:
94114
_build_wheel(self.dist, platform_tag="manylinux_2_17_x86_64")
95115
_write_sdist(self.dist) # windows-x64's wheel never staged

0 commit comments

Comments
 (0)