Skip to content

Commit 84480ac

Browse files
committed
Merge pull request #1095 from qwcode/fix-1074
function in case of broken sysconfig. fix #1074
2 parents b262aa3 + f91fc2f commit 84480ac

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

pip/pep425tags.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Generate and work with PEP 425 Compatibility Tags."""
22

33
import sys
4+
import warnings
45

56
try:
67
import sysconfig
@@ -25,10 +26,7 @@ def get_abbr_impl():
2526

2627
def get_impl_ver():
2728
"""Return implementation version."""
28-
impl_ver = sysconfig.get_config_var("py_version_nodot")
29-
if not impl_ver:
30-
impl_ver = ''.join(map(str, sys.version_info[:2]))
31-
return impl_ver
29+
return ''.join(map(str, sys.version_info[:2]))
3230

3331

3432
def get_platform():
@@ -58,7 +56,12 @@ def get_supported(versions=None, noarch=False):
5856

5957
abis = []
6058

61-
soabi = sysconfig.get_config_var('SOABI')
59+
try:
60+
soabi = sysconfig.get_config_var('SOABI')
61+
except IOError as e: # Issue #1074
62+
warnings.warn("{0}".format(e), RuntimeWarning)
63+
soabi = None
64+
6265
if soabi and soabi.startswith('cpython-'):
6366
abis[0:0] = ['cp' + soabi.split('-', 1)[-1]]
6467

@@ -74,7 +77,7 @@ def get_supported(versions=None, noarch=False):
7477

7578
if not noarch:
7679
arch = get_platform()
77-
80+
7881
# Current version, current API (built specifically for our Python):
7982
for abi in abis:
8083
supported.append(('%s%s' % (impl, versions[0]), abi, arch))

tests/unit/test_wheel.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,27 @@ def test_unpack_wheel_no_flatten(self):
150150
finally:
151151
rmtree(tmpdir)
152152
pass
153-
153+
154154
def test_purelib_platlib(self):
155155
"""
156156
Test the "wheel is purelib/platlib" code.
157157
"""
158158
packages = [("pure_wheel", "data/packages/pure_wheel-1.7", True),
159-
("plat_wheel", "data/packages/plat_wheel-1.7", False)]
159+
("plat_wheel", "data/packages/plat_wheel-1.7", False)]
160160
for name, path, expected in packages:
161161
assert wheel.root_is_purelib(name, path) == expected
162+
163+
class TestPEP425Tags(object):
164+
165+
def test_broken_sysconfig(self):
166+
"""
167+
Test that pep425tags still works when sysconfig is broken.
168+
Can be a problem on Python 2.7
169+
Issue #1074.
170+
"""
171+
import pip.pep425tags
172+
def raises_ioerror(var):
173+
raise IOError("I have the wrong path!")
174+
with patch('pip.pep425tags.sysconfig.get_config_var', raises_ioerror):
175+
assert len(pip.pep425tags.get_supported())
176+

0 commit comments

Comments
 (0)