Skip to content

Commit 87efd2f

Browse files
committed
Add compatibility tag handling for iOS.
1 parent 111eed1 commit 87efd2f

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

src/pip/_internal/utils/compatibility_tags.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
interpreter_name,
1414
interpreter_version,
1515
mac_platforms,
16+
ios_platforms,
1617
)
1718

18-
_osx_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)")
19+
_apple_arch_pat = re.compile(r"(.+)_(\d+)_(\d+)_(.+)")
1920

2021

2122
def version_info_to_nodot(version_info: Tuple[int, ...]) -> str:
@@ -24,7 +25,7 @@ def version_info_to_nodot(version_info: Tuple[int, ...]) -> str:
2425

2526

2627
def _mac_platforms(arch: str) -> List[str]:
27-
match = _osx_arch_pat.match(arch)
28+
match = _apple_arch_pat.match(arch)
2829
if match:
2930
name, major, minor, actual_arch = match.groups()
3031
mac_version = (int(major), int(minor))
@@ -43,6 +44,26 @@ def _mac_platforms(arch: str) -> List[str]:
4344
return arches
4445

4546

47+
def _ios_platforms(arch: str) -> List[str]:
48+
match = _apple_arch_pat.match(arch)
49+
if match:
50+
name, major, minor, actual_multiarch = match.groups()
51+
ios_version = (int(major), int(minor))
52+
arches = [
53+
# Since we have always only checked that the platform starts
54+
# with "ios", for backwards-compatibility we extract the
55+
# actual prefix provided by the user in case they provided
56+
# something like "ioscustom_". It may be good to remove
57+
# this as undocumented or deprecate it in the future.
58+
"{}_{}".format(name, arch[len("ios_") :])
59+
for arch in ios_platforms(ios_version, actual_multiarch)
60+
]
61+
else:
62+
# arch pattern didn't match (?!)
63+
arches = [arch]
64+
return arches
65+
66+
4667
def _custom_manylinux_platforms(arch: str) -> List[str]:
4768
arches = [arch]
4869
arch_prefix, arch_sep, arch_suffix = arch.partition("_")
@@ -68,6 +89,8 @@ def _get_custom_platforms(arch: str) -> List[str]:
6889
arch_prefix, arch_sep, arch_suffix = arch.partition("_")
6990
if arch.startswith("macosx"):
7091
arches = _mac_platforms(arch)
92+
elif arch.startswith("ios"):
93+
arches = _ios_platforms(arch)
7194
elif arch_prefix in ["manylinux2014", "manylinux2010"]:
7295
arches = _custom_manylinux_platforms(arch)
7396
else:

tests/unit/test_models_wheel.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,28 @@ def test_not_supported_multiarch_darwin(self) -> None:
148148
assert not w.supported(tags=intel)
149149
assert not w.supported(tags=universal)
150150

151+
def test_supported_ios_version(self) -> None:
152+
"""
153+
Wheels build for iOS 12.3 are supported on iOS 15.1
154+
"""
155+
tags = compatibility_tags.get_supported(
156+
"313", platforms=["ios_15_1_arm64_iphoneos"], impl="cp"
157+
)
158+
w = Wheel("simple-0.1-cp313-none-ios_12_3_arm64_iphoneos.whl")
159+
assert w.supported(tags=tags)
160+
w = Wheel("simple-0.1-cp313-none-ios_15_1_arm64_iphoneos.whl")
161+
assert w.supported(tags=tags)
162+
163+
def test_not_supported_ios_version(self) -> None:
164+
"""
165+
Wheels built for macOS 15.1 are not supported on 12.3
166+
"""
167+
tags = compatibility_tags.get_supported(
168+
"313", platforms=["ios_12_3_arm64_iphoneos"], impl="cp"
169+
)
170+
w = Wheel("simple-0.1-cp313-none-ios_15_1_arm64_iphoneos.whl")
171+
assert not w.supported(tags=tags)
172+
151173
def test_support_index_min(self) -> None:
152174
"""
153175
Test results from `support_index_min`

0 commit comments

Comments
 (0)