From f9a6748154f0ae48eadc4e4f1e2c4f732acf29f7 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Tue, 14 Nov 2023 14:45:28 +0000 Subject: [PATCH] ci: Fix Python 2.7 builds on macOS 11 With current macOS 11 runner images (20231216.1) the `python` on `$PATH` is Python 3.12 and setuptools isn't installed by default. E.g. ``` python -mtox -e "py27-mode_localhost-ansible4" ========================== Starting Command Output =========================== /bin/bash --noprofile --norc /Users/runner/work/_temp/93a29c4c-f606-45e4-8dbd-a4a5f51b8730.sh GLOB sdist-make: /Users/runner/work/1/s/setup.py ERROR: invocation failed (exit code 1), logfile: /Users/runner/work/1/s/.tox/log/GLOB-0.log ================================== log start =================================== Traceback (most recent call last): File "/Users/runner/work/1/s/setup.py", line 32, in from setuptools import find_packages, setup ModuleNotFoundError: No module named 'setuptools' ``` Installing setuptools under Python 3.12 chooses package versions incompatible with Python 2.7. Additionally Mitogen isn't yet compatible with Python 3.12 (#1033), so tests that call a local context with `python` fail. --- .ci/azure-pipelines-steps.yml | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.ci/azure-pipelines-steps.yml b/.ci/azure-pipelines-steps.yml index ed516d72..88d219b8 100644 --- a/.ci/azure-pipelines-steps.yml +++ b/.ci/azure-pipelines-steps.yml @@ -13,21 +13,33 @@ steps: versionSpec: '$(python.version)' condition: ne(variables['python.version'], '') -- script: | - type python - python --version - displayName: Show python version - - script: | sudo apt-get update sudo apt-get install -y python2-dev python3-pip virtualenv displayName: Install build deps condition: and(eq(variables['python.version'], ''), eq(variables['Agent.OS'], 'Linux')) -- script: python -mpip install "tox<4.0" +- script: | + type python && python --version + type python2 && python2 --version + type python3 && python3 --version + displayName: Show python versions + +- script: | + if [[ $(uname) == "Darwin" ]]; then + python2 -m ensurepip --user --altinstall --no-default-pip + python2 -m pip install --user "tox<4.0" + else + python -m pip install "tox<4.0" + fi displayName: Install tooling -- script: python -mtox -e "$(tox.env)" +- script: | + if [[ $(uname) == "Darwin" ]]; then + python2 -m tox -e "$(tox.env)" + else + python -m tox -e "$(tox.env)" + fi displayName: "Run tests" env: AWS_ACCESS_KEY_ID: $(AWS_ACCESS_KEY_ID)