Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 3.11 support. #1766

Merged
merged 8 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ 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 }}
uses: pantsbuild/actions/run-tox@95209b287c817c78a765962d40ac6cea790fc511
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]]
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
Expand All @@ -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, "0-beta.1"]
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand All @@ -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
Expand All @@ -105,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
Expand All @@ -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
Expand All @@ -142,13 +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]]
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, "0-beta.1"]
steps:
- name: Calculate Pythons to Expose
id: calculate-pythons-to-expose
Expand All @@ -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
Expand All @@ -176,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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pex/interpreter_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)

Expand Down
4 changes: 3 additions & 1 deletion pex/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ 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",
"Topic :: System :: Archiving :: Packaging",
"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.
Expand Down
3 changes: 3 additions & 0 deletions scripts/typecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}"

Expand Down
2 changes: 2 additions & 0 deletions tests/bin/test_sh_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ 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",
"python3.7",
"python3.6",
"python3.5",
"python2.7",
"pypy3.11",
"pypy3.10",
"pypy3.9",
"pypy3.8",
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/cli/commands/test_issue_1711.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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), (
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/cli/commands/test_issue_1741.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,6 +23,7 @@
)
def test_prereleases(
tmpdir, # type: Any
py310, # type: PythonInterpreter
):
# type: (...) -> None

Expand Down Expand Up @@ -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()
Expand Down
27 changes: 18 additions & 9 deletions tests/integration/cli/commands/test_lock.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -39,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:
Expand Down Expand Up @@ -175,30 +174,40 @@ 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"
== subprocess.check_output(args=[pex_file, "--version"], env=make_env(PEX_SCRIPT="cowsay"))
version_output = (
subprocess.check_output(
args=[python, pex_file, "--version"], env=make_env(PEX_SCRIPT="cowsay")
)
.decode("utf-8")
.strip()
)
assert "3.0" == version_output, version_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,
Expand Down
29 changes: 11 additions & 18 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
PY27,
PY37,
PY310,
PY_VER,
IntegResults,
WheelBuilder,
built_wheel,
Expand Down Expand Up @@ -1333,7 +1334,7 @@ def test_tmpdir_file(tmp_workdir):

EXAMPLE_PYTHON_REQUIREMENTS_URL = (
"https://raw.githubusercontent.com/pantsbuild/example-python/"
"c6052498f25a436f2639ccd0bc846cec1a55d7d5"
"68387a9f5f1a1cb288820f8ebb5d6f66d95c888a"
"/requirements.txt"
)

Expand Down Expand Up @@ -1369,10 +1370,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)


Expand Down Expand Up @@ -1551,24 +1551,17 @@ 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 Python 3.6+.",
)
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

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_issue_1597.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down
Loading