Skip to content

Support Python wheels on Linux ARM #248

Support Python wheels on Linux ARM

Support Python wheels on Linux ARM #248

Workflow file for this run

name: CD
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
release:
types: [ created ]
workflow_dispatch:
jobs:
# libraries:
# name: ${{ matrix.name }}
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# include:
# - name: 'Windows static library (Intel)'
# os: windows-2022
# arch: amd64
# shared_libs: OFF
# - name: 'Windows shared library (Intel)'
# os: windows-2022
# arch: amd64
# shared_libs: ON
# - name: 'Windows static library (ARM)'
# os: windows-2022
# arch: amd64_arm64
# shared_libs: OFF
# - name: 'Windows shared library (ARM)'
# os: windows-2022
# arch: amd64_arm64
# shared_libs: ON
# - name: 'Linux static library (Intel)'
# os: ubuntu-22.04
# shared_libs: OFF
# - name: 'Linux shared library (Intel)'
# os: ubuntu-22.04
# shared_libs: ON
# - name: 'Linux static library (ARM)'
# os: ubuntu-22.04
# arch: arm
# shared_libs: OFF
# context: CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
# - name: 'Linux shared library (ARM)'
# os: ubuntu-22.04
# arch: arm
# shared_libs: ON
# context: CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++
# - name: 'macOS static library (Intel)'
# os: macos-14
# shared_libs: OFF
# target_arch: " -DTARGET_ARCHITECTURE=Intel"
# - name: 'macOS shared library (Intel)'
# os: macos-14
# shared_libs: ON
# target_arch: " -DTARGET_ARCHITECTURE=Intel"
# - name: 'macOS static library (ARM)'
# os: macos-14
# shared_libs: OFF
# - name: 'macOS shared library (ARM)'
# os: macos-14
# shared_libs: ON
# env:
# BUILDCACHE_ACCURACY: STRICT
# BUILDCACHE_COMPRESS_FORMAT: ZSTD
# BUILDCACHE_DEBUG: -1
# BUILDCACHE_LOG_FILE: ""
# steps:
# - name: Check out libOpenCOR
# uses: actions/checkout@v4
# - name: Install ARM compiler
# if: ${{ matrix.arch == 'arm' }}
# run: |
# sudo apt update
# sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# - name: Install CMake and Ninja
# uses: lukka/get-cmake@latest
# - name: Install buildcache
# uses: cscouto/buildcache-action@v1
# with:
# cache_key: libraries-${{ matrix.os }}-${{ matrix.shared_libs }}
# - name: Configure MSVC
# if: ${{ runner.os == 'Windows' }}
# uses: ilammy/msvc-dev-cmd@v1
# with:
# arch: ${{ matrix.arch }}
# - name: Configure libOpenCOR
# run: |
# mkdir build
# cd build
# ${{ matrix.context }} cmake -G Ninja ${{ matrix.target_arch }} -DBUILD_TYPE=Release -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=OFF ..
# - name: Build libOpenCOR
# run: |
# cd build
# ninja
# - name: Package libOpenCOR
# run: |
# cd build
# cpack
# - name: Upload libOpenCOR artifacts
# if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
# uses: actions/upload-artifact@v4
# with:
# name: ${{ matrix.name }}
# path: ./build/libOpenCOR-*
# - name: Release libOpenCOR
# if: ${{ startsWith(github.ref, 'refs/tags/v') }}
# uses: softprops/action-gh-release@v2
# with:
# files: ./build/libOpenCOR-*
python_wheels:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# - name: 'Windows Python wheels (Intel)'
# os: windows-2022
# arch: amd64
# - name: 'Windows Python wheels (ARM)'
# os: windows-2022
# arch: amd64_arm64
- name: 'Linux Python wheels'
os: ubuntu-22.04
target_arch: x86_64
- name: 'Linux Python wheels'
os: ubuntu-22.04
target_arch: aarch64
# Note: ideally, we would be able to build our Python wheels for both Intel and ARM, but although there
# is a manylinux_2_34 image for ARM (see
# https://quay.io/repository/pypa/manylinux_2_34_aarch64?tab=tags), it is not supported by
# cibuildwheel. The only way to build Python wheels for ARM is currently through emulation (see
# https://cibuildwheel.pypa.io/en/stable/faq/#emulation), but this doesn't work for us because it
# relies on an old version of Linux while we want one with at least glibc version 2.34. So, for now,
# we are only building our Python wheels for Intel.
# - name: 'macOS Python wheels (Intel)'
# os: macos-13
# - name: 'macOS Python wheels (ARM)'
# os: macos-14
steps:
- name: Check out libOpenCOR
uses: actions/checkout@v4
- name: Configure MSVC
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Configure QEMU
if: ${{ (runner.os == 'Linux') && (matrix.target_arch == 'aarch64') }}
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build Python wheels
uses: pypa/cibuildwheel@9c75ea15c2f31a77e6043b80b1b7081372319d85
env:
CIBW_ARCHS: ${{ matrix.target_arch }}
CIBW_BUILD: 'cp*'
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=13.0
# Note #1: the value of CIBW_ENVIRONMENT_MACOS must be in sync with that of MACOS_DEPLOYMENT_TARGET in
# CMakelists.txt.
# Note #2: for some reasons, we need to specify the minor version, hence using 13.0 instead of 13.
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_34
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_34
CIBW_SKIP: 'cp36* cp37* cp38* *musllinux*'
- name: Upload Python wheel artifacts
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: ./wheelhouse/*.whl
- name: Release Python wheels
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: softprops/action-gh-release@v2
with:
files: ./wheelhouse/*.whl
# webassembly:
# name: WebAssembly
# runs-on: macos-14
# env:
# BUILDCACHE_ACCURACY: STRICT
# BUILDCACHE_COMPRESS_FORMAT: ZSTD
# BUILDCACHE_DEBUG: -1
# BUILDCACHE_LOG_FILE: ""
# steps:
# - name: Check out libOpenCOR
# uses: actions/checkout@v4
# - name: Install CMake and Ninja
# uses: lukka/get-cmake@latest
# - name: Install buildcache
# uses: cscouto/buildcache-action@v1
# with:
# cache_key: webassembly
# - name: Install Emscripten
# run: brew install emscripten
# - name: Configure libOpenCOR
# run: |
# mkdir build
# cd build
# cmake -G Ninja -DBUILD_TYPE=Release -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=ON -DJAVASCRIPT_UNIT_TESTING=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=OFF -DUNIT_TESTING=OFF ..
# - name: Build WebAssembly
# run: |
# cd build
# ninja
# - name: Upload WebAssembly artifact
# if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
# uses: actions/upload-artifact@v4
# with:
# name: WebAssembly
# path: ./build/libopencor-*
# - name: Release WebAssembly
# if: ${{ startsWith(github.ref, 'refs/tags/v') }}
# uses: softprops/action-gh-release@v2
# with:
# files: ./build/libopencor-*