Skip to content

Commit 4be275d

Browse files
committed
Ban macOS 11+ minor tags not supported by pip, packaging nor uv
See pypa/packaging.python.org#1933 When macOS switched to a versioning scheme incrementing the major version with macOS 11, packaging and subsequently pip and uv decided to only emit tags with the minor version 0 for macOS 11+ (since we don't know how many minors each version has). PyPI doesn't currently enforce this requirement, to the confusion of users who upload wheels that are ultimately not usuable (astral-sh/uv#16337). This PR bans uploads of those wheels, enforcing a minor version of 0 for macOS 11+. Matching implementations in pip and uv: https://github.com/pypa/packaging/blob/a85e63daecba56bbb829492624a844d306053504/src/packaging/tags.py#L452-L460 https://github.com/astral-sh/uv/blob/64bcd4e8a6ad629fa9ffc2922b4cc0cd57cb8dbe/crates/uv-platform-tags/src/tags.rs#L528-L538 (Pending DPO thread)
1 parent 691680f commit 4be275d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

tests/unit/forklift/test_legacy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2843,7 +2843,7 @@ def test_upload_attestation_fails_without_oidc_publisher(
28432843
"macosx_10_13_x86_64",
28442844
"macosx_11_0_x86_64",
28452845
"macosx_10_15_arm64",
2846-
"macosx_11_10_universal2",
2846+
"macosx_15_0_universal2",
28472847
"ios_13_0_arm64_iphoneos",
28482848
"ios_13_0_arm64_iphonesimulator",
28492849
"ios_13_0_x86_64_iphonesimulator",
@@ -3408,6 +3408,7 @@ def test_upload_fails_with_invalid_filename(
34083408
"linux_x86_64",
34093409
"linux_x86_64.win32",
34103410
"macosx_9_2_x86_64",
3411+
"macosx_11_2_arm64",
34113412
"macosx_16_2_arm64",
34123413
"macosx_10_15_amd64",
34133414
],

warehouse/forklift/legacy.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"linux_armv7l",
120120
}
121121
# macosx is a little more complicated:
122-
_macosx_platform_re = re.compile(r"macosx_(?P<major>\d+)_(\d+)_(?P<arch>.*)")
122+
_macosx_platform_re = re.compile(r"macosx_(?P<major>\d+)_(?P<minor>\d+)_(?P<arch>.*)")
123123
_macosx_arches = {
124124
"ppc",
125125
"ppc64",
@@ -133,8 +133,8 @@
133133
"universal",
134134
"universal2",
135135
}
136+
# macosx 10 is also supported, but with different rules
136137
_macosx_major_versions = {
137-
"10",
138138
"11",
139139
"12",
140140
"13",
@@ -178,9 +178,17 @@ def _valid_platform_tag(platform_tag):
178178
if platform_tag in _allowed_platforms:
179179
return True
180180
m = _macosx_platform_re.match(platform_tag)
181+
# https://github.com/pypa/packaging.python.org/issues/1933
182+
# There's two macosx formats: `macosx_10_{minor}` for the 10.x series where
183+
# only the minor version ever increased, and `macosx_{major}_0` for the
184+
# new release scheme where we don't know how many minor versions each
185+
# release has.
186+
if m and m.group("major") == "10" and m.group("arch") in _macosx_arches:
187+
return True
181188
if (
182189
m
183190
and m.group("major") in _macosx_major_versions
191+
and m.group("minor") == "0"
184192
and m.group("arch") in _macosx_arches
185193
):
186194
return True

0 commit comments

Comments
 (0)