From 1cf7abaccad3e9a34ce1eafb33c0670115dc0c15 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 30 Apr 2024 17:42:25 +0200 Subject: [PATCH] Enabling M1 runners for Python package building inside github actions --- .github/workflows/build.yml | 7 ++++++- ci-scripts/macos/libpng-patch.sh | 29 ----------------------------- pyproject.toml | 17 +---------------- 3 files changed, 7 insertions(+), 46 deletions(-) delete mode 100644 ci-scripts/macos/libpng-patch.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6463f2bd2..fc426f6aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,8 +20,12 @@ jobs: max-parallel: 12 matrix: include: - - os: "macos-latest" + - os: "macos-13" # intel runner cibuild: "*macosx*" + macos-arch: "x86_64" + - os: "macos-14" # M1 runner + cibuild: "*macosx*" + macos-arch: "arm64" - os: "ubuntu-latest" cibuild: "*manylinux*" - os: "ubuntu-latest" @@ -58,6 +62,7 @@ jobs: # CIBW_SOME_OPTION: value env: CIBW_BUILD: ${{ matrix.cibuild }} + CIBW_ARCHS_MACOS: ${{ matrix.macos-arch }} - name: Download Cache from Docker (linux only) if: ${{ runner.os == 'Linux' }} diff --git a/ci-scripts/macos/libpng-patch.sh b/ci-scripts/macos/libpng-patch.sh deleted file mode 100644 index 8cd7973a5..000000000 --- a/ci-scripts/macos/libpng-patch.sh +++ /dev/null @@ -1,29 +0,0 @@ -# Solves issue #1346 -# Deprecate patch when Github Actions provides Apple Silicon runners. -# WARNING: Only run this in a CI runner - -# Issue: klayout depends on libpng, which is loaded by homebrew. -# But M1 wheels are cross-compiled in an intel host, so by default -# libpng.dylib has an x86 architecture. This prevents linking the library -# in the tl library. - -# Patch solution: manually download libpng arm64 pre-built library from homebrew - -# Reading -# https://stackoverflow.com/questions/55110564/how-can-i-install-a-homebrew-bottle-designed-for-a-different-previous-version -# https://github.com/Homebrew/homebrew-core/blob/6abea16e917b12d6af4912736f66eb8d42bf089b/Formula/libpng.rb - -export HOMEBREW_NO_INSTALL_CLEANUP=1 -export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 - -# Check if we're about to build an arm64 wheel. WARNING universal wheels not supported -if [ "$_PYTHON_HOST_PLATFORM" == "macosx-11.0-arm64" ] -then - # Exit early if done - test -f /tmp/libpng-apple-silicon-installed && exit 0 - curl -L -H "Authorization: Bearer QQ==" -o /tmp/libpng-1.6.39.arm64_big_sur.bottle.1.tar.gz https://ghcr.io/v2/homebrew/core/libpng/blobs/sha256:cf59cedc91afc6f2f3377567ba82b99b97744c60925a5d1df6ecf923fdb2f234 - brew reinstall -f /tmp/libpng-1.6.39.arm64_big_sur.bottle.1.tar.gz || exit 1 - touch /tmp/libpng-apple-silicon-installed -elif [ -f "/tmp/libpng-apple-silicon-installed" ]; then - brew reinstall -f libpng && rm -f /tmp/libpng-apple-silicon-installed -fi \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index c3c614d63..78ac75733 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,9 +11,6 @@ test-command = [ # Disable building PyPy wheels on all platforms skip = "pp*" -# Skip trying to test arm64 builds on Intel Macs -test-skip = "*-macosx_arm64 *-macosx_universal2:arm64" - [tool.cibuildwheel.linux] # beware: the before-all script does not persist environment variables! # No point in defining $PATH or $CCACHE_DIR @@ -27,17 +24,5 @@ before-build = "ccache -s" environment-pass = ["HOST_CCACHE_DIR"] [tool.cibuildwheel.macos] -before-all = [ - "brew install libpng", - "brew deps --tree --installed", -] - -# TEMP while Github Actions does not provide an Apple Silicon runner -# TODO Simply remove it when it's available -archs = ["x86_64", "arm64"] -before-build = [ - "ccache -s", - "bash {project}/ci-scripts/macos/libpng-patch.sh", -] # Repair macOS wheels (include libpng with the wheel, for example) -repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v --ignore-missing-dependencies {wheel}" \ No newline at end of file +repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v --ignore-missing-dependencies {wheel}"