Skip to content

Commit

Permalink
Add protection against devendored packaging.
Browse files Browse the repository at this point in the history
  • Loading branch information
freakboy3742 committed Oct 29, 2024
1 parent 4204359 commit 82888a8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 18 deletions.
1 change: 1 addition & 0 deletions news/13053.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An ImportError seen when using a devendored version of packaging <= 24.1 has been resolved.
45 changes: 27 additions & 18 deletions src/pip/_internal/utils/compatibility_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
generic_tags,
interpreter_name,
interpreter_version,
ios_platforms,
mac_platforms,
)

Expand Down Expand Up @@ -45,23 +44,33 @@ def _mac_platforms(arch: str) -> List[str]:


def _ios_platforms(arch: str) -> List[str]:
match = _apple_arch_pat.match(arch)
if match:
name, major, minor, actual_multiarch = match.groups()
ios_version = (int(major), int(minor))
arches = [
# Since we have always only checked that the platform starts
# with "ios", for backwards-compatibility we extract the
# actual prefix provided by the user in case they provided
# something like "ioscustom_". It may be good to remove
# this as undocumented or deprecate it in the future.
"{}_{}".format(name, arch[len("ios_") :])
for arch in ios_platforms(ios_version, actual_multiarch)
]
else:
# arch pattern didn't match (?!)
arches = [arch]
return arches
try:
# If using a devendored version of packaging<=24.1, ios_platforms won't
# be available. The try/catch can be removes as soon as a new version of
# packaging is released.
from pip._vendor.packaging.tags import ios_platforms

match = _apple_arch_pat.match(arch)
if match:
name, major, minor, actual_multiarch = match.groups()
ios_version = (int(major), int(minor))
arches = [
# Since we have always only checked that the platform starts
# with "ios", for backwards-compatibility we extract the
# actual prefix provided by the user in case they provided
# something like "ioscustom_". It may be good to remove
# this as undocumented or deprecate it in the future.
"{}_{}".format(name, arch[len("ios_") :])
for arch in ios_platforms(ios_version, actual_multiarch)
]
else:
# arch pattern didn't match (?!)
arches = [arch]

return arches
except ImportError: # pragma: no cover
# Using a devendored version of packaging <= 24.1.
return []


def _custom_manylinux_platforms(arch: str) -> List[str]:
Expand Down

0 comments on commit 82888a8

Please sign in to comment.