Skip to content

Commit

Permalink
Repair .egg resolution for platform specific eggs.
Browse files Browse the repository at this point in the history
  • Loading branch information
kwlzn committed May 18, 2018
1 parent a5c59f6 commit b40145f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pex/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,20 @@ def __init__(self, url, **kw):
raise self.InvalidPackage('Could not match egg: %s' % filename)

self._name, self._raw_version, self._py_version, self._platform = matcher.group(
'name', 'ver', 'pyver', 'plat')
'name', 'ver', 'pyver', 'plat'
)

if self._raw_version is None or self._py_version is None:
raise self.InvalidPackage('url with .egg extension but bad name: %s' % url)

impl = 'py' + self._py_version.replace('.', '')
abi_tag = 'none'
tag_platform = self._platform or 'any'
self._supported_tags = set()
self._supported_tags.add(('py' + self._py_version.replace('.', ''), abi_tag, tag_platform))
tag_platform = (self._platform or 'any').replace('-', '_')

self._supported_tags = set([(impl, abi_tag, tag_platform)])
if tag_platform != 'any':
self._supported_tags.add((impl, abi_tag, 'any'))

# Work around PyPy versions being weird in pep425tags.get_supported
if self.py_version == '2.7':
self._supported_tags.add(('pp2', abi_tag, tag_platform))
Expand Down
1 change: 1 addition & 0 deletions pex/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
IS_LINUX = "platform.system() == 'Linux'"
IS_NOT_LINUX = "platform.system() != 'Linux'"
NOT_CPYTHON27_OR_OSX = "%s or %s" % (NOT_CPYTHON27, IS_NOT_LINUX)
NOT_CPYTHON27_OR_LINUX = "%s or %s" % (NOT_CPYTHON27, IS_LINUX)
NOT_CPYTHON36_OR_LINUX = "%s or %s" % (NOT_CPYTHON36, IS_LINUX)


Expand Down
12 changes: 12 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from pex.pex_bootstrapper import get_pex_info
from pex.testing import (
IS_PYPY,
NOT_CPYTHON27,
NOT_CPYTHON27_OR_OSX,
NOT_CPYTHON36,
NOT_CPYTHON36_OR_LINUX,
Expand Down Expand Up @@ -830,3 +831,14 @@ def test_pex_manylinux_runtime():

out = subprocess.check_output([pex_path, tester_path])
assert out.strip() == '[1, 2, 3]'


@pytest.mark.skipif(NOT_CPYTHON27)
def test_platform_specific_egg_resolution():
with temporary_dir() as td:
pex_out_path = os.path.join(td, 'pex.pex')
res = run_pex_command(['--disable-cache',
'--no-wheel',
'MarkupSafe==1.0',
'-o', pex_out_path])
res.assert_success()

0 comments on commit b40145f

Please sign in to comment.