From 1f627493cf8d4ae801893c3c7ffd3d80085b0719 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Wed, 4 Oct 2023 14:30:30 -0700 Subject: [PATCH 1/7] .github/workflows/wheels.yml: New --- .github/workflows/wheels.yml | 83 ++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..55fd7e00 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,83 @@ +name: Build wheels + +on: + push: + pull_request: + workflow_dispatch: + +concurrency: + # Cancel previous runs of this workflow for the same branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + sdists_for_pypi: + name: Build sdist (and upload to PyPI on release tags) + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - name: make sdist + run: | + python3 -m pip install build + python3 -m build --sdist + - uses: actions/upload-artifact@v3 + with: + path: "dist/*.tar.gz" + name: dist + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macOS-latest] + + steps: + - uses: actions/checkout@v4 + + # Used to host cibuildwheel + - uses: actions/setup-python@v4 + + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.0 + + - uses: actions/upload-artifact@v3 + with: + name: wheels + path: ./wheelhouse/*.whl + + pypi-publish: + # https://github.com/pypa/gh-action-pypi-publish + name: Upload wheels to PyPI + needs: build_wheels + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + runs-on: ubuntu-latest + env: + CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} + steps: + + - uses: actions/download-artifact@v3 + with: + name: wheels + path: wheelhouse + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.SAGEMATH_PYPI_API_TOKEN }} + packages_dir: wheelhouse/ + skip_existing: true + verbose: true + if: env.CAN_DEPLOY == 'true' From 0701d8d4e2ec3d52a14ff7a0328a9bf13b574750 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 15 Mar 2024 23:22:24 -0700 Subject: [PATCH 2/7] pyproject.toml: Add section [tool.cibuildwheel] --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 224d5d16..82a96945 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,3 +24,9 @@ keywords = ["PARI/GP number theory"] [project.urls] Homepage = "https://github.com/sagemath/cypari2" +[tool.cibuildwheel] +before-all = """ + apt-get install --yes wget sudo || yum install -y wget sudo || brew install bash coreutils + bash -x ./.install-pari.sh +""" +environment = { PARI_VERSION="pari-2.15.4" } From 57b2f42109930a0fe4d21fc52ec03380e2f06b2e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 6 Oct 2023 21:16:41 -0700 Subject: [PATCH 3/7] .github/workflows/wheels.yml: Update from sage dist.yml --- .github/workflows/wheels.yml | 60 +++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 55fd7e00..5dd5c6a6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -19,6 +19,11 @@ jobs: CAN_DEPLOY: ${{ secrets.SAGEMATH_PYPI_API_TOKEN != '' }} steps: - uses: actions/checkout@v4 + - name: Install pari + run: | + bash -x .install-pari.sh + env: + PARI_VERSION: pari-2.15.4 - uses: actions/setup-python@v4 - name: make sdist run: | @@ -37,20 +42,61 @@ jobs: if: env.CAN_DEPLOY == 'true' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') build_wheels: - name: Build wheels on ${{ matrix.os }} + name: Build wheels on ${{ matrix.os }}, arch ${{ matrix.arch }} runs-on: ${{ matrix.os }} + needs: sdists_for_pypi strategy: + fail-fast: false matrix: - os: [ubuntu-latest, macOS-latest] - + include: + - os: ubuntu-latest + arch: x86_64 + - os: ubuntu-latest + arch: i686 + - os: macos-latest + arch: auto + env: + # SPKGs to install as system packages + SPKGS: _bootstrap _prereq + # Non-Python packages to install as spkgs + TARGETS_PRE: pari + # Disable building PyPy wheels on all platforms + # Disable musllinux until #33083 provides alpine package information + CIBW_SKIP: "pp* *-musllinux*" + # + CIBW_ARCHS: ${{ matrix.arch }} + # https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" + # Environment during wheel build + CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal" + # Use 'build', not 'pip wheel' + CIBW_BUILD_FRONTEND: build steps: - uses: actions/checkout@v4 + with: + repository: sagemath/sage + ref: develop - # Used to host cibuildwheel - - uses: actions/setup-python@v4 + - uses: actions/download-artifact@v3 + with: + name: dist + path: dist - - name: Build wheels - uses: pypa/cibuildwheel@v2.16.0 + - name: Build platform wheels + # We build the wheel from the sdist. + # But we must run cibuildwheel with the unpacked source directory, not a tarball, + # so that SAGE_ROOT is copied into the build containers. + # + # In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution. + # https://cibuildwheel.readthedocs.io/en/stable/options/#before-all + run: | + export PATH=build/bin:$PATH + export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root && make -j4 V=0 $TARGETS_PRE" + mkdir -p unpacked + for pkg in cypari2; do + (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz + pipx run cibuildwheel==2.16.0 unpacked/$pkg* + done - uses: actions/upload-artifact@v3 with: From aeb2f1d74330f84a84ed65f39a7e2e10cbf0c7dd Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 3 Feb 2024 23:42:43 -0800 Subject: [PATCH 4/7] .github/workflows/wheels.yml [linux]: Set LD_LIBRARY_PATH --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5dd5c6a6..9a5016fa 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -68,7 +68,7 @@ jobs: # https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9" # Environment during wheel build - CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal" + CIBW_ENVIRONMENT: "PATH=$(pwd)/local/bin:$PATH CPATH=$(pwd)/local/include:$CPATH LIBRARY_PATH=$(pwd)/local/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/local/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/local/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal" # Use 'build', not 'pip wheel' CIBW_BUILD_FRONTEND: build steps: From 478aaf0c80857044fdec6ada0ba13b3deede84b9 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 15 Mar 2024 23:29:41 -0700 Subject: [PATCH 5/7] .github/workflows/wheels.yml: Use cibuildwheel==2.17.0, add macos-14 (arm64) build --- .github/workflows/wheels.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 9a5016fa..203fec69 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -55,6 +55,8 @@ jobs: arch: i686 - os: macos-latest arch: auto + - os: macos-14 + arch: auto env: # SPKGs to install as system packages SPKGS: _bootstrap _prereq @@ -95,7 +97,7 @@ jobs: mkdir -p unpacked for pkg in cypari2; do (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz - pipx run cibuildwheel==2.16.0 unpacked/$pkg* + pipx run cibuildwheel==2.17.0 unpacked/$pkg* done - uses: actions/upload-artifact@v3 From a0156f803e99c6f7eaf3b2ca4858f58ae3d42898 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 15 Mar 2024 23:40:27 -0700 Subject: [PATCH 6/7] pyproject.toml: Remove unused cibuildwheel section --- pyproject.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 82a96945..224d5d16 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,9 +24,3 @@ keywords = ["PARI/GP number theory"] [project.urls] Homepage = "https://github.com/sagemath/cypari2" -[tool.cibuildwheel] -before-all = """ - apt-get install --yes wget sudo || yum install -y wget sudo || brew install bash coreutils - bash -x ./.install-pari.sh -""" -environment = { PARI_VERSION="pari-2.15.4" } From 2be5aebde492b46a0a1ccba83076fa01442a0983 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Fri, 15 Mar 2024 23:49:12 -0700 Subject: [PATCH 7/7] .github/workflows/wheels.yml: Get pipx as done in https://github.com/sagemath/sage/pull/37503 --- .github/workflows/wheels.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 203fec69..2df07968 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -84,6 +84,14 @@ jobs: name: dist path: dist + - uses: actions/setup-python@v5 + # As of 2024-02-03, the macOS M1 runners do not have preinstalled python or pipx. + # Installing pipx follows the approach of https://github.com/pypa/cibuildwheel/pull/1743 + id: python + with: + python-version: "3.8 - 3.12" + update-environment: false + - name: Build platform wheels # We build the wheel from the sdist. # But we must run cibuildwheel with the unpacked source directory, not a tarball, @@ -92,12 +100,13 @@ jobs: # In the CIBW_BEFORE_ALL phase, we install libraries using the Sage distribution. # https://cibuildwheel.readthedocs.io/en/stable/options/#before-all run: | + "${{ steps.python.outputs.python-path }}" -m pip install pipx export PATH=build/bin:$PATH export CIBW_BEFORE_ALL="( $(sage-print-system-package-command debian --yes --no-install-recommends install $(sage-get-system-packages debian $SPKGS)) || $(sage-print-system-package-command fedora --yes --no-install-recommends install $(sage-get-system-packages fedora $SPKGS | sed s/pkg-config/pkgconfig/)) || ( $(sage-print-system-package-command homebrew --yes --no-install-recommends install $(sage-get-system-packages homebrew $SPKGS)) || echo error ignored) ) && ./bootstrap && ./configure --enable-build-as-root && make -j4 V=0 $TARGETS_PRE" mkdir -p unpacked for pkg in cypari2; do (cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz - pipx run cibuildwheel==2.17.0 unpacked/$pkg* + "${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg* done - uses: actions/upload-artifact@v3