File tree 2 files changed +26
-8
lines changed
2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 1
1
"""Generate and work with PEP 425 Compatibility Tags."""
2
2
3
3
import sys
4
+ import warnings
4
5
5
6
try :
6
7
import sysconfig
@@ -25,10 +26,7 @@ def get_abbr_impl():
25
26
26
27
def get_impl_ver ():
27
28
"""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 ]))
32
30
33
31
34
32
def get_platform ():
@@ -58,7 +56,12 @@ def get_supported(versions=None, noarch=False):
58
56
59
57
abis = []
60
58
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
+
62
65
if soabi and soabi .startswith ('cpython-' ):
63
66
abis [0 :0 ] = ['cp' + soabi .split ('-' , 1 )[- 1 ]]
64
67
@@ -74,7 +77,7 @@ def get_supported(versions=None, noarch=False):
74
77
75
78
if not noarch :
76
79
arch = get_platform ()
77
-
80
+
78
81
# Current version, current API (built specifically for our Python):
79
82
for abi in abis :
80
83
supported .append (('%s%s' % (impl , versions [0 ]), abi , arch ))
Original file line number Diff line number Diff line change @@ -150,12 +150,27 @@ def test_unpack_wheel_no_flatten(self):
150
150
finally :
151
151
rmtree (tmpdir )
152
152
pass
153
-
153
+
154
154
def test_purelib_platlib (self ):
155
155
"""
156
156
Test the "wheel is purelib/platlib" code.
157
157
"""
158
158
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 )]
160
160
for name , path , expected in packages :
161
161
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
+
You can’t perform that action at this time.
0 commit comments