diff --git a/.github/workflows/cache_comparison.yaml b/.github/workflows/cache_comparison.yaml index da1903a80c2..67410485b23 100644 --- a/.github/workflows/cache_comparison.yaml +++ b/.github/workflows/cache_comparison.yaml @@ -11,12 +11,20 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 10 - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - env: BASE_REF: ${{ github.event.inputs.base_ref }} BUILD_COMMIT: ${{ github.event.inputs.build_commit }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7b3936688f4..939eef23e4d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -374,12 +374,20 @@ jobs: fetch-depth: '0' fetch-tags: true ref: ${{ needs.release_info.outputs.build-ref }} - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Install Protoc uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 with: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f20359e3db..422f39fcfa7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -118,10 +118,20 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 10 - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Install Protoc uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 with: @@ -221,10 +231,20 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 10 - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Install Protoc uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 with: @@ -670,10 +690,20 @@ jobs: \ --max_size 30\necho \"PANTS_REMOTE_STORE_ADDRESS=grpc://localhost:9092\" >> \"$GITHUB_ENV\"\necho\ \ \"PANTS_REMOTE_CACHE_READ=true\" >> \"$GITHUB_ENV\"\necho \"PANTS_REMOTE_CACHE_WRITE=${CACHE_WRITE}\" >> \"$GITHUB_ENV\"\ \n" - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -850,12 +880,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -942,12 +980,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1034,12 +1080,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1126,12 +1180,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1218,12 +1280,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1310,12 +1380,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1402,12 +1480,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1494,12 +1580,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1586,12 +1680,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1678,12 +1780,20 @@ jobs: echo "${HOME}/.thrift" >> $GITHUB_PATH ' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: @@ -1737,12 +1847,20 @@ jobs: with: distribution: adopt java-version: '11' - - name: Set up Python 3.9 + - name: Set up Python 3.7, 3.8, 3.9, 3.10, 3.12, 3.11 uses: actions/setup-python@v5 with: - python-version: '3.9' - - name: Expose Pythons - uses: pantsbuild/actions/expose-pythons@v9 + python-version: '3.7 + + 3.8 + + 3.9 + + 3.10 + + 3.12 + + 3.11' - name: Download native binaries uses: actions/download-artifact@v4 with: diff --git a/src/python/pants/backend/python/util_rules/pex_test.py b/src/python/pants/backend/python/util_rules/pex_test.py index 08bd9ae2405..30290a05232 100644 --- a/src/python/pants/backend/python/util_rules/pex_test.py +++ b/src/python/pants/backend/python/util_rules/pex_test.py @@ -181,7 +181,7 @@ def test_pex_environment(rule_runner: RuleRunner, pex_type: type[Pex | VenvPex]) "--subprocess-environment-env-vars=LANG", # Value should come from environment. "--subprocess-environment-env-vars=ftp_proxy=dummyproxy", ), - interpreter_constraints=InterpreterConstraints(["CPython>=3.6"]), + interpreter_constraints=InterpreterConstraints(["CPython>=3.8"]), env={"LANG": "es_PY.UTF-8"}, ) @@ -232,7 +232,7 @@ def test_pex_working_directory(rule_runner: RuleRunner, pex_type: type[Pex | Ven pex_type=pex_type, main=EntryPoint("main"), sources=sources, - interpreter_constraints=InterpreterConstraints(["CPython>=3.6"]), + interpreter_constraints=InterpreterConstraints(["CPython>=3.8"]), ) pex_process_type = PexProcess if isinstance(pex_data.pex, Pex) else VenvPexProcess @@ -426,7 +426,7 @@ def test_entry_point(rule_runner: RuleRunner) -> None: def test_interpreter_constraints(rule_runner: RuleRunner) -> None: - constraints = InterpreterConstraints(["CPython>=2.7,<3", "CPython>=3.6,<3.12"]) + constraints = InterpreterConstraints(["CPython>=2.7,<3", "CPython>=3.8,<3.12"]) pex_info = create_pex_and_get_pex_info( rule_runner, interpreter_constraints=constraints, internal_only=False ) @@ -442,7 +442,7 @@ def test_platforms(rule_runner: RuleRunner) -> None: # We use Python 2.7, rather than Python 3, to ensure that the specified platform is # actually used. platforms = PexPlatforms(["linux-x86_64-cp-27-cp27mu"]) - constraints = InterpreterConstraints(["CPython>=2.7,<3", "CPython>=3.6"]) + constraints = InterpreterConstraints(["CPython>=2.7,<3", "CPython>=3.8"]) pex_data = create_pex_and_get_all_data( rule_runner, requirements=PexRequirements(["cryptography==2.9"]), diff --git a/src/python/pants_release/generate_github_workflows.py b/src/python/pants_release/generate_github_workflows.py index ab05fcbb561..a4e890a35a3 100644 --- a/src/python/pants_release/generate_github_workflows.py +++ b/src/python/pants_release/generate_github_workflows.py @@ -26,7 +26,6 @@ def action(name: str) -> str: "cache": "actions/cache@v4", "checkout": "actions/checkout@v4", "download-artifact": "actions/download-artifact@v4", - "expose-pythons": "pantsbuild/actions/expose-pythons@v9", "github-action-required-labels": "mheap/github-action-required-labels@v4.0.0", "rust-cache": "benjyw/rust-cache@5ed697a6894712d2854c80635bb00a2496ea307a", "setup-go": "actions/setup-go@v5", @@ -111,7 +110,8 @@ def hash_files(path: str) -> str: # We don't specify a patch version so that we get the latest, which comes pre-installed: # https://github.com/actions/setup-python#available-versions-of-python -PYTHON_VERSION = "3.9" +# NOTE: The last entry becomes the default +PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.12", "3.11"] DONT_SKIP_RUST = "needs.classify_changes.outputs.rust == 'true'" DONT_SKIP_WHEELS = "needs.classify_changes.outputs.release == 'true' || needs.classify_changes.outputs.ci_config == 'true'" @@ -348,11 +348,14 @@ def install_rustup() -> Step: } -def install_python(version: str) -> Step: +def install_pythons(versions: list[str]) -> Step: + # See: + # https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#specifying-multiple-pythonpypy-versions + # This is a list expressed as a newline delimited string instead of a... list return { - "name": f"Set up Python {version}", + "name": f"Set up Python {', '.join(versions)}", "uses": action("setup-python"), - "with": {"python-version": version}, + "with": {"python-version": "\n".join(versions)}, } @@ -555,27 +558,16 @@ def bootstrap_caches(self) -> Sequence[Step]: }, ] - def setup_primary_python(self) -> Sequence[Step]: + def setup_pythons(self) -> Sequence[Step]: ret = [] if self.platform not in HAS_PYTHON: - ret.append(install_python(PYTHON_VERSION)) - return ret - - def expose_all_pythons(self) -> Sequence[Step]: - ret = [] - if self.platform not in HAS_PYTHON: - ret.append( - { - "name": "Expose Pythons", - "uses": action("expose-pythons"), - } - ) + ret.append(install_pythons(PYTHON_VERSIONS)) return ret def bootstrap_pants(self) -> Sequence[Step]: return [ *checkout(), - *self.setup_primary_python(), + *self.setup_pythons(), *self.bootstrap_caches(), { "name": "Bootstrap Pants", @@ -770,8 +762,7 @@ def test_jobs( # preinstalled on the self-hosted runners. else [] ), - *helper.setup_primary_python(), - *helper.expose_all_pythons(), + *helper.setup_pythons(), *helper.native_binaries_download(), { "name": human_readable_step_name, @@ -881,7 +872,7 @@ def build_wheels_job( else: initial_steps = [ *checkout(ref=for_deploy_ref), - *helper.expose_all_pythons(), + *helper.setup_pythons(), # NB: We only cache Rust, but not `native_engine.so` and the Pants # virtualenv. This is because we must build both these things with # multiple Python versions, whereas that caching assumes only one primary @@ -1033,7 +1024,7 @@ def test_workflow_jobs() -> Jobs: "steps": [ *checkout(), *launch_bazel_remote(), - *linux_x86_64_helper.setup_primary_python(), + *linux_x86_64_helper.setup_pythons(), *linux_x86_64_helper.native_binaries_download(), { "name": "Lint", @@ -1109,8 +1100,7 @@ def cache_comparison_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]: "timeout-minutes": 90, "steps": [ *checkout(), - *helper.setup_primary_python(), - *helper.expose_all_pythons(), + *helper.setup_pythons(), { "name": "Prepare cache comparison", "run": dedent( @@ -1243,8 +1233,7 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]: "fetch-tags": True, }, }, - *helper.setup_primary_python(), - *helper.expose_all_pythons(), + *helper.setup_pythons(), *helper.bootstrap_caches(), { "name": "Generate announcement", @@ -1581,7 +1570,7 @@ def gen_goals(use_default_version: bool) -> Sequence[object]: "permissions": {}, "steps": [ *checkout(repository=repo.name, **repo.checkout_options), - install_python(repo.python_version), + install_pythons([repo.python_version]), *([install_go()] if repo.install_go else []), *([install_node(repo.node_version)] if repo.node_version else []), *([download_apache_thrift()] if repo.install_thrift else []),