Skip to content

Commit 8ad84de

Browse files
committed
Remove unused abi functions
1 parent 218cd2a commit 8ad84de

File tree

2 files changed

+1
-115
lines changed

2 files changed

+1
-115
lines changed

src/pip/_internal/pep425tags.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
from pip._internal.utils.typing import MYPY_CHECK_RUNNING
2222

2323
if MYPY_CHECK_RUNNING:
24-
from typing import (
25-
Callable, List, Optional, Tuple, Union
26-
)
24+
from typing import List, Optional, Tuple, Union
2725

2826
from pip._vendor.packaging.tags import PythonVersion
2927

@@ -78,52 +76,6 @@ def get_impl_tag():
7876
return "{}{}".format(interpreter_name(), get_impl_ver())
7977

8078

81-
def get_flag(var, fallback, expected=True, warn=True):
82-
# type: (str, Callable[..., bool], Union[bool, int], bool) -> bool
83-
"""Use a fallback method for determining SOABI flags if the needed config
84-
var is unset or unavailable."""
85-
val = get_config_var(var)
86-
if val is None:
87-
if warn:
88-
logger.debug("Config variable '%s' is unset, Python ABI tag may "
89-
"be incorrect", var)
90-
return fallback()
91-
return val == expected
92-
93-
94-
def get_abi_tag():
95-
# type: () -> Optional[str]
96-
"""Return the ABI tag based on SOABI (if available) or emulate SOABI
97-
(CPython 2, PyPy)."""
98-
soabi = get_config_var('SOABI')
99-
impl = interpreter_name()
100-
abi = None # type: Optional[str]
101-
102-
if not soabi and impl in {'cp', 'pp'} and hasattr(sys, 'maxunicode'):
103-
d = ''
104-
m = ''
105-
u = ''
106-
is_cpython = (impl == 'cp')
107-
if get_flag(
108-
'Py_DEBUG', lambda: hasattr(sys, 'gettotalrefcount'),
109-
warn=is_cpython):
110-
d = 'd'
111-
if sys.version_info < (3, 8) and get_flag(
112-
'WITH_PYMALLOC', lambda: is_cpython, warn=is_cpython):
113-
m = 'm'
114-
if sys.version_info < (3, 3) and get_flag(
115-
'Py_UNICODE_SIZE', lambda: sys.maxunicode == 0x10ffff,
116-
expected=4, warn=is_cpython):
117-
u = 'u'
118-
abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u)
119-
elif soabi and soabi.startswith('cpython-'):
120-
abi = 'cp' + soabi.split('-')[1]
121-
elif soabi:
122-
abi = soabi.replace('.', '_').replace('-', '_')
123-
124-
return abi
125-
126-
12779
def _is_running_32bit():
12880
# type: () -> bool
12981
return sys.maxsize == 2147483647

tests/unit/test_pep425tags.py

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import sys
2-
31
import pytest
42
from mock import patch
5-
from pip._vendor.packaging.tags import interpreter_name
63

74
from pip._internal import pep425tags
85

@@ -38,45 +35,6 @@ def _mock_get_config_var(var):
3835
return get_config_var(var)
3936
return _mock_get_config_var
4037

41-
def abi_tag_unicode(self, flags, config_vars):
42-
"""
43-
Used to test ABI tags, verify correct use of the `u` flag
44-
"""
45-
import pip._internal.pep425tags
46-
47-
config_vars.update({'SOABI': None})
48-
base = interpreter_name() + pip._internal.pep425tags.get_impl_ver()
49-
50-
if sys.version_info >= (3, 8):
51-
# Python 3.8 removes the m flag, so don't look for it.
52-
flags = flags.replace('m', '')
53-
54-
if sys.version_info < (3, 3):
55-
config_vars.update({'Py_UNICODE_SIZE': 2})
56-
mock_gcf = self.mock_get_config_var(**config_vars)
57-
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
58-
mock_gcf):
59-
abi_tag = pip._internal.pep425tags.get_abi_tag()
60-
assert abi_tag == base + flags
61-
62-
config_vars.update({'Py_UNICODE_SIZE': 4})
63-
mock_gcf = self.mock_get_config_var(**config_vars)
64-
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
65-
mock_gcf):
66-
abi_tag = pip._internal.pep425tags.get_abi_tag()
67-
assert abi_tag == base + flags + 'u'
68-
69-
else:
70-
# On Python >= 3.3, UCS-4 is essentially permanently enabled, and
71-
# Py_UNICODE_SIZE is None. SOABI on these builds does not include
72-
# the 'u' so manual SOABI detection should not do so either.
73-
config_vars.update({'Py_UNICODE_SIZE': None})
74-
mock_gcf = self.mock_get_config_var(**config_vars)
75-
with patch('pip._internal.pep425tags.sysconfig.get_config_var',
76-
mock_gcf):
77-
abi_tag = pip._internal.pep425tags.get_abi_tag()
78-
assert abi_tag == base + flags
79-
8038
@pytest.mark.xfail(
8139
strict=True, reason="packaging.tags does not guard against this error"
8240
)
@@ -112,30 +70,6 @@ def test_no_hyphen_tag(self):
11270
assert '-' not in tag.abi
11371
assert '-' not in tag.platform
11472

115-
def test_manual_abi_noflags(self):
116-
"""
117-
Test that no flags are set on a non-PyDebug, non-Pymalloc ABI tag.
118-
"""
119-
self.abi_tag_unicode('', {'Py_DEBUG': False, 'WITH_PYMALLOC': False})
120-
121-
def test_manual_abi_d_flag(self):
122-
"""
123-
Test that the `d` flag is set on a PyDebug, non-Pymalloc ABI tag.
124-
"""
125-
self.abi_tag_unicode('d', {'Py_DEBUG': True, 'WITH_PYMALLOC': False})
126-
127-
def test_manual_abi_m_flag(self):
128-
"""
129-
Test that the `m` flag is set on a non-PyDebug, Pymalloc ABI tag.
130-
"""
131-
self.abi_tag_unicode('m', {'Py_DEBUG': False, 'WITH_PYMALLOC': True})
132-
133-
def test_manual_abi_dm_flags(self):
134-
"""
135-
Test that the `dm` flags are set on a PyDebug, Pymalloc ABI tag.
136-
"""
137-
self.abi_tag_unicode('dm', {'Py_DEBUG': True, 'WITH_PYMALLOC': True})
138-
13973

14074
class TestManylinux2010Tags(object):
14175

0 commit comments

Comments
 (0)