Is it possible to build an ARM64 linux wheel on Github?

Question:

Currently I use cibuildwheel for building a c extension on Github.

cibuildwheel supports ARM64 for Windows (experimental) and Mac. It seems to support also ARM64 linux, with the name aarch64 (that is the "canonical" name of ARM64).

AArch64 linux needs QEMU. The problem is that in the example it’s not clear how to specify in the Github pipeline the use of QEMU for AArch64.

Asked By: Marco Sulla

||

Answers:

First of all, cibuildwheel does support ARM64 for Linux builds. It’s called aarch64.

About the implementation, I finally found how to do, thanks to the pipeline of matplotlib:

name: Build
on: [push, pull_request]
jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            cibw_archs: "native"
          - os: ubuntu-latest
            cibw_archs: "aarch64"
          - os: windows-latest
            cibw_archs: "native ARM64"
          - os: macos-latest
            cibw_archs: "native arm64"

    steps:
      - name: Set up QEMU
        if: matrix.cibw_archs == 'aarch64'
        uses: docker/setup-qemu-action@v2
        with:
          platforms: arm64
      - uses: actions/checkout@v3
      - name: Build wheels
        uses: pypa/[email protected]
        env:
          CIBW_ARCHS: ${{ matrix.cibw_archs }}
          CIBW_SKIP: "pp*"
          CIBW_TEST_REQUIRES: pytest
          CIBW_TEST_COMMAND: pytest {package}
      - uses: actions/upload-artifact@v3
        with:
          path: ./wheelhouse/*.whl

The trick is to make a separate entry for linux arm64, because it needs QEMU.

Answered By: Marco Sulla
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.