9
9
import sysconfig
10
10
from collections import OrderedDict
11
11
12
+ from pip ._vendor .packaging .tags import interpreter_name , interpreter_version
12
13
from pip ._vendor .six import PY2
13
14
14
15
import pip ._internal .utils .glibc
@@ -40,46 +41,17 @@ def get_config_var(var):
40
41
return sysconfig .get_config_var (var )
41
42
42
43
43
- def get_abbr_impl ():
44
- # type: () -> str
45
- """Return abbreviated implementation name."""
46
- if hasattr (sys , 'pypy_version_info' ):
47
- pyimpl = 'pp'
48
- elif sys .platform .startswith ('java' ):
49
- pyimpl = 'jy'
50
- elif sys .platform == 'cli' :
51
- pyimpl = 'ip'
52
- else :
53
- pyimpl = 'cp'
54
- return pyimpl
55
-
56
-
57
- interpreter_name = get_abbr_impl
58
-
59
-
60
44
def version_info_to_nodot (version_info ):
61
45
# type: (Tuple[int, ...]) -> str
62
46
# Only use up to the first two numbers.
63
47
return '' .join (map (str , version_info [:2 ]))
64
48
65
49
66
- def get_impl_ver ():
67
- # type: () -> str
68
- """Return implementation version."""
69
- impl_ver = get_config_var ("py_version_nodot" )
70
- if not impl_ver or get_abbr_impl () == 'pp' :
71
- impl_ver = '' .join (map (str , get_impl_version_info ()))
72
- return impl_ver
73
-
74
-
75
- interpreter_version = get_impl_ver
76
-
77
-
78
50
def get_impl_version_info ():
79
51
# type: () -> Tuple[int, ...]
80
52
"""Return sys.version_info-like tuple for use in decrementing the minor
81
53
version."""
82
- if get_abbr_impl () == 'pp' :
54
+ if interpreter_name () == 'pp' :
83
55
# as per https://github.com/pypa/pip/issues/2882
84
56
# attrs exist only on pypy
85
57
return (sys .version_info [0 ],
@@ -107,7 +79,7 @@ def get_abi_tag():
107
79
"""Return the ABI tag based on SOABI (if available) or emulate SOABI
108
80
(CPython 2, PyPy)."""
109
81
soabi = get_config_var ('SOABI' )
110
- impl = get_abbr_impl ()
82
+ impl = interpreter_name ()
111
83
abi = None # type: Optional[str]
112
84
113
85
if not soabi and impl in {'cp' , 'pp' } and hasattr (sys , 'maxunicode' ):
@@ -126,7 +98,7 @@ def get_abi_tag():
126
98
'Py_UNICODE_SIZE' , lambda : sys .maxunicode == 0x10ffff ,
127
99
expected = 4 , warn = is_cpython ):
128
100
u = 'u'
129
- abi = '%s%s%s%s%s' % (impl , get_impl_ver (), d , m , u )
101
+ abi = '%s%s%s%s%s' % (impl , interpreter_version (), d , m , u )
130
102
elif soabi and soabi .startswith ('cpython-' ):
131
103
abi = 'cp' + soabi .split ('-' )[1 ]
132
104
elif soabi :
@@ -417,7 +389,7 @@ def get_supported(
417
389
current_version = versions [0 ]
418
390
other_versions = versions [1 :]
419
391
420
- impl = impl or get_abbr_impl ()
392
+ impl = impl or interpreter_name ()
421
393
422
394
abis = [] # type: List[str]
423
395
0 commit comments