-
-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix installers to be insensitive to extras iteration order. (#532)
Fixes #158
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
import contextlib | ||
from collections import OrderedDict | ||
|
||
import pytest | ||
|
||
from pex.bin.pex import get_interpreter | ||
from pex.installer import WheelInstaller | ||
from pex.testing import ensure_python_interpreter, make_installer, temporary_dir | ||
from pex.version import SETUPTOOLS_REQUIREMENT, WHEEL_REQUIREMENT | ||
|
||
|
||
class OrderableInstaller(WheelInstaller): | ||
def __init__(self, source_dir, strict=True, interpreter=None, install_dir=None, mixins=None): | ||
self._mixins = mixins | ||
super(OrderableInstaller, self).__init__(source_dir, strict, interpreter, install_dir) | ||
|
||
def mixins(self): | ||
return self._mixins | ||
|
||
|
||
@contextlib.contextmanager | ||
def bare_interpreter(): | ||
with temporary_dir() as interpreter_cache: | ||
yield get_interpreter( | ||
python_interpreter=ensure_python_interpreter('3.6.3'), | ||
interpreter_cache_dir=interpreter_cache, | ||
repos=None, | ||
use_wheel=True | ||
) | ||
|
||
|
||
@contextlib.contextmanager | ||
def wheel_installer(*mixins): | ||
with bare_interpreter() as interpreter: | ||
with make_installer(installer_impl=OrderableInstaller, | ||
interpreter=interpreter, | ||
mixins=OrderedDict(mixins)) as installer: | ||
yield installer | ||
|
||
|
||
WHEEL_EXTRA = ('wheel', WHEEL_REQUIREMENT) | ||
SETUPTOOLS_EXTRA = ('setuptools', SETUPTOOLS_REQUIREMENT) | ||
|
||
|
||
def test_wheel_before_setuptools(): | ||
with wheel_installer(WHEEL_EXTRA, SETUPTOOLS_EXTRA) as installer: | ||
installer.bdist() | ||
|
||
|
||
def test_setuptools_before_wheel(): | ||
with wheel_installer(SETUPTOOLS_EXTRA, WHEEL_EXTRA) as installer: | ||
installer.bdist() | ||
|
||
|
||
def test_no_wheel(): | ||
with wheel_installer(SETUPTOOLS_EXTRA) as installer: | ||
with pytest.raises(installer.InstallFailure): | ||
installer.bdist() |