Skip to content

Commit

Permalink
Merge pull request #1095 from qwcode/fix-1074
Browse files Browse the repository at this point in the history
function in case of broken sysconfig. fix #1074
  • Loading branch information
qwcode committed Jul 28, 2013
2 parents b262aa3 + f91fc2f commit 84480ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
15 changes: 9 additions & 6 deletions pip/pep425tags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Generate and work with PEP 425 Compatibility Tags."""

import sys
import warnings

try:
import sysconfig
Expand All @@ -25,10 +26,7 @@ def get_abbr_impl():

def get_impl_ver():
"""Return implementation version."""
impl_ver = sysconfig.get_config_var("py_version_nodot")
if not impl_ver:
impl_ver = ''.join(map(str, sys.version_info[:2]))
return impl_ver
return ''.join(map(str, sys.version_info[:2]))


def get_platform():
Expand Down Expand Up @@ -58,7 +56,12 @@ def get_supported(versions=None, noarch=False):

abis = []

soabi = sysconfig.get_config_var('SOABI')
try:
soabi = sysconfig.get_config_var('SOABI')
except IOError as e: # Issue #1074
warnings.warn("{0}".format(e), RuntimeWarning)
soabi = None

if soabi and soabi.startswith('cpython-'):
abis[0:0] = ['cp' + soabi.split('-', 1)[-1]]

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

if not noarch:
arch = get_platform()

# Current version, current API (built specifically for our Python):
for abi in abis:
supported.append(('%s%s' % (impl, versions[0]), abi, arch))
Expand Down
19 changes: 17 additions & 2 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,27 @@ def test_unpack_wheel_no_flatten(self):
finally:
rmtree(tmpdir)
pass

def test_purelib_platlib(self):
"""
Test the "wheel is purelib/platlib" code.
"""
packages = [("pure_wheel", "data/packages/pure_wheel-1.7", True),
("plat_wheel", "data/packages/plat_wheel-1.7", False)]
("plat_wheel", "data/packages/plat_wheel-1.7", False)]
for name, path, expected in packages:
assert wheel.root_is_purelib(name, path) == expected

class TestPEP425Tags(object):

def test_broken_sysconfig(self):
"""
Test that pep425tags still works when sysconfig is broken.
Can be a problem on Python 2.7
Issue #1074.
"""
import pip.pep425tags
def raises_ioerror(var):
raise IOError("I have the wrong path!")
with patch('pip.pep425tags.sysconfig.get_config_var', raises_ioerror):
assert len(pip.pep425tags.get_supported())

0 comments on commit 84480ac

Please sign in to comment.