Skip to content

Commit

Permalink
sagemathgh-36525: GH Actions: Fix build of macOS x86_64 wheels, build…
Browse files Browse the repository at this point in the history
… wheels for sagemath-{bliss,coxeter3,mcqd,tdlib} for PyPI

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

Because the GitHub runner `macos-latest` is now Apple Silicon, building
x86_64 wheels is broken. We fix this here by using `macos-13` for
building x86_64.

We speed up the build on Linux by bootstrapping only once in each job,
and configuring and building packages of the Sage distribution only once
for each Linux platform. Bootstrapping is now done outside of the
container, and we configure Sage to use a `--prefix` in a directory
mounted from the host, and storing the `config.status`.

We add wheels for the optional-extension packages **sagemath-bliss**,
... that can be built on top of the existing modularized distributions.
(The packages **sagemath-meataxe** and **sagemath-sirocco** have to wait
for **sagemath-modules** to become available.)

Tests at https://github.com/mkoeppe/sage/actions/workflows/dist.yml:
- Successful run at
https://github.com/mkoeppe/sage/actions/runs/9100668826 (the failure in
release_dist is  unrelated)

Follow-up:
- sagemath#37541, refactor as reusable GH Actions workflow -- for use by
cysignals, cypari2, pplpy etc.

Part of:
- sagemath#31251

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#36521
- Depends on sagemath#37503 (merged here)

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36525
Reported by: Matthias Köppe
Reviewer(s):
  • Loading branch information
Release Manager committed May 23, 2024
2 parents c4681e3 + 2b2bbb2 commit 83a7fac
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ jobs:
arch: x86_64
- os: ubuntu-latest
arch: i686
- os: macos-latest
- os: macos-13
arch: x86_64
- os: macos-14
arch: arm64
Expand All @@ -175,16 +175,16 @@ jobs:
# SPKGs to install as system packages
SPKGS: _bootstrap _prereq
# Non-Python packages to install as spkgs
TARGETS_PRE: gmpy2-build-deps
TARGETS_PRE: gmp mpfr mpc bliss coxeter3 mcqd meataxe sirocco boost_cropped tdlib
# 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, <3.12"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.9, <3.13"
# 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)/prefix/bin:$PATH CPATH=$(pwd)/prefix/include:$CPATH LIBRARY_PATH=$(pwd)/prefix/lib:$LIBRARY_PATH LD_LIBRARY_PATH=$(pwd)/prefix/lib:$LD_LIBRARY_PATH PKG_CONFIG_PATH=$(pwd)/prefix/share/pkgconfig:$PKG_CONFIG_PATH ACLOCAL_PATH=/usr/share/aclocal PIP_CONSTRAINT=$(pwd)/constraints.txt"
# Use 'build', not 'pip wheel'
CIBW_BUILD_FRONTEND: build
steps:
Expand All @@ -203,23 +203,36 @@ jobs:
python-version: "3.8 - 3.12"
update-environment: false

- name: Bootstrap
run: |
export PATH=$(pwd)/build/bin:$PATH
eval $(sage-print-system-package-command auto --sudo --yes --no-install-recommends --spkg install _bootstrap)
./bootstrap
- name: Build platform wheels
# We build the wheels from the sdists so that MANIFEST filtering becomes effective.
# 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
# This is unfortunately repeated for each of the packages that we build wheels for
# For Linux, this is repeated for each of the packages that we build wheels for
# because CIBW starts with a fresh container on each invocation.
# Therefore we cache it in a directory mounted from the host: /host
# https://cibuildwheel.pypa.io/en/stable/faq/#linux-builds-in-containers
#
# omit sagemath-{meataxe,sirocco} for now -- needs sagemath-modules
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"
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) ) && if cp /host/sage-\$AUDITWHEEL_PLAT/config.status . 2>/dev/null; then chmod +x config.status; fi && if [ -x ./config.status ]; then ./config.status; else ./configure --enable-build-as-root ${{ startsWith(matrix.os, 'ubuntu') && '--prefix=/host/sage-\$AUDITWHEEL_PLAT' || '' }} && cp config.status prefix/; fi && MAKE=\"make -j6\" make V=0 $TARGETS_PRE && (echo \"sage_conf @ file://\$(pwd)/pkgs/sage-conf\" && echo \"sage_setup @ file://\$(pwd)/pkgs/sage-setup\") > constraints.txt"
mkdir -p unpacked
for pkg in sagemath-objects sagemath-categories; do
for pkg in sagemath*objects sagemath*categories sagemath*bliss sagemath*coxeter3 sagemath*mcqd sagemath*tdlib; do
case "$pkg:${{ matrix.arch }}" in
sagemath*tdlib:i686) continue;; # broken - boost-related
esac
(cd unpacked && tar xfz - ) < dist/$pkg*.tar.gz
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.17.0 unpacked/$pkg*
"${{ steps.python.outputs.python-path }}" -m pipx run cibuildwheel==2.18.0 unpacked/$pkg*
done
- uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/sagemath_tdlib/dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
tdlib cysignals | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON)
tdlib cysignals boost_cropped | $(PYTHON_TOOLCHAIN) sage_setup sagemath_environment cython pkgconfig $(PYTHON)
1 change: 1 addition & 0 deletions build/pkgs/sirocco/dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mpfr
1 change: 1 addition & 0 deletions pkgs/sagemath-coxeter3/pyproject.toml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ requires = [
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_sagemath_objects
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_pkgconfig
Expand Down
1 change: 1 addition & 0 deletions pkgs/sagemath-meataxe/pyproject.toml.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ requires = [
SPKG_INSTALL_REQUIRES_setuptools
SPKG_INSTALL_REQUIRES_sage_setup
SPKG_INSTALL_REQUIRES_sagemath_environment
SPKG_INSTALL_REQUIRES_sagemath_objects
SPKG_INSTALL_REQUIRES_cython
SPKG_INSTALL_REQUIRES_cysignals
SPKG_INSTALL_REQUIRES_pkgconfig
Expand Down

0 comments on commit 83a7fac

Please sign in to comment.