|
| 1 | +diff --git a/src/pip/_vendor/packaging/tags.py b/src/pip/_vendor/packaging/tags.py |
| 2 | +index 6667d2990..bcc6ea041 100644 |
| 3 | +--- a/src/pip/_vendor/packaging/tags.py |
| 4 | ++++ b/src/pip/_vendor/packaging/tags.py |
| 5 | +@@ -25,7 +25,7 @@ from . import _manylinux, _musllinux |
| 6 | + logger = logging.getLogger(__name__) |
| 7 | + |
| 8 | + PythonVersion = Sequence[int] |
| 9 | +-MacVersion = Tuple[int, int] |
| 10 | ++AppleVersion = Tuple[int, int] |
| 11 | + |
| 12 | + INTERPRETER_SHORT_NAMES: dict[str, str] = { |
| 13 | + "python": "py", # Generic. |
| 14 | +@@ -363,7 +363,7 @@ def _mac_arch(arch: str, is_32bit: bool = _32_BIT_INTERPRETER) -> str: |
| 15 | + return "i386" |
| 16 | + |
| 17 | + |
| 18 | +-def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> list[str]: |
| 19 | ++def _mac_binary_formats(version: AppleVersion, cpu_arch: str) -> list[str]: |
| 20 | + formats = [cpu_arch] |
| 21 | + if cpu_arch == "x86_64": |
| 22 | + if version < (10, 4): |
| 23 | +@@ -396,7 +396,7 @@ def _mac_binary_formats(version: MacVersion, cpu_arch: str) -> list[str]: |
| 24 | + |
| 25 | + |
| 26 | + def mac_platforms( |
| 27 | +- version: MacVersion | None = None, arch: str | None = None |
| 28 | ++ version: AppleVersion | None = None, arch: str | None = None |
| 29 | + ) -> Iterator[str]: |
| 30 | + """ |
| 31 | + Yields the platform tags for a macOS system. |
| 32 | +@@ -408,7 +408,7 @@ def mac_platforms( |
| 33 | + """ |
| 34 | + version_str, _, cpu_arch = platform.mac_ver() |
| 35 | + if version is None: |
| 36 | +- version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2]))) |
| 37 | ++ version = cast("AppleVersion", tuple(map(int, version_str.split(".")[:2]))) |
| 38 | + if version == (10, 16): |
| 39 | + # When built against an older macOS SDK, Python will report macOS 10.16 |
| 40 | + # instead of the real version. |
| 41 | +@@ -424,7 +424,7 @@ def mac_platforms( |
| 42 | + stdout=subprocess.PIPE, |
| 43 | + text=True, |
| 44 | + ).stdout |
| 45 | +- version = cast("MacVersion", tuple(map(int, version_str.split(".")[:2]))) |
| 46 | ++ version = cast("AppleVersion", tuple(map(int, version_str.split(".")[:2]))) |
| 47 | + else: |
| 48 | + version = version |
| 49 | + if arch is None: |
| 50 | +@@ -483,6 +483,57 @@ def mac_platforms( |
| 51 | + ) |
| 52 | + |
| 53 | + |
| 54 | ++def ios_platforms( |
| 55 | ++ version: AppleVersion | None = None, multiarch: str | None = None |
| 56 | ++) -> Iterator[str]: |
| 57 | ++ """ |
| 58 | ++ Yields the platform tags for an iOS system. |
| 59 | ++ |
| 60 | ++ :param version: A two-item tuple specifying the iOS version to generate |
| 61 | ++ platform tags for. Defaults to the current iOS version. |
| 62 | ++ :param multiarch: The CPU architecture+ABI to generate platform tags for - |
| 63 | ++ (the value used by `sys.implementation._multiarch` e.g., |
| 64 | ++ `arm64_iphoneos` or `x84_64_iphonesimulator`). Defaults to the current |
| 65 | ++ multiarch value. |
| 66 | ++ """ |
| 67 | ++ if version is None: |
| 68 | ++ # if iOS is the current platform, ios_ver *must* be defined. However, |
| 69 | ++ # it won't exist for CPython versions before 3.13, which causes a mypy |
| 70 | ++ # error. |
| 71 | ++ _, release, _, _ = platform.ios_ver() # type: ignore[attr-defined] |
| 72 | ++ version = cast("AppleVersion", tuple(map(int, release.split(".")[:2]))) |
| 73 | ++ |
| 74 | ++ if multiarch is None: |
| 75 | ++ multiarch = sys.implementation._multiarch |
| 76 | ++ |
| 77 | ++ ios_platform_template = "ios_{major}_{minor}_{multiarch}" |
| 78 | ++ |
| 79 | ++ # Consider any major.minor version from iOS 12.0 to the version prior to the |
| 80 | ++ # version requested by platform. 12.0 is the first iOS version that is known |
| 81 | ++ # to have enough features to support CPython. Consider every possible minor |
| 82 | ++ # release up to X.9. There highest the minor has ever gone is 8 (14.8 and |
| 83 | ++ # 15.8) but having some extra candidates that won't ever match doesn't |
| 84 | ++ # really hurt, and it saves us from having to keep an explicit list of known |
| 85 | ++ # iOS versions in the code. |
| 86 | ++ for major in range(12, version[0]): |
| 87 | ++ for minor in range(0, 10): |
| 88 | ++ yield ios_platform_template.format( |
| 89 | ++ major=major, minor=minor, multiarch=multiarch |
| 90 | ++ ) |
| 91 | ++ |
| 92 | ++ # Consider every minor version from X.0 to the minor version prior to the |
| 93 | ++ # version requested by the platform. |
| 94 | ++ for minor in range(0, version[1]): |
| 95 | ++ yield ios_platform_template.format( |
| 96 | ++ major=version[0], minor=minor, multiarch=multiarch |
| 97 | ++ ) |
| 98 | ++ |
| 99 | ++ # Consider the actual X.Y version that was requested. |
| 100 | ++ yield ios_platform_template.format( |
| 101 | ++ major=version[0], minor=version[1], multiarch=multiarch |
| 102 | ++ ) |
| 103 | ++ |
| 104 | ++ |
| 105 | + def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]: |
| 106 | + linux = _normalize_string(sysconfig.get_platform()) |
| 107 | + if not linux.startswith("linux_"): |
| 108 | +@@ -512,6 +563,8 @@ def platform_tags() -> Iterator[str]: |
| 109 | + """ |
| 110 | + if platform.system() == "Darwin": |
| 111 | + return mac_platforms() |
| 112 | ++ elif platform.system() == "iOS": |
| 113 | ++ return ios_platforms() |
| 114 | + elif platform.system() == "Linux": |
| 115 | + return _linux_platforms() |
| 116 | + else: |
0 commit comments