From 22e651589b3f2da26da6786dcbd1553fd7c8d4a6 Mon Sep 17 00:00:00 2001 From: John Sirois Date: Wed, 26 Oct 2022 18:39:03 -0700 Subject: [PATCH] Finalize 3.11 in CI. (#1966) --- .github/workflows/ci.yml | 22 ++++++---------- .github/workflows/release.yml | 8 +++--- tests/integration/test_setproctitle.py | 35 ++++++++++++++++++++++---- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1137aa117..6099cc22d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,20 +58,17 @@ jobs: python-version: [ 3, 5 ] pip-version: 20 - os: macos-11 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 20 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 20 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 22_2 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 22_3 - - os: ubuntu-20.04 - python-version: [ 3, 11, "0-rc.2" ] - pip-version: 20 steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose @@ -163,20 +160,17 @@ jobs: python-version: [ 3, 7 ] pip-version: 22_3 - os: macos-11 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 20 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 20 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 22_2 - os: ubuntu-20.04 - python-version: [ 3, 10 ] + python-version: [ 3, 11 ] pip-version: 22_3 - - os: ubuntu-20.04 - python-version: [ 3, 11, "0-rc.2" ] - pip-version: 20 steps: - name: Calculate Pythons to Expose id: calculate-pythons-to-expose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 43ecc09d6..d6bc65321 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -49,10 +49,10 @@ jobs: uses: actions/checkout@v3 with: ref: ${{ needs.determine-tag.outputs.release-tag }} - - name: Setup Python 3.10 + - name: Setup Python 3.11 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Publish Pex ${{ needs.determine-tag.outputs.release-tag }} uses: pantsbuild/actions/run-tox@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb env: @@ -72,10 +72,10 @@ jobs: ref: ${{ needs.determine-tag.outputs.release-tag }} # This ensures we get all branches and tags which is needed for `tox -e package`. fetch-depth: 0 - - name: Setup Python 3.10 + - name: Setup Python 3.11 uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Package Pex ${{ needs.determine-tag.outputs.release-tag }} PEX uses: pantsbuild/actions/run-tox@e63d2d0e3c339bdffbe5e51e7c39550e3bc527bb with: diff --git a/tests/integration/test_setproctitle.py b/tests/integration/test_setproctitle.py index 142079533..49c009fbc 100644 --- a/tests/integration/test_setproctitle.py +++ b/tests/integration/test_setproctitle.py @@ -3,6 +3,7 @@ import os.path import subprocess import sys +import sysconfig from textwrap import dedent from typing import Text @@ -10,10 +11,11 @@ from pex import variables from pex.common import safe_open +from pex.compatibility import commonpath from pex.interpreter import PythonInterpreter from pex.layout import Layout from pex.pex_info import PexInfo -from pex.testing import run_pex_command +from pex.testing import IS_MAC, run_pex_command from pex.typing import TYPE_CHECKING if TYPE_CHECKING: @@ -90,10 +92,33 @@ def grab_ps( def assert_expected_python(exe): # type: (Text) -> None - assert ( - PythonInterpreter.get().resolve_base_interpreter() - == PythonInterpreter.from_binary(str(exe)).resolve_base_interpreter() - ) + expected = PythonInterpreter.get().resolve_base_interpreter() + actual = PythonInterpreter.from_binary(str(exe)).resolve_base_interpreter() + python_framework = sysconfig.get_config_var("PYTHONFRAMEWORKINSTALLDIR") + if IS_MAC and expected != actual and python_framework: + # Mac framework Python distributions have two Python binaries (starred) as well as + # several symlinks. The layout looks like so: + # /Library/Frameworks/ + # Python.framework/ # sysconfig.get_config_var("PYTHONFRAMEWORKINSTALLDIR") + # Versions/X.Y/ # sys.prefix + # bin/ + # python -> pythonX.Y + # pythonX -> pythonX.Y + # *pythonX.Y + # Resources/Python.app/ + # Contents/MacOS/ + # *Python + # + # In some versions of Python, the bin Python, when executed, gets a sys.executable of + # the corresponding Python resource. On others, they each retain a sys.executable + # faithful to their launcher file path. It's the latter type we're working around here. + assert python_framework == commonpath( + (python_framework, expected.binary, actual.binary) + ) + assert expected.prefix == actual.prefix + assert expected.version == actual.version + else: + assert expected == actual pex_file = os.path.join(str(tmpdir), "pex.file") exe, args = grab_ps(pex_file)