Skip to content

Commit 26b50c9

Browse files
author
Simon Rit
committed
ENH: Compile Linux arm64 packages on arm64 github runners
Cross compilation of "_2_28-aarch64" packages is 10x slower than that of _2_28-x64 packages.
1 parent 7e5f78c commit 26b50c9

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

.github/workflows/build-test-package-python.yml

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ on:
3939
description: 'JSON-formatted array of "<manylinux-image>-<arch>" specializations'
4040
required: false
4141
type: string
42-
default: '["_2_28-x64","2014-x64","_2_28-aarch64"]'
42+
default: '["_2_28-x64","2014-x64"]'
4343
macosx-deployment-target:
4444
description: 'A string to provide as MACOSX_DEPLOYMENT_TARGET, e.g. "10.15". If left empty (default), the per-architecture default will be used.'
4545
required: false
@@ -131,6 +131,80 @@ jobs:
131131
name: LinuxWheel3${{ matrix.python3-minor-version }}${{ matrix.manylinux-platform }}
132132
path: dist/*.whl
133133

134+
build-linux-arm-py:
135+
runs-on: ubuntu-22.04-arm
136+
strategy:
137+
max-parallel: 2
138+
matrix:
139+
python3-minor-version: ${{ fromJSON(inputs.python3-minor-versions) }}
140+
141+
steps:
142+
- uses: actions/checkout@v4
143+
144+
- name: Free Disk Space (Ubuntu)
145+
uses: jlumbroso/free-disk-space@v1.3.1
146+
with:
147+
large-packages: false
148+
149+
- name: 'Fetch build script'
150+
run: |
151+
IPP_DOWNLOAD_GIT_TAG=${{ inputs.itk-python-package-tag }}
152+
IPP_DOWNLOAD_ORG=${{ inputs.itk-python-package-org }}
153+
curl -L https://raw.githubusercontent.com/${IPP_DOWNLOAD_ORG:=InsightSoftwareConsortium}/ITKPythonPackage/${IPP_DOWNLOAD_GIT_TAG:=master}/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O
154+
chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh
155+
156+
- name: 'Build 🐍 Python 📦 package'
157+
shell: bash
158+
run: |
159+
rm -rf dist
160+
161+
export ITK_PACKAGE_VERSION=${{ inputs.itk-wheel-tag }}
162+
export ITKPYTHONPACKAGE_TAG=${{ inputs.itk-python-package-tag }}
163+
export ITKPYTHONPACKAGE_ORG=${{ inputs.itk-python-package-org }}
164+
export ITK_MODULE_PREQ=${{ inputs.itk-module-deps }}
165+
if [ -z ${{ inputs.cmake-options }} ]; then
166+
CMAKE_OPTIONS=""
167+
else
168+
CMAKE_OPTIONS="--cmake_options ${{ inputs.cmake-options }}"
169+
fi
170+
171+
MANYLINUX_PLATFORM="_2_28-aarch64"
172+
echo "Manylinux platform ${MANYLINUX_PLATFORM}"
173+
rm -rf ITKPythonPackage
174+
export MANYLINUX_VERSION=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)`
175+
export TARGET_ARCH=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)`
176+
echo "Building for manylinux specialization ${MANYLINUX_VERSION} and target architecture ${TARGET_ARCH}"
177+
178+
./dockcross-manylinux-download-cache-and-build-module-wheels.sh cp3${{ matrix.python3-minor-version }} $CMAKE_OPTIONS
179+
180+
- name: Set up Python 3.11 for Validation
181+
uses: actions/setup-python@v5
182+
with:
183+
python-version: "3.11"
184+
185+
- name: Validate build output
186+
shell: bash
187+
run: |
188+
python -m pip install twine
189+
ls dist/
190+
191+
MANYLINUX_PLATFORM="_2_28-aarch64"
192+
MANYLINUX_VERSION=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 1)`
193+
TARGET_ARCH_NAME=`(echo ${MANYLINUX_PLATFORM} | cut -d '-' -f 2)`
194+
if [[ ${TARGET_ARCH_NAME} == "x64" ]]; then
195+
TARGET_ARCH_NAME="x86_64" # Match auditwheel naming convention
196+
fi
197+
WHEEL_PATTERN="dist/itk_*cp3${{ matrix.python3-minor-version }}*manylinux${MANYLINUX_VERSION}*${TARGET_ARCH_NAME}.whl"
198+
199+
echo "Searching for wheels matching pattern ${WHEEL_PATTERN}"
200+
python -m twine check ${WHEEL_PATTERN}
201+
202+
- name: Publish Python package as GitHub Artifact
203+
uses: actions/upload-artifact@v4
204+
with:
205+
name: LinuxWheel3${{ matrix.python3-minor-version }}_2_28-aarch64
206+
path: dist/*.whl
207+
134208
build-macos-arm-py:
135209
runs-on: macos-14
136210
strategy:
@@ -334,6 +408,7 @@ jobs:
334408
publish-python-packages-to-pypi:
335409
needs:
336410
- build-linux-py
411+
- build-linux-arm-py
337412
- build-macos-arm-py
338413
- build-windows-python-packages
339414
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)