Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify abi3 usage in pep425tags #7367

Merged
merged 3 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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