From befa9bb3efb5e5b16f5532c9e0ff32423611d61d Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 12:11:00 -0700 Subject: [PATCH 1/8] Add 3.11 support. Fixes #1747 --- .github/workflows/ci.yml | 19 +++++++++------ pex/interpreter_constraints.py | 8 +++---- pex/result.py | 4 +++- pyproject.toml | 3 ++- scripts/typecheck.sh | 3 +++ tests/bin/test_sh_boot.py | 2 ++ .../cli/commands/test_issue_1711.py | 6 +++-- .../cli/commands/test_issue_1741.py | 4 ++++ tests/integration/cli/commands/test_lock.py | 15 ++++++++---- tests/integration/test_integration.py | 24 +++++-------------- tests/integration/test_issue_1597.py | 2 +- tests/integration/test_issue_1656.py | 14 ++++++++++- tests/integration/test_issue_1726.py | 16 +++++++++---- tests/integration/test_issue_539.py | 14 ++++++----- tests/integration/test_lock_resolver.py | 9 +++++-- tests/integration/test_reproducible.py | 12 ++++++++++ tests/test_targets.py | 9 +++---- tox.ini | 2 +- 18 files changed, 110 insertions(+), 56 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a4c05ea2e..890d8c88a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: with: fetch-depth: ${{ matrix.fetch-depth }} - name: Setup Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "${{ matrix.python-version }}" - name: Check ${{ matrix.check-name }} @@ -65,7 +65,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [[2, 7], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]] + python-version: [[2, 7], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11]] os: [ubuntu-20.04, macos-10.15] exclude: - os: macos-10.15 @@ -78,6 +78,8 @@ jobs: python-version: [3, 8] - os: macos-10.15 python-version: [3, 9] + - os: macos-10.15 + python-version: [3, 11] steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose @@ -90,7 +92,7 @@ jobs: - name: Checkout Pex uses: actions/checkout@v2 - name: Setup Python ${{ join(matrix.python-version, '.') }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "${{ join(matrix.python-version, '.') }}" - name: Expose Pythons @@ -125,7 +127,7 @@ jobs: - name: Checkout Pex uses: actions/checkout@v2 - name: Setup PyPy ${{ join(matrix.pypy-version, '.') }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "pypy-${{ join(matrix.pypy-version, '.') }}" - name: Expose Pythons @@ -147,8 +149,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [[2, 7], [3, 10]] + python-version: [[2, 7], [3, 10], [3, 11]] os: [ubuntu-20.04, macos-10.15] + exclude: + - os: macos-10.15 + python-version: [3, 11] steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose @@ -161,7 +166,7 @@ jobs: - name: Checkout Pex uses: actions/checkout@v2 - name: Setup Python ${{ join(matrix.python-version, '.') }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "${{ join(matrix.python-version, '.') }}" - name: Expose Pythons @@ -196,7 +201,7 @@ jobs: - name: Checkout Pex uses: actions/checkout@v2 - name: Setup PyPy ${{ join(matrix.pypy-version, '.') }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v3 with: python-version: "pypy-${{ join(matrix.pypy-version, '.') }}" - name: Expose Pythons diff --git a/pex/interpreter_constraints.py b/pex/interpreter_constraints.py index b09b62558..9ff6d13c1 100644 --- a/pex/interpreter_constraints.py +++ b/pex/interpreter_constraints.py @@ -189,10 +189,10 @@ def iter_compatible_versions( # N.B.: Pex does not support the missing 3.x versions here. PythonVersion(Lifecycle.EOL, 3, 5, 10), PythonVersion(Lifecycle.EOL, 3, 6, 15), - PythonVersion(Lifecycle.STABLE, 3, 7, 12), - PythonVersion(Lifecycle.STABLE, 3, 8, 12), - PythonVersion(Lifecycle.STABLE, 3, 9, 10), - PythonVersion(Lifecycle.STABLE, 3, 10, 2), + PythonVersion(Lifecycle.STABLE, 3, 7, 13), + PythonVersion(Lifecycle.STABLE, 3, 8, 13), + PythonVersion(Lifecycle.STABLE, 3, 9, 12), + PythonVersion(Lifecycle.STABLE, 3, 10, 4), PythonVersion(Lifecycle.DEV, 3, 11, 0), ) diff --git a/pex/result.py b/pex/result.py index 163c89b97..7b537fc3e 100644 --- a/pex/result.py +++ b/pex/result.py @@ -56,7 +56,9 @@ def __init__( super(Error, self).__init__(exit_code=exit_code, message=message) -@attr.s(frozen=True) +# Frozen exception types don't work under 3.11.0b1 which sets the `__traceback__` attribute after +# construction in some cases. +@attr.s class ResultError(Exception): """Wraps an Error in an exception for use in short-circuiting via `try_` / `catch`.""" diff --git a/pyproject.toml b/pyproject.toml index 0a982ff4e..78211df82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ classifiers = [ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Build Tools", @@ -32,7 +33,7 @@ classifiers = [ "Topic :: System :: Software Distribution", "Topic :: Utilities", ] -requires-python = ">=2.7,<3.11,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" +requires-python = ">=2.7,<3.12,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*" [tool.flit.metadata.requires-extra] # For improved subprocess robustness under python2.7. diff --git a/scripts/typecheck.sh b/scripts/typecheck.sh index fa2af7c61..d6bb16ac2 100755 --- a/scripts/typecheck.sh +++ b/scripts/typecheck.sh @@ -10,6 +10,9 @@ FILES_TO_CHECK=( ) ) +echo "Typechecking using $(python --version) against Python 3.11 ..." +mypy --python-version 3.11 "${FILES_TO_CHECK[@]}" + echo "Typechecking using $(python --version) against Python 3.10 ..." mypy --python-version 3.10 "${FILES_TO_CHECK[@]}" diff --git a/tests/bin/test_sh_boot.py b/tests/bin/test_sh_boot.py index a577fc46f..f509c7d70 100644 --- a/tests/bin/test_sh_boot.py +++ b/tests/bin/test_sh_boot.py @@ -64,6 +64,7 @@ def expected(*names): all_names.add(current_interpreter_identity.binary_name(version_components=2)) all_names.update( [ + "python3.11", "python3.10", "python3.9", "python3.8", @@ -71,6 +72,7 @@ def expected(*names): "python3.6", "python3.5", "python2.7", + "pypy3.11", "pypy3.10", "pypy3.9", "pypy3.8", diff --git a/tests/integration/cli/commands/test_issue_1711.py b/tests/integration/cli/commands/test_issue_1711.py index 5733864a7..1d722a042 100644 --- a/tests/integration/cli/commands/test_issue_1711.py +++ b/tests/integration/cli/commands/test_issue_1711.py @@ -11,7 +11,7 @@ from pex.resolve import lockfile from pex.resolve.locked_resolve import Artifact, LockedRequirement from pex.resolve.resolved_requirement import Fingerprint -from pex.testing import run_pex_command +from pex.testing import PY_VER, run_pex_command from pex.typing import TYPE_CHECKING if TYPE_CHECKING: @@ -88,7 +88,9 @@ def assert_psutil_basics(): # differently - likely because of some collection implementation difference. if PY3: run_pex_command( - args=["pex==2.1.77", "-c", "pex3", "--"] + create_lock_args + args=["pex==2.1.77", "-c", "pex3", "--"] + create_lock_args, + # N.B.: Pex 2.1.77 only works on Python 3.10 and older. + python=py37.binary if PY_VER > (3, 10) else None, ).assert_success() psutil_old = assert_psutil_basics() assert 0 == len(psutil_old.additional_artifacts), ( diff --git a/tests/integration/cli/commands/test_issue_1741.py b/tests/integration/cli/commands/test_issue_1741.py index 9e71f6da7..c932735da 100644 --- a/tests/integration/cli/commands/test_issue_1741.py +++ b/tests/integration/cli/commands/test_issue_1741.py @@ -7,6 +7,7 @@ import pytest from pex.cli.testing import run_pex3 +from pex.interpreter import PythonInterpreter from pex.pep_440 import Version from pex.pep_503 import ProjectName from pex.resolve.lockfile import json_codec @@ -22,6 +23,7 @@ ) def test_prereleases( tmpdir, # type: Any + py310, # type: PythonInterpreter ): # type: (...) -> None @@ -58,6 +60,8 @@ def test_prereleases( # 1st prove this does the wrong thing on prior broken versions of Pex. result = run_pex_command( args=["pex==2.1.83", "-c", "pex", "--"] + use_lock_args, + # N.B.: Pex 2.1.88 only works on Python 3.10 and older. + python=py310.binary if PY_VER > (3, 10) else None, quiet=True, ) result.assert_failure() diff --git a/tests/integration/cli/commands/test_lock.py b/tests/integration/cli/commands/test_lock.py index e3dc07d3c..a6260b19d 100644 --- a/tests/integration/cli/commands/test_lock.py +++ b/tests/integration/cli/commands/test_lock.py @@ -1,7 +1,6 @@ # Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). -import hashlib import os import re import subprocess @@ -175,20 +174,28 @@ def test_create_local_unsupported(pex_project_dir): ) == result.error -def test_create_vcs(tmpdir): - # type: (Any) -> None +def test_create_vcs( + tmpdir, # type: Any + py310, # type: str +): + # type: (...) -> None + + # N.B.: The VCS Pex below only works on Python 3.10 and older. + python = py310 if PY_VER > (3, 10) else sys.executable lock = os.path.join(str(tmpdir), "lock") run_pex3( "lock", "create", + "--python", + python, "pex @ git+https://github.com/pantsbuild/pex@473c6ac7", "git+https://github.com/VaasuDevanS/cowsay-python@v3.0#egg=cowsay", "-o", lock, ).assert_success() pex_file = os.path.join(str(tmpdir), "pip-pex.pex") - run_pex_command(args=["--lock", lock, "-o", pex_file]).assert_success() + run_pex_command(args=["--lock", lock, "-o", pex_file], python=python).assert_success() assert ( "3.0" diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index f4f2a34e0..ded589286 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -1333,7 +1333,7 @@ def test_tmpdir_file(tmp_workdir): EXAMPLE_PYTHON_REQUIREMENTS_URL = ( "https://raw.githubusercontent.com/pantsbuild/example-python/" - "c6052498f25a436f2639ccd0bc846cec1a55d7d5" + "68387a9f5f1a1cb288820f8ebb5d6f66d95c888a" "/requirements.txt" ) @@ -1369,10 +1369,9 @@ def req( ), ) assert [ - req("ansicolors>=1.0.2", 4), - req("setuptools>=42.0.0", 5), - req("translate>=3.2.1", 6), - req("protobuf>=3.11.3", 7), + req("ansicolors==1.1.8", 4), + req("setuptools>=56.2.0,<57", 5), + req("types-setuptools>=56.2.0,<58", 6), ] == list(reqs) @@ -1554,21 +1553,10 @@ def test_pip_issues_9420_workaround(): def test_requirement_file_from_url(tmpdir): # type: (Any) -> None - constraints = os.path.join(str(tmpdir), "constraints.txt") - with open(constraints, "w") as fp: - print("translate>=3.2.1,<3.6.0", file=fp) - print("protobuf<=3.17.3", file=fp) - print("setuptools<60", file=fp) - pex_file = os.path.join(str(tmpdir), "pex") - - results = run_pex_command( - args=["-r", EXAMPLE_PYTHON_REQUIREMENTS_URL, "--constraints", constraints, "-o", pex_file] - ) + results = run_pex_command(args=["-r", EXAMPLE_PYTHON_REQUIREMENTS_URL, "-o", pex_file]) results.assert_success() - output, returncode = run_simple_pex( - pex_file, args=["-c", "import colors, google.protobuf, setuptools, translate"] - ) + output, returncode = run_simple_pex(pex_file, args=["-c", "import colors, setuptools"]) assert 0 == returncode, output assert b"" == output diff --git a/tests/integration/test_issue_1597.py b/tests/integration/test_issue_1597.py index 0fb9cb063..1bf37ee1e 100644 --- a/tests/integration/test_issue_1597.py +++ b/tests/integration/test_issue_1597.py @@ -20,7 +20,7 @@ def build_pex( args, # type: List[str] - marker='python_full_version == "{python_full_version}"'.format( + marker='python_full_version >= "{python_full_version}"'.format( python_full_version=platform.python_version() ), # type: str ): diff --git a/tests/integration/test_issue_1656.py b/tests/integration/test_issue_1656.py index 7a7fbebf2..3d43c5e9d 100644 --- a/tests/integration/test_issue_1656.py +++ b/tests/integration/test_issue_1656.py @@ -9,7 +9,7 @@ from pex.interpreter import PythonInterpreter from pex.pex_info import PexInfo -from pex.testing import make_env, run_pex_command +from pex.testing import PY_VER, make_env, run_pex_command from pex.typing import TYPE_CHECKING if TYPE_CHECKING: @@ -39,6 +39,15 @@ def old_pex(tmpdir_factory): return pex_file +skip_for_newer_than_310 = pytest.mark.skipif( + PY_VER > (3, 10), + reason=( + "This test exercises compatibility with old Pex versions but those do not work on " + "anything newer than Python 3.10." + ), +) + + def run_current_pex_tool( subject_pex, # type: str subcommand, # type: str @@ -63,6 +72,7 @@ def run_pex_tool( ).decode("utf-8") +@skip_for_newer_than_310 def test_old_venv_tool_vs_new_pex( tmpdir, # type: Any old_pex, # type: str @@ -77,6 +87,7 @@ def test_old_venv_tool_vs_new_pex( assert b"4.0\n" == subprocess.check_output(args=[os.path.join(venv, "pex"), "--version"]) +@skip_for_newer_than_310 def test_new_venv_tool_vs_old_pex( tmpdir, # type: Any old_pex, # type: str @@ -91,6 +102,7 @@ def test_new_venv_tool_vs_old_pex( assert b"4.0\n" == subprocess.check_output(args=[os.path.join(venv, "pex"), "--version"]) +@skip_for_newer_than_310 def test_mixed_pex_root( tmpdir, # type: Any old_pex, # type: str diff --git a/tests/integration/test_issue_1726.py b/tests/integration/test_issue_1726.py index 9cd548f20..3777435e5 100644 --- a/tests/integration/test_issue_1726.py +++ b/tests/integration/test_issue_1726.py @@ -10,7 +10,8 @@ import pytest from pex.common import safe_open -from pex.testing import run_pex_command +from pex.interpreter import PythonInterpreter +from pex.testing import PY_VER, run_pex_command from pex.typing import TYPE_CHECKING if TYPE_CHECKING: @@ -21,8 +22,11 @@ sys.version_info[:2] < (3, 7), reason="The jaraco-collections 3.5.1 distribution requires Python >=3.7", ) -def test_check_install_issue_1726(tmpdir): - # type: (Any) -> None +def test_check_install_issue_1726( + tmpdir, # type: Any + py310, # type: PythonInterpreter +): + # type: (...) -> None src = os.path.join(str(tmpdir), "src") with safe_open(os.path.join(src, "setup.py"), "w") as fp: @@ -53,7 +57,11 @@ def test_check_install_issue_1726(tmpdir): "-c", "from jaraco import collections; print(collections.__file__)", ] - old_result = run_pex_command(args=["pex==2.1.80", "-c", "pex", "--"] + pex_args) + old_result = run_pex_command( + args=["pex==2.1.80", "-c", "pex", "--"] + pex_args, + # N.B.: Pex 2.1.80 only works on Python 3.10 and older. + python=py310.binary if PY_VER > (3, 10) else None, + ) old_result.assert_failure() assert ( "Failed to resolve compatible distributions:\n" diff --git a/tests/integration/test_issue_539.py b/tests/integration/test_issue_539.py index ad090e4a6..8e7d4f21b 100644 --- a/tests/integration/test_issue_539.py +++ b/tests/integration/test_issue_539.py @@ -9,14 +9,16 @@ from pex.common import temporary_dir from pex.pip.tool import get_pip -from pex.testing import IS_PYPY, run_pex_command +from pex.testing import IS_PYPY, PY_VER, run_pex_command @pytest.mark.skipif( - IS_PYPY, - reason="The cryptography 2.6.1 project only has pre-built wheels for CPython " - "available on PyPI and this test relies upon a pre-built wheel being " - "available.", + IS_PYPY or PY_VER > (3, 10), + reason=( + "The cryptography 2.6.1 project only has pre-built wheels for CPython <= 3.10 " + "available on PyPI and this test relies upon a pre-built wheel being " + "available." + ), ) def test_abi3_resolution(): # type: () -> None @@ -27,7 +29,7 @@ def test_abi3_resolution(): # cryptography-2.6.1-cp34-abi3-macosx_10_6_intel.whl # cryptography-2.6.1-cp34-abi3-manylinux1_x86_64.whl # With pex in --no-build mode, we force a test that pex abi3 resolution works when this test is - # run under CPython>3.4,<4 on OSX and linux. + # run under CPython>3.4,<3.11 on OSX and linux. with temporary_dir() as td: # The dependency graph for cryptography-2.6.1 includes pycparser which is only released as an diff --git a/tests/integration/test_lock_resolver.py b/tests/integration/test_lock_resolver.py index 4fdb234f5..153796b92 100644 --- a/tests/integration/test_lock_resolver.py +++ b/tests/integration/test_lock_resolver.py @@ -22,7 +22,7 @@ from pex.pex_info import PexInfo from pex.resolve import lockfile from pex.resolve.locked_resolve import LockedRequirement -from pex.testing import built_wheel, make_env, run_pex_command +from pex.testing import PY_VER, built_wheel, make_env, run_pex_command from pex.typing import TYPE_CHECKING from pex.util import CacheHelper @@ -394,6 +394,7 @@ def test_issue_1413_portable_find_links(tmpdir): def test_issue_1717_transitive_extras( tmpdir, # type: Any + py310, # type: PythonInterpreter ): # type: (...) -> None @@ -481,7 +482,11 @@ def assert_dists( ProjectNameAndVersion.from_filename(d).project_name for d in pex_info.distributions } - run_pex_command(args=["pex==2.1.78", "-cpex", "--"] + create_pex_args).assert_success() + run_pex_command( + args=["pex==2.1.78", "-cpex", "--"] + create_pex_args, + # N.B.: Pex 2.1.78 only works on Python 3.10 and older. + python=py310.binary if PY_VER > (3, 10) else None, + ).assert_success() pex_info = PexInfo.from_pex(pex) assert_requirements(pex_info) assert_dists(pex_info, "root", "middle_man_with_extras", "A", "B", "C") diff --git a/tests/integration/test_reproducible.py b/tests/integration/test_reproducible.py index e62bcd7df..5e8cb2e7f 100644 --- a/tests/integration/test_reproducible.py +++ b/tests/integration/test_reproducible.py @@ -7,12 +7,15 @@ from textwrap import dedent from zipfile import ZipFile +import pytest + from pex.common import temporary_dir from pex.compatibility import PY2 from pex.testing import ( PY27, PY37, PY310, + PY_VER, create_pex_command, ensure_python_interpreter, run_command_with_jitter, @@ -93,6 +96,15 @@ def test_reproducible_build_no_args(): assert_reproducible_build([], pythons=MIXED_MAJOR_PYTHONS) +@pytest.mark.skipif( + PY_VER > (3, 10), + reason=( + "There are no pre-built binaries for the cryptograph transitive dependency graph (cffi in " + "particular); so this test fails under Python 3.11+ since it requires building an sdist " + "and that leads to an underlying C `.so` build that we have insufficient control over to " + "make reproducible." + ), +) def test_reproducible_build_bdist_requirements(): # type: () -> None # We test both a pure Python wheel (six) and a platform-specific wheel (cryptography). diff --git a/tests/test_targets.py b/tests/test_targets.py index f99daac8e..40ec0e022 100644 --- a/tests/test_targets.py +++ b/tests/test_targets.py @@ -113,6 +113,7 @@ def test_requires_python_current(): current_target = targets.current() major, minor, patch = current_target.interpreter.version + patch_is_zero = 0 == patch def requires_python(template): # type: (str) -> str @@ -132,25 +133,25 @@ def assert_requires_python( assert_requires_python(True, "~={major}.{minor}") assert_requires_python(True, "=={major}.{minor}.*") - assert_requires_python(False, "=={major}.{minor}") + assert_requires_python(patch_is_zero, "=={major}.{minor}") assert_requires_python(True, "=={major}.{minor}.{patch}") assert_requires_python(True, "!={major}") assert_requires_python(False, "!={major}.*") - assert_requires_python(True, "!={major}.{minor}") + assert_requires_python(not patch_is_zero, "!={major}.{minor}") assert_requires_python(False, "!={major}.{minor}.*") assert_requires_python(False, "!={major}.{minor}.{patch}") assert_requires_python(False, "<{major}") assert_requires_python(False, "<={major}") assert_requires_python(False, "<{major}.{minor}") - assert_requires_python(False, "<={major}.{minor}") + assert_requires_python(patch_is_zero, "<={major}.{minor}") assert_requires_python(False, "<{major}.{minor}.{patch}") assert_requires_python(True, "<={major}.{minor}.{patch}") assert_requires_python(True, ">{major}") assert_requires_python(True, ">={major}") - assert_requires_python(True, ">{major}.{minor}") + assert_requires_python(not patch_is_zero, ">{major}.{minor}") assert_requires_python(True, ">={major}.{minor}") assert_requires_python(False, ">{major}.{minor}.{patch}") assert_requires_python(True, ">={major}.{minor}.{patch}") diff --git a/tox.ini b/tox.ini index de6a07f5e..20ce4216f 100644 --- a/tox.ini +++ b/tox.ini @@ -49,7 +49,7 @@ whitelist_externals = bash git -[testenv:py{py,py-subprocess,py2,py2-subprocess,py3,27,35,36,37,38,39,310}-integration] +[testenv:py{py,py-subprocess,py2,py2-subprocess,py3,27,35,36,37,38,39,310,311}-integration] deps = pytest-xdist==1.34.0 {[testenv]deps} From b1b0f403e44d10237b5ce6b165224f56f983ee83 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 12:15:38 -0700 Subject: [PATCH 2/8] Fix unused import --- tests/integration/cli/commands/test_lock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/cli/commands/test_lock.py b/tests/integration/cli/commands/test_lock.py index a6260b19d..1ff80d1c7 100644 --- a/tests/integration/cli/commands/test_lock.py +++ b/tests/integration/cli/commands/test_lock.py @@ -38,7 +38,7 @@ from pex.version import __version__ if TYPE_CHECKING: - from typing import Any, Optional + from typing import Any import attr # vendor:skip else: From 18e3e3ab544e277ba39442344f6b798231163f33 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 12:24:02 -0700 Subject: [PATCH 3/8] Fixup tox env names to ignore extra version info. --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 890d8c88a..0f6c312bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,12 +60,12 @@ jobs: with: tox-env: ${{ matrix.tox-env }} cpython-unit-tests: - name: (${{ matrix.os }}) TOXENV=py${{ join(matrix.python-version, '') }} + name: (${{ matrix.os }}) TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }} needs: org-check runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [[2, 7], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11]] + python-version: [[2, 7], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11, "0-beta.1"]] os: [ubuntu-20.04, macos-10.15] exclude: - os: macos-10.15 @@ -79,7 +79,7 @@ jobs: - os: macos-10.15 python-version: [3, 9] - os: macos-10.15 - python-version: [3, 11] + python-version: [3, 11, "0-beta.1"] steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose @@ -107,7 +107,7 @@ jobs: - name: Run Unit Tests uses: pantsbuild/actions/run-tox@95209b287c817c78a765962d40ac6cea790fc511 with: - tox-env: py${{ join(matrix.python-version, '') }} + tox-env: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }} pypy-unit-tests: name: (PyPy ${{ join(matrix.pypy-version, '.') }}) TOXENV=pypy${{ matrix.pypy-version[0] }} needs: org-check @@ -144,16 +144,16 @@ jobs: with: tox-env: pypy${{ matrix.pypy-version[0] }} cpython-integration-tests: - name: (${{ matrix.os }}) TOXENV=py${{ join(matrix.python-version, '') }}-integration + name: (${{ matrix.os }}) TOXENV=py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-integration needs: org-check runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [[2, 7], [3, 10], [3, 11]] + python-version: [[2, 7], [3, 10], [3, 11, "0-beta.1"]] os: [ubuntu-20.04, macos-10.15] exclude: - os: macos-10.15 - python-version: [3, 11] + python-version: [3, 11, "0-beta.1"] steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose @@ -181,7 +181,7 @@ jobs: - name: Run Integration Tests uses: pantsbuild/actions/run-tox@95209b287c817c78a765962d40ac6cea790fc511 with: - tox-env: py${{ join(matrix.python-version, '') }}-integration + tox-env: py${{ matrix.python-version[0] }}${{ matrix.python-version[1] }}-integration pypy-integration-tests: name: (PyPy ${{ join(matrix.pypy-version, '.') }}) TOXENV=pypy${{ matrix.pypy-version[0] }}-integration needs: org-check From c9ab0bec922c7c57b22206ae3670448ec08368fe Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 12:57:41 -0700 Subject: [PATCH 4/8] Skip test_requirements_network_configuration for <= 3.5. --- tests/integration/test_integration.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index ded589286..362f002cb 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -40,7 +40,7 @@ run_pex_command, run_simple_pex, run_simple_pex_test, - temporary_content, + temporary_content, PY_VER, ) from pex.third_party import pkg_resources from pex.third_party.pkg_resources import Requirement @@ -1550,6 +1550,10 @@ def test_pip_issues_9420_workaround(): ) +@pytest.mark.skipif( + PY_VER <= (3, 5), + reason="The example python requirements URL has requirements that only work with Pythin 3.6+." +) def test_requirement_file_from_url(tmpdir): # type: (Any) -> None From 6f9081139e951fc6ae40f5f426182dffc4180ca5 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 12:59:31 -0700 Subject: [PATCH 5/8] Fix formatting. --- tests/integration/test_integration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 362f002cb..066904e87 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -31,6 +31,7 @@ PY27, PY37, PY310, + PY_VER, IntegResults, WheelBuilder, built_wheel, @@ -40,7 +41,7 @@ run_pex_command, run_simple_pex, run_simple_pex_test, - temporary_content, PY_VER, + temporary_content, ) from pex.third_party import pkg_resources from pex.third_party.pkg_resources import Requirement @@ -1552,7 +1553,7 @@ def test_pip_issues_9420_workaround(): @pytest.mark.skipif( PY_VER <= (3, 5), - reason="The example python requirements URL has requirements that only work with Pythin 3.6+." + reason="The example python requirements URL has requirements that only work with Pythin 3.6+.", ) def test_requirement_file_from_url(tmpdir): # type: (Any) -> None From 09eb7b1efb7da52083290deb9819315188c08986 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 13:43:30 -0700 Subject: [PATCH 6/8] Stabilize 3.11 test variants. --- tests/integration/cli/commands/test_lock.py | 10 ++++++---- tests/integration/test_lock_resolver.py | 11 ++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tests/integration/cli/commands/test_lock.py b/tests/integration/cli/commands/test_lock.py index 1ff80d1c7..88b96ba39 100644 --- a/tests/integration/cli/commands/test_lock.py +++ b/tests/integration/cli/commands/test_lock.py @@ -197,15 +197,17 @@ def test_create_vcs( pex_file = os.path.join(str(tmpdir), "pip-pex.pex") run_pex_command(args=["--lock", lock, "-o", pex_file], python=python).assert_success() - assert ( - "3.0" - == subprocess.check_output(args=[pex_file, "--version"], env=make_env(PEX_SCRIPT="cowsay")) + output = ( + subprocess.check_output( + args=[python, pex_file, "--version"], env=make_env(PEX_SCRIPT="cowsay") + ) .decode("utf-8") .strip() ) + assert "3.0" == output, output process = subprocess.Popen( - args=[pex_file, "-V"], + args=[python, pex_file, "-V"], env=make_env(PEX_SCRIPT="pex"), stdout=subprocess.PIPE, stderr=subprocess.PIPE, diff --git a/tests/integration/test_lock_resolver.py b/tests/integration/test_lock_resolver.py index 153796b92..239245e14 100644 --- a/tests/integration/test_lock_resolver.py +++ b/tests/integration/test_lock_resolver.py @@ -7,6 +7,7 @@ import re import shutil import subprocess +import sys from textwrap import dedent import colors @@ -482,16 +483,16 @@ def assert_dists( ProjectNameAndVersion.from_filename(d).project_name for d in pex_info.distributions } + # N.B.: Pex 2.1.78 only works on Python 3.10 and older. + python = py310.binary if PY_VER > (3, 10) else sys.executable run_pex_command( - args=["pex==2.1.78", "-cpex", "--"] + create_pex_args, - # N.B.: Pex 2.1.78 only works on Python 3.10 and older. - python=py310.binary if PY_VER > (3, 10) else None, + args=["pex==2.1.78", "-cpex", "--"] + create_pex_args, python=python ).assert_success() pex_info = PexInfo.from_pex(pex) assert_requirements(pex_info) assert_dists(pex_info, "root", "middle_man_with_extras", "A", "B", "C") - process = subprocess.Popen(args=test_pex_args, stderr=subprocess.PIPE) + process = subprocess.Popen(args=[python] + test_pex_args, stderr=subprocess.PIPE) _, stderr = process.communicate() assert 0 != process.returncode @@ -515,7 +516,7 @@ def assert_dists( stderr.decode("utf-8"), ) is not None - ) + ), stderr.decode("utf-8") run_pex_command(args=create_pex_args).assert_success() pex_info = PexInfo.from_pex(pex) From f55b6c89ad5bf23c96ccee989c141b90bd162fd3 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 13:44:29 -0700 Subject: [PATCH 7/8] Fix typo. --- tests/integration/test_integration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 066904e87..d736d029b 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -1553,7 +1553,7 @@ def test_pip_issues_9420_workaround(): @pytest.mark.skipif( PY_VER <= (3, 5), - reason="The example python requirements URL has requirements that only work with Pythin 3.6+.", + reason="The example python requirements URL has requirements that only work with Python 3.6+.", ) def test_requirement_file_from_url(tmpdir): # type: (Any) -> None From f260ad41bf3880dec0321f9825c7407aa8286e96 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Sun, 15 May 2022 13:49:36 -0700 Subject: [PATCH 8/8] Fix shadowing vs types. --- tests/integration/cli/commands/test_lock.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/cli/commands/test_lock.py b/tests/integration/cli/commands/test_lock.py index 88b96ba39..4eca502cc 100644 --- a/tests/integration/cli/commands/test_lock.py +++ b/tests/integration/cli/commands/test_lock.py @@ -197,14 +197,14 @@ def test_create_vcs( pex_file = os.path.join(str(tmpdir), "pip-pex.pex") run_pex_command(args=["--lock", lock, "-o", pex_file], python=python).assert_success() - output = ( + version_output = ( subprocess.check_output( args=[python, pex_file, "--version"], env=make_env(PEX_SCRIPT="cowsay") ) .decode("utf-8") .strip() ) - assert "3.0" == output, output + assert "3.0" == version_output, version_output process = subprocess.Popen( args=[python, pex_file, "-V"],