From 5d09f812b4a8710aac13a31414307d3124246512 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sat, 3 Dec 2022 23:41:18 +0100 Subject: [PATCH 1/6] CI: add Cirrus CI jobs Run the tests on a few different Linux and Python distributions. --- .cirrus.yml | 64 +++++++++++++++++++++++++++++++++++++++ ci/alpine-3.docker | 3 ++ ci/archlinux.docker | 3 ++ ci/debian-11.docker | 3 ++ ci/debian-unstable.docker | 3 ++ ci/fedora-37.docker | 3 ++ ci/manylinux.docker | 2 ++ ci/miniconda.docker | 3 ++ ci/opensuse-15.docker | 3 ++ 9 files changed, 87 insertions(+) create mode 100644 .cirrus.yml create mode 100644 ci/alpine-3.docker create mode 100644 ci/archlinux.docker create mode 100644 ci/debian-11.docker create mode 100644 ci/debian-unstable.docker create mode 100644 ci/fedora-37.docker create mode 100644 ci/manylinux.docker create mode 100644 ci/miniconda.docker create mode 100644 ci/opensuse-15.docker diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 000000000..df45bedd1 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,64 @@ +test_template: &test + test_script: + - command -v python3 + - python3 --version + - python3 -m pip install .[test] + - python3 -m pytest + +alpine-3_task: + container: + dockerfile: ci/alpine-3.docker + cpu: 1 + << : *test + +archlinux_task: + container: + dockerfile: ci/archlinux.docker + cpu: 1 + << : *test + +debian-11_task: + container: + dockerfile: ci/debian-11.docker + cpu: 1 + << : *test + +debian-unstable_task: + container: + dockerfile: ci/debian-unstable.docker + cpu: 1 + << : *test + +fedora-37_task: + container: + dockerfile: ci/fedora-37.docker + cpu: 1 + << : *test + +manylinux-python3.11_task: + container: + dockerfile: ci/manylinux.docker + cpu: 1 + env: + PATH: "/opt/python/cp311-cp311/bin/:${PATH}" + << : *test + +manylinux-python3.7_task: + container: + dockerfile: ci/manylinux.docker + cpu: 1 + env: + PATH: "/opt/python/cp37-cp37m/bin/:${PATH}" + << : *test + +miniconda_task: + container: + dockerfile: ci/miniconda.docker + cpu: 1 + << : *test + +opensuse-15_task: + container: + dockerfile: ci/opensuse-15.docker + cpu: 1 + << : *test diff --git a/ci/alpine-3.docker b/ci/alpine-3.docker new file mode 100644 index 000000000..dfabaf0cb --- /dev/null +++ b/ci/alpine-3.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM alpine:3 +RUN apk add --no-cache python3-dev py3-pip build-base ninja git patchelf diff --git a/ci/archlinux.docker b/ci/archlinux.docker new file mode 100644 index 000000000..4607b6003 --- /dev/null +++ b/ci/archlinux.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM archlinux:latest +RUN pacman -Sy && pacman -S --noconfirm python python-pip gcc ninja git patchelf diff --git a/ci/debian-11.docker b/ci/debian-11.docker new file mode 100644 index 000000000..597cefc9c --- /dev/null +++ b/ci/debian-11.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM debian:bullseye +RUN apt-get update && apt-get install -y git ninja-build patchelf python3-pip python3-venv && rm -rf /var/lib/apt/lists/* diff --git a/ci/debian-unstable.docker b/ci/debian-unstable.docker new file mode 100644 index 000000000..1cbc161b2 --- /dev/null +++ b/ci/debian-unstable.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM debian:unstable +RUN apt-get update && apt-get install -y git ninja-build patchelf python3-pip python3-venv && rm -rf /var/lib/apt/lists/* diff --git a/ci/fedora-37.docker b/ci/fedora-37.docker new file mode 100644 index 000000000..da0c3e671 --- /dev/null +++ b/ci/fedora-37.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM fedora:37 +RUN dnf -y update && dnf -y install python3-devel python3-pip gcc ninja-build git patchelf && dnf clean all diff --git a/ci/manylinux.docker b/ci/manylinux.docker new file mode 100644 index 000000000..96788f5d9 --- /dev/null +++ b/ci/manylinux.docker @@ -0,0 +1,2 @@ +# 20221203 +FROM quay.io/pypa/manylinux_2_28_x86_64 diff --git a/ci/miniconda.docker b/ci/miniconda.docker new file mode 100644 index 000000000..f5f6a2ac9 --- /dev/null +++ b/ci/miniconda.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM continuumio/miniconda3 +RUN apt-get update && apt-get install -y gcc ninja-build git patchelf && rm -rf /var/lib/apt/lists/* diff --git a/ci/opensuse-15.docker b/ci/opensuse-15.docker new file mode 100644 index 000000000..ec59fcb55 --- /dev/null +++ b/ci/opensuse-15.docker @@ -0,0 +1,3 @@ +# 20221203 +FROM opensuse/leap:latest +RUN zypper --non-interactive install python310 python310-pip python310-devel gcc ninja git patchelf && zypper clean --all && ln -s python3.10 /usr/bin/python3 From e011261884a4b62b8177925b45c89679e01082c1 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Sun, 4 Dec 2022 00:09:37 +0100 Subject: [PATCH 2/6] CI: decommission Sage CI The new Cirrus CI jobs are a much more efficient way to run the test suite on a few different Linux and Python distributions. --- .github/workflows/sage.yml | 151 ------------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 .github/workflows/sage.yml diff --git a/.github/workflows/sage.yml b/.github/workflows/sage.yml deleted file mode 100644 index 21e8cc752..000000000 --- a/.github/workflows/sage.yml +++ /dev/null @@ -1,151 +0,0 @@ -name: sage - -## This GitHub Actions workflow provides: -## -## - portability testing, by building and testing this project on many platforms -## (Linux variants) -## -## - continuous integration, by building and testing other software -## that depends on this project. -## -## It runs on every push to the GitHub repository. -## -## The testing can be monitored in the "Actions" tab of the GitHub repository. -## -## After all jobs have finished (or are canceled) and a short delay, -## tar files of all logs are made available as "build artifacts". -## -## This GitHub Actions workflow uses the portability testing framework -## of SageMath (https://www.sagemath.org/). For more information, see -## https://doc.sagemath.org/html/en/developer/portability_testing.html - -## The workflow consists of two jobs: -## -## - First, it builds a source distribution of the project -## and generates a script "update-pkgs.sh". It uploads them -## as a build artifact named upstream. -## -## - Second, it checks out a copy of the SageMath source tree. -## It downloads the upstream artifact and replaces the project's -## package in the SageMath distribution by the newly packaged one -## from the upstream artifact, by running the script "update-pkgs.sh". -## Then it builds a small portion of the Sage distribution. -## -## Many copies of the second step are run in parallel for each of the tested -## systems/configurations. - -on: - push: - pull_request: - branches: - - main - - release-* - paths-ignore: - # This is spelt like this to do not ignore the docs/examples/ folder. - - docs/* - - docs/usage/* - - CHANGELOG.rst - - LICENSE - - README.md - workflow_dispatch: - # Allow to run manually - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - # Ubuntu packages to install so that the project's can build an sdist - DIST_PREREQ: python3-pip - # Name of this project in the Sage distribution - SPKG: meson_python - -jobs: - - build: - runs-on: ubuntu-latest - outputs: - systems: ${{ steps.push-to-main-systems.outputs.systems }} ${{ steps.pull-request-systems.outputs.systems }} - steps: - - name: Check out ${{ env.SPKG }} - uses: actions/checkout@v3 - with: - path: build/pkgs/${{ env.SPKG }}/src - - name: Install prerequisites - run: | - sudo DEBIAN_FRONTEND=noninteractive apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt-get install $DIST_PREREQ - python3 -m pip install --user build - - name: Run make dist, prepare upstream artifact - run: | - pushd build/pkgs/${{ env.SPKG }}/src - python3 -m build --sdist . - popd - mkdir -p upstream - cp build/pkgs/${{ env.SPKG }}/src/dist/*.tar.gz upstream/${{ env.SPKG }}-git.tar.gz - echo "sage-package create ${{ env.SPKG }} --version git --tarball ${{ env.SPKG }}-git.tar.gz --type=standard" > upstream/update-pkgs.sh - if [ -n "${{ env.REMOVE_PATCHES }}" ] - then - echo "(cd ../build/pkgs/${{ env.SPKG }}/patches rm -f ${{ env.REMOVE_PATCHES }}; :)" >> upstream/update-pkgs.sh - fi - echo "sed -i.bak \"/pushdef.*LT_VERSION/s/3[0-9.]*/4/\" ../build/pkgs/python3/spkg-configure.m4" >> upstream/update-pkgs.sh - echo "sed -i.bak \"/export.*proxy/d\" ../build/bin/sage-spkg" >> upstream/update-pkgs.sh - ls -l upstream - - name: System factors for pull requests - # See https://github.com/sagemath/sage/blob/develop/.github/workflows/docker.yml for available systems - id: pull-request-systems - if: ${{ github.event_name == 'pull_request' }} - run: >- - echo 'systems=[ - "archlinux-latest", - "conda-forge", - ]' >> $GITHUB_OUTPUT - - name: System factors for push to main - # See https://github.com/sagemath/sage/blob/develop/.github/workflows/docker.yml for available systems - id: push-to-main-systems - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - run: >- - echo 'systems=[ - "debian-bullseye", - "fedora-36", - "centos-stream-8-python3.9", - "gentoo-python3.9", - "archlinux-latest", - "opensuse-15.4-gcc_11-python3.10", - "opensuse-tumbleweed-python3.10", - "conda-forge", - "archlinux-latest", - "conda-forge", - ]' >> $GITHUB_OUTPUT - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - path: upstream - name: upstream - - test: - # https://github.com/sagemath/sage/blob/develop/.github/workflows/docker.yml - uses: sagemath/sagetrac-mirror/.github/workflows/docker.yml@develop - with: - tox_system_factors: ${{ needs.build.outputs.systems }} - tox_packages_factors: >- - ["minimal-develop",] - # Extra system packages to install. See available packages at - # https://github.com/sagemath/sage/tree/develop/build/pkgs - # liblzma, bzip2, and libffi are python3 dependencies. - extra_sage_packages: "patch liblzma bzip2 libffi python3 ninja_build" - # Sage distribution packages to build - targets: SAGE_CHECK=no SAGE_CHECK_PACKAGES="meson_python" python_build meson_python - sage_repo: sagemath/sage - sage_ref: develop - upstream_artifact: upstream - sage_trac_git: https://github.com/sagemath/sagetrac-mirror.git - docker_targets: "with-targets" - docker_push_repository: ghcr.io/${{ github.repository }}/meson-python- - needs: [build] - - # sage-pass: - # needs: [test] - # runs-on: ubuntu-latest - # steps: - # - run: echo "All jobs passed" From 1fed365ee90f5ff004ccc16c4200a2afdcf9fa2c Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Tue, 6 Dec 2022 20:59:24 +0100 Subject: [PATCH 3/6] CI: install pip with fix for isolated build environment on Debian --- .cirrus.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index df45bedd1..800fcd1b6 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -21,12 +21,18 @@ debian-11_task: container: dockerfile: ci/debian-11.docker cpu: 1 + fix-pip_script: + # see https://github.com/pypa/pip/pull/11623 + - python3 -m pip install --upgrade "pip @ git+https://github.com/pypa/pip.git@refs/pull/11623/merge" << : *test debian-unstable_task: container: dockerfile: ci/debian-unstable.docker cpu: 1 + fix-pip_script: + # see https://github.com/pypa/pip/pull/11623 + - python3 -m pip install --upgrade "pip @ git+https://github.com/pypa/pip.git@refs/pull/11623/merge" << : *test fedora-37_task: From c6a1337e5bbe4b997724f69e7f6f6d9dcb5b6d69 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Fri, 9 Dec 2022 10:20:44 +0100 Subject: [PATCH 4/6] CI: install Meson with fix for Python 3.7 extensions linking --- .cirrus.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.cirrus.yml b/.cirrus.yml index 800fcd1b6..0d64c5883 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -55,6 +55,12 @@ manylinux-python3.7_task: cpu: 1 env: PATH: "/opt/python/cp37-cp37m/bin/:${PATH}" + fix-meson_script: + # see https://github.com/mesonbuild/meson/issues/11097 + - mkdir wheelhouse + - python -m pip wheel --wheel-dir wheelhouse git+https://github.com/mesonbuild/meson@refs/pull/11104/head + - echo "PIP_FIND_LINKS=$(pwd)/wheelhouse/" >> $CIRRUS_ENV + - PIP_FIND_LINKS="$(pwd)/wheelhouse/" python -m pip install meson << : *test miniconda_task: From d0a8bd4ecf066e5526659e7951f8c31cb48a30c5 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Fri, 9 Dec 2022 10:54:17 +0100 Subject: [PATCH 5/6] BUG: fix comments --- mesonpy/_tags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesonpy/_tags.py b/mesonpy/_tags.py index 355a81152..538ceabc0 100644 --- a/mesonpy/_tags.py +++ b/mesonpy/_tags.py @@ -101,12 +101,12 @@ def _get_macosx_platform_tag() -> str: # # This results in packaging versions up to 21.3 generating # platform tags like "macosx_10_16_x86_64" and later versions - # generating "macosx_11_0_x86_64". Using latter would be more + # generating "macosx_11_0_x86_64". Using the latter would be more # correct but prevents the resulting wheel from being installed on # systems using packaging 21.3 or earlier (pip 22.3 or earlier). # # Fortunately packaging versions carrying the workaround still - # accepts "macosx_11_0_x86_64" as a compatible platform tag. We + # accepts "macosx_10_16_x86_64" as a compatible platform tag. We # can therefore ignore the issue and generate the slightly # incorrect tag. From 0f4deacd8543aab4a460791a00731660d4fdeeac Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Fri, 9 Dec 2022 10:54:41 +0100 Subject: [PATCH 6/6] TST: reconcile platform tags with recent packaging on macOS --- tests/conftest.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5d0b18080..90500dca1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,13 +19,25 @@ def adjust_packaging_platform_tag(platform: str) -> str: - # The packaging module generates overly specific platforms tags on - # Linux. The platforms tags on Linux evolved over time. - # meson-python uses more relaxed platform tags to maintain - # compatibility with old wheel installation tools. The relaxed - # platform tags match the ones generated by the wheel package. - # https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/ - return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform) + if platform.startswith(('manylinux', 'musllinux')): + # The packaging module generates overly specific platforms tags on + # Linux. The platforms tags on Linux evolved over time. + # meson-python uses more relaxed platform tags to maintain + # compatibility with old wheel installation tools. The relaxed + # platform tags match the ones generated by the wheel package. + # https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/ + return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform) + if platform.startswith('macosx'): + # Python built with older macOS SDK on macOS 11, reports an + # unexising macOS 10.16 version instead of the real version. + # The packaging module introduced a workaround in version + # 22.0. Too maintain compatibility with older packaging + # releases we don't implement it. Reconcile this. + from platform import mac_ver + version = tuple(map(int, mac_ver()[0].split('.')))[:2] + if version == (10, 16): + return re.sub(r'^macosx_\d+_\d+_(.*)$', r'macosx_10_16_\1', platform) + return platform package_dir = pathlib.Path(__file__).parent / 'packages'