-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow --platform resolves for current interpreter. (#1364)
Previously, if a `--platform` resolve was being executed with an interpreter that matched the platform, a regular full-featured interpreter resolve was performed. This prevented, for example, resolving using a CPython 3.8 interpreter on a manylinux2014 capable host for deployment to a host that is only manylinux2010 capable. The `--resolve-local-platforms` option exists to force this sort of fallback to a full-featured interpreter resolve when that is desired. Fixes #1355
- Loading branch information
Showing
6 changed files
with
204 additions
and
22 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
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,58 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import absolute_import | ||
|
||
import pytest | ||
|
||
from pex.distribution_target import DistributionTarget | ||
from pex.interpreter import PythonInterpreter | ||
|
||
|
||
@pytest.fixture | ||
def current_interpreter(): | ||
# type: () -> PythonInterpreter | ||
return PythonInterpreter.get() | ||
|
||
|
||
def test_interpreter_platform_mutex(current_interpreter): | ||
# type: (PythonInterpreter) -> None | ||
|
||
def assert_is_platform(target): | ||
# type: (DistributionTarget) -> None | ||
assert target.is_platform | ||
assert not target.is_interpreter | ||
|
||
def assert_is_interpreter(target): | ||
# type: (DistributionTarget) -> None | ||
assert target.is_interpreter | ||
assert not target.is_platform | ||
|
||
assert_is_interpreter(DistributionTarget.current()) | ||
assert_is_interpreter(DistributionTarget()) | ||
assert_is_interpreter(DistributionTarget.for_interpreter(current_interpreter)) | ||
assert_is_platform(DistributionTarget.for_platform(current_interpreter.platform)) | ||
|
||
with pytest.raises(DistributionTarget.AmbiguousTargetError): | ||
DistributionTarget(interpreter=current_interpreter, platform=current_interpreter.platform) | ||
|
||
|
||
def test_manylinux(current_interpreter): | ||
# type: (PythonInterpreter) -> None | ||
|
||
current_platform = current_interpreter.platform | ||
|
||
target = DistributionTarget.for_platform(current_platform, manylinux="foo") | ||
assert (current_platform, "foo") == target.get_platform() | ||
|
||
target = DistributionTarget(platform=current_platform, manylinux="bar") | ||
assert (current_platform, "bar") == target.get_platform() | ||
|
||
with pytest.raises(DistributionTarget.ManylinuxOutOfContextError): | ||
DistributionTarget(manylinux="baz") | ||
|
||
with pytest.raises(DistributionTarget.ManylinuxOutOfContextError): | ||
DistributionTarget(interpreter=PythonInterpreter.get(), manylinux="baz") | ||
|
||
target = DistributionTarget.for_interpreter(current_interpreter) | ||
assert (current_platform, None) == target.get_platform() |
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