Skip to content

Commit

Permalink
pybamm-team#3462 Add a job to compile Linux aarch64 wheel via emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
agriyakhetarpal committed Nov 27, 2023
1 parent 9df33eb commit 3de48cc
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 3de48cc

Please sign in to comment.