-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously `pex` would warn for default usage scenarios under both Python 3.11 and Python 3.12. For Python 3.12, the `--pip-version` defaulted to 23.2 but a warning about vendored Pip 20.3.4 was issued anyway; this is now fixed. For both Python 3.11 and Python 3.12, the vendored version of packaging used the deprecated `sre_constants` stdlib module; this is now fixed with packaging 23.1 being vendored and selected for Python >= 3.7. Fixes #2186
- Loading branch information
Showing
6 changed files
with
94 additions
and
10 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,78 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from textwrap import dedent | ||
from typing import NoReturn, Union | ||
|
||
import pytest | ||
|
||
from pex import targets | ||
from pex.interpreter import PythonInterpreter | ||
from pex.pip.version import PipVersion, PipVersionValue | ||
from pex.testing import IntegResults, run_pex_command | ||
|
||
|
||
def pex_execute_cowsay(*extra_pex_args): | ||
# type: (*str) -> IntegResults | ||
return run_pex_command( | ||
args=list(extra_pex_args) + ["cowsay==5.0", "-c", "cowsay", "--", "Moo!"], quiet=True | ||
) | ||
|
||
|
||
def test_default_resolve_no_warning(): | ||
# type: () -> None | ||
|
||
result = pex_execute_cowsay() | ||
result.assert_success() | ||
assert not result.error | ||
assert "Moo!" in result.output | ||
|
||
|
||
@pytest.fixture | ||
def incompatible_pip_version(): | ||
# type: () -> Union[PipVersionValue, NoReturn] | ||
for pip_version in PipVersion.values(): | ||
if not pip_version.requires_python_applies(targets.current()): | ||
return pip_version | ||
|
||
pytest.skip( | ||
"There is no supported Pip version incompatible with {interpreter}.".format( | ||
interpreter=PythonInterpreter.get() | ||
) | ||
) | ||
raise AssertionError("Unreachable: satisfy type checker.") | ||
|
||
|
||
def expected_incompatible_pip_message(incompatible_pip_version): | ||
# type: (PipVersionValue) -> str | ||
return dedent( | ||
"""\ | ||
Pip {pip_version} requires Python {python_req} and the following target does not apply: | ||
1. {target} | ||
""".format( | ||
pip_version=incompatible_pip_version, | ||
python_req=incompatible_pip_version.requires_python, | ||
target=targets.current(), | ||
) | ||
) | ||
|
||
|
||
def test_incompatible_resolve_warning(incompatible_pip_version): | ||
# type: (PipVersionValue) -> None | ||
|
||
result = pex_execute_cowsay("--pip-version", str(incompatible_pip_version)) | ||
result.assert_success() | ||
assert expected_incompatible_pip_message(incompatible_pip_version) in result.error, result.error | ||
assert "Moo!" in result.output, result.output | ||
|
||
|
||
def test_incompatible_resolve_error(incompatible_pip_version): | ||
# type: (PipVersionValue) -> None | ||
|
||
result = pex_execute_cowsay( | ||
"--pip-version", str(incompatible_pip_version), "--no-allow-pip-version-fallback" | ||
) | ||
result.assert_failure() | ||
assert result.error.endswith( | ||
expected_incompatible_pip_message(incompatible_pip_version) | ||
), result.error |
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