Skip to content

Commit ec137f3

Browse files
committed
Update packaging patch to reflect changes from code review.
1 parent 753742b commit ec137f3

File tree

2 files changed

+55
-45
lines changed

2 files changed

+55
-45
lines changed

src/pip/_vendor/packaging/tags.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -509,30 +509,35 @@ def ios_platforms(
509509

510510
ios_platform_template = "ios_{major}_{minor}_{multiarch}"
511511

512-
# Consider any major.minor version from iOS 12.0 to the version prior to the
513-
# version requested by platform. 12.0 is the first iOS version that is known
514-
# to have enough features to support CPython. Consider every possible minor
515-
# release up to X.9. There highest the minor has ever gone is 8 (14.8 and
516-
# 15.8) but having some extra candidates that won't ever match doesn't
517-
# really hurt, and it saves us from having to keep an explicit list of known
518-
# iOS versions in the code.
519-
for major in range(12, version[0]):
520-
for minor in range(0, 10):
521-
yield ios_platform_template.format(
522-
major=major, minor=minor, multiarch=multiarch
523-
)
512+
# Consider any iOS major.minor version from the version requested, down to
513+
# 12.0. 12.0 is the first iOS version that is known to have enough features
514+
# to support CPython. Consider every possible minor release up to X.9. There
515+
# highest the minor has ever gone is 8 (14.8 and 15.8) but having some extra
516+
# candidates that won't ever match doesn't really hurt, and it saves us from
517+
# having to keep an explicit list of known iOS versions in the code. Return
518+
# the results descending order of version number.
519+
520+
# If the requested major version is less than 12, there won't be any matches.
521+
if version[0] < 12:
522+
return
523+
524+
# Consider the actual X.Y version that was requested.
525+
yield ios_platform_template.format(
526+
major=version[0], minor=version[1], multiarch=multiarch
527+
)
524528

525529
# Consider every minor version from X.0 to the minor version prior to the
526530
# version requested by the platform.
527-
for minor in range(0, version[1]):
531+
for minor in range(version[1] - 1, -1, -1):
528532
yield ios_platform_template.format(
529533
major=version[0], minor=minor, multiarch=multiarch
530534
)
531535

532-
# Consider the actual X.Y version that was requested.
533-
yield ios_platform_template.format(
534-
major=version[0], minor=version[1], multiarch=multiarch
535-
)
536+
for major in range(version[0] - 1, 11, -1):
537+
for minor in range(9, -1, -1):
538+
yield ios_platform_template.format(
539+
major=major, minor=minor, multiarch=multiarch
540+
)
536541

537542

538543
def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:

tools/vendoring/patches/packaging.patch

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
diff --git a/src/pip/_vendor/packaging/tags.py b/src/pip/_vendor/packaging/tags.py
2-
index 6667d2990..bcc6ea041 100644
2+
index 6667d2990..cb11c60b8 100644
33
--- a/src/pip/_vendor/packaging/tags.py
44
+++ b/src/pip/_vendor/packaging/tags.py
55
@@ -25,7 +25,7 @@ from . import _manylinux, _musllinux
66
logger = logging.getLogger(__name__)
7-
7+
88
PythonVersion = Sequence[int]
99
-MacVersion = Tuple[int, int]
1010
+AppleVersion = Tuple[int, int]
11-
11+
1212
INTERPRETER_SHORT_NAMES: dict[str, str] = {
1313
"python": "py", # Generic.
1414
@@ -363,7 +363,7 @@ def _mac_arch(arch: str, is_32bit: bool = _32_BIT_INTERPRETER) -> str:
1515
return "i386"
16-
17-
16+
17+
1818
-def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> list[str]:
1919
+def _mac_binary_formats(version: AppleVersion, cpu_arch: str) -> list[str]:
2020
formats = [cpu_arch]
2121
if cpu_arch == "x86_64":
2222
if version < (10, 4):
2323
@@ -396,7 +396,7 @@ def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> list[str]:
24-
25-
24+
25+
2626
def mac_platforms(
2727
- version: MacVersion | None = None, arch: str | None = None
2828
+ version: AppleVersion | None = None, arch: str | None = None
@@ -47,10 +47,10 @@ index 6667d2990..bcc6ea041 100644
4747
else:
4848
version = version
4949
if arch is None:
50-
@@ -483,6 +483,58 @@ def mac_platforms(
50+
@@ -483,6 +483,63 @@ def mac_platforms(
5151
)
52-
53-
52+
53+
5454
+def ios_platforms(
5555
+ version: AppleVersion | None = None, multiarch: str | None = None
5656
+) -> Iterator[str]:
@@ -77,36 +77,41 @@ index 6667d2990..bcc6ea041 100644
7777
+
7878
+ ios_platform_template = "ios_{major}_{minor}_{multiarch}"
7979
+
80-
+ # Consider any major.minor version from iOS 12.0 to the version prior to the
81-
+ # version requested by platform. 12.0 is the first iOS version that is known
82-
+ # to have enough features to support CPython. Consider every possible minor
83-
+ # release up to X.9. There highest the minor has ever gone is 8 (14.8 and
84-
+ # 15.8) but having some extra candidates that won't ever match doesn't
85-
+ # really hurt, and it saves us from having to keep an explicit list of known
86-
+ # iOS versions in the code.
87-
+ for major in range(12, version[0]):
88-
+ for minor in range(0, 10):
89-
+ yield ios_platform_template.format(
90-
+ major=major, minor=minor, multiarch=multiarch
91-
+ )
80+
+ # Consider any iOS major.minor version from the version requested, down to
81+
+ # 12.0. 12.0 is the first iOS version that is known to have enough features
82+
+ # to support CPython. Consider every possible minor release up to X.9. There
83+
+ # highest the minor has ever gone is 8 (14.8 and 15.8) but having some extra
84+
+ # candidates that won't ever match doesn't really hurt, and it saves us from
85+
+ # having to keep an explicit list of known iOS versions in the code. Return
86+
+ # the results descending order of version number.
87+
+
88+
+ # If the requested major version is less than 12, there won't be any matches.
89+
+ if version[0] < 12:
90+
+ return
91+
+
92+
+ # Consider the actual X.Y version that was requested.
93+
+ yield ios_platform_template.format(
94+
+ major=version[0], minor=version[1], multiarch=multiarch
95+
+ )
9296
+
9397
+ # Consider every minor version from X.0 to the minor version prior to the
9498
+ # version requested by the platform.
95-
+ for minor in range(0, version[1]):
99+
+ for minor in range(version[1] - 1, -1, -1):
96100
+ yield ios_platform_template.format(
97101
+ major=version[0], minor=minor, multiarch=multiarch
98102
+ )
99103
+
100-
+ # Consider the actual X.Y version that was requested.
101-
+ yield ios_platform_template.format(
102-
+ major=version[0], minor=version[1], multiarch=multiarch
103-
+ )
104+
+ for major in range(version[0] - 1, 11, -1):
105+
+ for minor in range(9, -1, -1):
106+
+ yield ios_platform_template.format(
107+
+ major=major, minor=minor, multiarch=multiarch
108+
+ )
104109
+
105110
+
106111
def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
107112
linux = _normalize_string(sysconfig.get_platform())
108113
if not linux.startswith("linux_"):
109-
@@ -512,6 +563,8 @@ def platform_tags() -> Iterator[str]:
114+
@@ -512,6 +569,8 @@ def platform_tags() -> Iterator[str]:
110115
"""
111116
if platform.system() == "Darwin":
112117
return mac_platforms()

0 commit comments

Comments
 (0)