1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Replace get_abbr_impl with interpreter_name

This reduces the amount of code we have to manage.

interpreter_name is calculated differently, defaulting to the
long name of the interpreter rather than "cp", but that is more
conformant.
This commit is contained in:
Chris Hunt 2019-11-23 18:02:23 -05:00
parent 4b5614c9e2
commit 893faa9e44
3 changed files with 7 additions and 25 deletions

View file

@ -9,13 +9,12 @@ import json
import logging
import os
from pip._vendor.packaging.tags import interpreter_version
from pip._vendor.packaging.tags import interpreter_name, interpreter_version
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal.exceptions import InvalidWheelFilename
from pip._internal.models.link import Link
from pip._internal.models.wheel import Wheel
from pip._internal.pep425tags import interpreter_name
from pip._internal.utils.compat import expanduser
from pip._internal.utils.temp_dir import TempDirectory
from pip._internal.utils.typing import MYPY_CHECK_RUNNING

View file

@ -9,7 +9,7 @@ import sys
import sysconfig
from collections import OrderedDict
from pip._vendor.packaging.tags import interpreter_version
from pip._vendor.packaging.tags import interpreter_name, interpreter_version
from pip._vendor.six import PY2
import pip._internal.utils.glibc
@ -41,23 +41,6 @@ def get_config_var(var):
return sysconfig.get_config_var(var)
def get_abbr_impl():
# type: () -> str
"""Return abbreviated implementation name."""
if hasattr(sys, 'pypy_version_info'):
pyimpl = 'pp'
elif sys.platform.startswith('java'):
pyimpl = 'jy'
elif sys.platform == 'cli':
pyimpl = 'ip'
else:
pyimpl = 'cp'
return pyimpl
interpreter_name = get_abbr_impl
def version_info_to_nodot(version_info):
# type: (Tuple[int, ...]) -> str
# Only use up to the first two numbers.
@ -68,7 +51,7 @@ def get_impl_version_info():
# type: () -> Tuple[int, ...]
"""Return sys.version_info-like tuple for use in decrementing the minor
version."""
if get_abbr_impl() == 'pp':
if interpreter_name() == 'pp':
# as per https://github.com/pypa/pip/issues/2882
# attrs exist only on pypy
return (sys.version_info[0],
@ -96,7 +79,7 @@ def get_abi_tag():
"""Return the ABI tag based on SOABI (if available) or emulate SOABI
(CPython 2, PyPy)."""
soabi = get_config_var('SOABI')
impl = get_abbr_impl()
impl = interpreter_name()
abi = None # type: Optional[str]
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
@ -385,7 +368,7 @@ def get_supported(
current_version = versions[0]
other_versions = versions[1:]
impl = impl or get_abbr_impl()
impl = impl or interpreter_name()
abis = [] # type: List[str]

View file

@ -2,7 +2,7 @@ import sys
import pytest
from mock import patch
from pip._vendor.packaging.tags import interpreter_version
from pip._vendor.packaging.tags import interpreter_name, interpreter_version
from pip._internal import pep425tags
@ -54,7 +54,7 @@ class TestPEP425Tags(object):
import pip._internal.pep425tags
config_vars.update({'SOABI': None})
base = pip._internal.pep425tags.get_abbr_impl() + interpreter_version()
base = interpreter_name() + interpreter_version()
if sys.version_info >= (3, 8):
# Python 3.8 removes the m flag, so don't look for it.