Skip to content

function in case of broken sysconfig. fix #1074 #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 28, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())