Skip to content

Commit

Permalink
Fix installers to be insensitive to extras iteration order.
Browse files Browse the repository at this point in the history
Fixes #158
  • Loading branch information
jsirois committed Jul 27, 2018
1 parent bca1cd1 commit 00d219e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pex/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def function_wrapper(self, *args, **kw):

class InstallerBase(object):
SETUP_BOOTSTRAP_HEADER = "import sys"
SETUP_BOOTSTRAP_MODULE = "sys.path.insert(0, %(path)r); import %(module)s"
SETUP_BOOTSTRAP_PYPATH = "sys.path.insert(0, %(path)r)"
SETUP_BOOTSTRAP_MODULE = "import %(module)s"
SETUP_BOOTSTRAP_FOOTER = """
__file__ = 'setup.py'
sys.argv[0] = 'setup.py'
Expand Down Expand Up @@ -85,15 +86,21 @@ def capability(self):

@property
def bootstrap_script(self):
bootstrap_sys_paths = []
bootstrap_modules = []
for module, requirement in self.mixins().items():
path = self._interpreter.get_location(requirement)
if not path:
assert not self._strict # This should be caught by validation
continue
bootstrap_modules.append(self.SETUP_BOOTSTRAP_MODULE % {'path': path, 'module': module})
bootstrap_sys_paths.append(self.SETUP_BOOTSTRAP_PYPATH % {'path': path})
bootstrap_modules.append(self.SETUP_BOOTSTRAP_MODULE % {'module': module})
return '\n'.join(
[self.SETUP_BOOTSTRAP_HEADER] + bootstrap_modules + [self.SETUP_BOOTSTRAP_FOOTER])
[self.SETUP_BOOTSTRAP_HEADER] +
bootstrap_sys_paths +
bootstrap_modules +
[self.SETUP_BOOTSTRAP_FOOTER]
)

def run(self):
if self._installed is not None:
Expand Down

0 comments on commit 00d219e

Please sign in to comment.