Skip to content

Commit

Permalink
Simplify abi3 usage in pep425tags (#7367)
Browse files Browse the repository at this point in the history
abi3 refers to the CPython stable ABI, so we should only ensure it
applies in that particular case.

This simplifies the logic in get_platforms() and makes us more
compatible with the behavior of packaging.tags, which only includes abi3
for cpython_tags() and only the literal "abi3".
  • Loading branch information
chrahunt authored Nov 19, 2019
1 parent a3bcaa4 commit b802331
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
2 changes: 2 additions & 0 deletions news/7327.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Use literal "abi3" for wheel tag on CPython 3.x, to align with PEP 384
which only defines it for this platform.
25 changes: 12 additions & 13 deletions src/pip/_internal/pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import warnings
from collections import OrderedDict

from pip._vendor.six import PY2

import pip._internal.utils.glibc
from pip._internal.utils.compat import get_extension_suffixes
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

if MYPY_CHECK_RUNNING:
from typing import (
Tuple, Callable, List, Optional, Union, Dict, Set
Tuple, Callable, List, Optional, Union, Dict
)

Pep425Tag = Tuple[str, str, str]
Expand Down Expand Up @@ -361,12 +362,10 @@ def get_supported(
if abi:
abis[0:0] = [abi]

abi3s = set() # type: Set[str]
for suffix in get_extension_suffixes():
if suffix.startswith('.abi'):
abi3s.add(suffix.split('.', 2)[1])
supports_abi3 = not PY2 and impl == "cp"

abis.extend(sorted(list(abi3s)))
if supports_abi3:
abis.append("abi3")

abis.append('none')

Expand Down Expand Up @@ -419,13 +418,13 @@ def get_supported(
supported.append(('%s%s' % (impl, versions[0]), abi, arch))

# abi3 modules compatible with older version of Python
for version in versions[1:]:
# abi3 was introduced in Python 3.2
if version in {'31', '30'}:
break
for abi in abi3s: # empty set if not Python 3
if supports_abi3:
for version in versions[1:]:
# abi3 was introduced in Python 3.2
if version in {'31', '30'}:
break
for arch in arches:
supported.append(("%s%s" % (impl, version), abi, arch))
supported.append(("%s%s" % (impl, version), "abi3", arch))

# Has binaries, does not use the Python API:
for arch in arches:
Expand Down
14 changes: 0 additions & 14 deletions src/pip/_internal/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
__all__ = [
"ipaddress", "uses_pycache", "console_to_str",
"get_path_uid", "stdlib_pkgs", "WINDOWS", "samefile", "get_terminal_size",
"get_extension_suffixes",
]


Expand Down Expand Up @@ -189,19 +188,6 @@ def get_path_uid(path):
return file_uid


if PY2:
from imp import get_suffixes

def get_extension_suffixes():
return [suffix[0] for suffix in get_suffixes()]

else:
from importlib.machinery import EXTENSION_SUFFIXES

def get_extension_suffixes():
return EXTENSION_SUFFIXES


def expanduser(path):
# type: (str) -> str
"""
Expand Down

0 comments on commit b802331

Please sign in to comment.