From 60ea588f57c90dd68717e8ee50f67ca98b0410c4 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 30 Jan 2024 23:58:43 +0530 Subject: [PATCH 1/7] Add configuration for macOS arm64 wheels See #3772 --- .github/workflows/publish_pypi.yml | 46 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 03cd977fef..47d06d5c31 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -133,7 +133,7 @@ jobs: CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel} CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()" - - name: Build wheels on macOS + - name: Build wheels on macOS amd64 if: matrix.os == 'macos-latest' run: pipx run cibuildwheel --output-dir wheelhouse env: @@ -150,11 +150,45 @@ jobs: path: ./wheelhouse/*.whl if-no-files-found: error - - name: Upload wheels for macOS + - name: Upload wheels for macOS amd64 uses: actions/upload-artifact@v4 if: matrix.os == 'macos-latest' with: - name: macos_wheels + name: macos_amd64_wheels + path: ./wheelhouse/*.whl + if-no-files-found: error + + build_macos_arm64_wheels: + name: Wheels (macos-arm64) + # Current runner is macOS X 14+ on GitHub-hosted runners + runs-on: macos-14 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: 3.8 + + - name: Clone pybind11 repo (no history) + run: git clone --depth 1 --branch v2.11.1 + + - name: Install SuiteSparse and SUNDIALS on macOS + run: | + brew install graphviz openblas libomp + brew reinstall gcc + python -m pip install cmake wget + python scripts/install_KLU_Sundials.py + + - name: Build wheels on macOS arm64 + run: pipx run cibuildwheel --output-dir wheelhouse + env: + CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel + CIBW_REPAIR_WHEEL_COMMAND: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} + CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()" + + - name: Upload wheels for macOS arm64 + uses: actions/upload-artifact@v4 + with: + name: macos_arm64_wheels path: ./wheelhouse/*.whl if-no-files-found: error @@ -182,7 +216,7 @@ jobs: # This job is only of value to PyBaMM and would always be skipped in forks if: github.event_name != 'schedule' && github.repository == 'pybamm-team/PyBaMM' name: Upload package to PyPI - needs: [build_macos_and_linux_wheels, build_windows_wheels, build_sdist] + needs: [build_macos_and_linux_wheels, build_macos_arm64_wheels, build_windows_wheels, build_sdist] runs-on: ubuntu-latest steps: - name: Download all artifacts @@ -191,7 +225,7 @@ jobs: - name: Move all package files to files/ run: | mkdir files - mv windows_wheels/* linux_wheels/* macos_wheels/* sdist/* files/ + mv windows_wheels/* linux_wheels/* macos_amd64_wheels/* macos_arm64_wheels/* sdist/* files/ - name: Publish on PyPI if: github.event.inputs.target == 'pypi' || github.event_name == 'release' @@ -213,7 +247,7 @@ jobs: open_failure_issue: needs: [build_windows_wheels, build_macos_and_linux_wheels, build_sdist] name: Open an issue if build fails - if: ${{ always() && contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}} + if: ${{ contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From ff8a6d1e95aca79abf5ca77530fb6e51f413e383 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:27:13 +0530 Subject: [PATCH 2/7] Build on Python 3.10+ for now --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 47d06d5c31..29804960ed 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -166,7 +166,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.10 - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.11.1 From 82e3238ee9a38026f4c7e0bbcd532e299a43f9ba Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:29:08 +0530 Subject: [PATCH 3/7] Possibly incorrect version string parsing --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 29804960ed..94d8a0b41e 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -166,7 +166,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.10 + python-version: '3.10' - name: Clone pybind11 repo (no history) run: git clone --depth 1 --branch v2.11.1 From e394ea48423646831f0ecb46f1d4303df4173e0d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:31:57 +0530 Subject: [PATCH 4/7] Missed adding link for `pybind11` --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 94d8a0b41e..8a74b1a8bd 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -169,7 +169,7 @@ jobs: python-version: '3.10' - name: Clone pybind11 repo (no history) - run: git clone --depth 1 --branch v2.11.1 + run: git clone --depth 1 --branch v2.11.1 https://github.com/pybind/pybind11.git - name: Install SuiteSparse and SUNDIALS on macOS run: | From 203afc21846aa25afba3ede922f39f124e9abbce Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 09:38:34 +0530 Subject: [PATCH 5/7] pipx invocation is missing, installed by default on other runners --- .github/workflows/publish_pypi.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 8a74b1a8bd..7e979741e1 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -175,13 +175,13 @@ jobs: run: | brew install graphviz openblas libomp brew reinstall gcc - python -m pip install cmake wget + python -m pip install cmake pipx python scripts/install_KLU_Sundials.py - name: Build wheels on macOS arm64 - run: pipx run cibuildwheel --output-dir wheelhouse + run: python -m pipx run cibuildwheel --output-dir wheelhouse env: - CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel + CIBW_BEFORE_BUILD: python -m pip install cmake casadi setuptools wheel delocate CIBW_REPAIR_WHEEL_COMMAND: delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} CIBW_TEST_COMMAND: python -c "import pybamm; pybamm.IDAKLUSolver()" From af9c299b966e401e45b54a7a2d447980c3b378fb Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 11:53:36 +0530 Subject: [PATCH 6/7] Add user-facing CHANGELOG entry about M-series wheels Python 3.8 wheels cannot be tested on arm64 devices but Python 3.9+ wheels can be. It would be a good idea to test all wheels across all Python versions. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f8ff3599a..bdacb00ae3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- Added support for macOS arm64 (M-series) platforms. ([#3789](https://github.com/pybamm-team/PyBaMM/pull/3789)) - Renamed "electrode diffusivity" to "particle diffusivity" as a non-breaking change with a deprecation warning ([#3624](https://github.com/pybamm-team/PyBaMM/pull/3624)) - Add support for BPX version 0.4.0 which allows for blended electrodes and user-defined parameters in BPX([#3414](https://github.com/pybamm-team/PyBaMM/pull/3414)) - Added the ability to specify a custom solver tolerance in `get_initial_stoichiometries` and related functions ([#3714](https://github.com/pybamm-team/PyBaMM/pull/3714)) From 310fbbffb68284c4d8f2a39959b69baadf500e4b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:44:50 +0530 Subject: [PATCH 7/7] Add `always()` condition to ensure job will run --- .github/workflows/publish_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 7e979741e1..7479598b5d 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -247,7 +247,7 @@ jobs: open_failure_issue: needs: [build_windows_wheels, build_macos_and_linux_wheels, build_sdist] name: Open an issue if build fails - if: ${{ contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}} + if: ${{ always() && contains(needs.*.result, 'failure') && github.repository_owner == 'pybamm-team'}} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4