diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 4d6d2b65d7..11c4553ead 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -22,6 +22,8 @@ env: CIBW_BUILD_VERBOSITY: 2 # Disable build isolation to allow pre-installing build-time dependencies CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation" + CIBW_SKIP: "pp* *musllinux*" + FORCE_COLOR: 3 jobs: build_windows_wheels: @@ -72,21 +74,26 @@ jobs: if-no-files-found: error build_macos_and_linux_wheels: - name: Build wheels on ${{ matrix.os }} + name: Wheels (${{ matrix.os }} / ${{ matrix.arch }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest] + arch: [x86_64, aarch64] + # build just amd64/x86_64 on macOS until we can get cross-compilation to arm64 working. + exclude: + - os: macos-latest + arch: aarch64 steps: - uses: actions/checkout@v4 name: Check out PyBaMM repository - name: Set up QEMU - if: matrix.os == 'ubuntu-latest' + if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' uses: docker/setup-qemu-action@v3 with: - platforms: all + platforms: arm64 - uses: actions/setup-python@v4 with: @@ -104,27 +111,47 @@ jobs: python -m pip install cmake wget python scripts/install_KLU_Sundials.py - - name: Build wheels on ${{ matrix.os }} + - name: Build Linux wheels for ${{ matrix.arch }} run: pipx run cibuildwheel --output-dir wheelhouse + if: matrix.os == 'ubuntu-latest' && matrix.arch == 'aarch64' env: - CIBW_ARCHS_LINUX: x86_64 aarch64 + # on aarch64/arm64, add EPEL to repolist and install openblas-devel from there + CIBW_ARCHS_LINUX: aarch64 CIBW_BEFORE_ALL_LINUX: > + yum -y install epel-release && yum -y install openblas-devel lapack-devel && bash scripts/install_sundials.sh 6.0.3 6.5.0 CIBW_BEFORE_BUILD_LINUX: > python -m pip install cmake casadi setuptools wheel CIBW_REPAIR_WHEEL_COMMAND_LINUX: > auditwheel repair -w {dest_dir} {wheel} + + - name: Build Linux wheels for ${{ matrix.arch }} + run: pipx run cibuildwheel --output-dir wheelhouse + if: matrix.os == 'ubuntu-latest' && matrix.arch == 'x86_64' + env: + CIBW_ARCHS_LINUX: x86_64 + CIBW_BEFORE_ALL_LINUX: > + yum -y install openblas-devel lapack-devel && + bash scripts/install_sundials.sh 6.0.3 6.5.0 + CIBW_BEFORE_BUILD_LINUX: > + python -m pip install cmake casadi setuptools wheel + CIBW_REPAIR_WHEEL_COMMAND_LINUX: > + auditwheel repair -w {dest_dir} {wheel} + + - name: Build macOS wheels for ${{ matrix.arch }} + if: matrix.os == 'macos-latest' + run: pipx run cibuildwheel --output-dir wheelhouse + env: CIBW_BEFORE_BUILD_MACOS: > python -m pip install --upgrade cmake casadi setuptools wheel && scripts/fix_suitesparse_rpath_mac.sh CIBW_REPAIR_WHEEL_COMMAND_MACOS: > delocate-listdeps {wheel} && delocate-wheel -v -w {dest_dir} {wheel} - CIBW_SKIP: "pp* *musllinux*" - name: Upload wheels uses: actions/upload-artifact@v3 with: - name: wheels + name: macos_linux_wheels path: ./wheelhouse/*.whl if-no-files-found: error @@ -152,7 +179,7 @@ jobs: if-no-files-found: error publish_pypi: - if: github.event_name != 'schedule' + if: github.event_name != 'schedule' && inputs.target != '' name: Upload package to PyPI needs: [build_macos_and_linux_wheels, build_windows_wheels, build_sdist] runs-on: ubuntu-latest @@ -163,7 +190,7 @@ jobs: - name: Move all package files to files/ run: | mkdir files - mv windows_wheels/* wheels/* sdist/* files/ + mv windows_wheels/* macos_linux_wheels/* sdist/* files/ - name: Publish on PyPI if: github.event.inputs.target == 'pypi' || github.event_name == 'release'