BLD: cross-compilation for android using cibuildwheel #23302
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Workflow to build and test wheels, similarly to numpy/numpy-release. | |
# To work on these jobs in a fork, comment out: | |
# | |
# if: github.repository == 'numpy/numpy' | |
name: Wheel builder | |
on: | |
pull_request: | |
branches: | |
- main | |
- maintenance/** | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
build_wheels: | |
name: Build wheel ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }} | |
# To enable this job on a fork, comment out: | |
if: github.repository == 'numpy/numpy' | |
runs-on: ${{ matrix.buildplat[0] }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# Github Actions doesn't support pairing matrix values together, let's improvise | |
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 | |
buildplat: | |
- [ubuntu-22.04, manylinux_x86_64, ""] | |
- [ubuntu-22.04, musllinux_x86_64, ""] | |
- [ubuntu-22.04-arm, manylinux_aarch64, ""] | |
- [ubuntu-22.04-arm, musllinux_aarch64, ""] | |
- [macos-13, macosx_x86_64, openblas] | |
- [macos-14, macosx_arm64, openblas] | |
- [windows-2022, win_amd64, ""] | |
- [windows-11-arm, win_arm64, ""] | |
python: ["cp311"] | |
env: | |
IS_32_BIT: ${{ matrix.buildplat[1] == 'win32' }} # used in cibw_test_command.sh | |
steps: | |
- name: Checkout numpy | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
with: | |
submodules: true | |
persist-credentials: false | |
- name: Setup MSVC (32-bit) | |
if: ${{ matrix.buildplat[1] == 'win32' }} | |
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1 | |
with: | |
architecture: 'x86' | |
- name: Setup LLVM for Windows ARM64 | |
if: ${{ matrix.buildplat[1] == 'win_arm64' }} | |
uses: ./.github/windows_arm64_steps | |
- name: pkg-config-for-win | |
if: runner.os == 'windows' | |
run: | | |
choco install -y --no-progress --stoponfirstfailure --checksum 6004DF17818F5A6DBF19CB335CC92702 pkgconfiglite | |
$CIBW = "${{ github.workspace }}/.openblas" | |
# pkgconfig needs a complete path, and not just "./openblas since the | |
# build is run in a tmp dir (?) | |
# It seems somewhere in the env passing, `\` is not | |
# passed through, so convert it to '/' | |
$CIBW = $CIBW.replace("\","/") | |
echo "CIBW_ENVIRONMENT_WINDOWS=PKG_CONFIG_PATH=$CIBW" >> $env:GITHUB_ENV | |
- name: Setup macOS | |
if: matrix.buildplat[0] == 'macos-13' || matrix.buildplat[0] == 'macos-14' | |
run: | | |
# Needed due to https://github.com/actions/runner-images/issues/3371 | |
# Supported versions: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md | |
echo "FC=gfortran-13" >> "$GITHUB_ENV" | |
echo "F77=gfortran-13" >> "$GITHUB_ENV" | |
echo "F90=gfortran-13" >> "$GITHUB_ENV" | |
if [[ ${{ matrix.buildplat[2] }} == 'accelerate' ]]; then | |
# macosx_arm64 and macosx_x86_64 with accelerate | |
# only target Sonoma onwards | |
CIBW="MACOSX_DEPLOYMENT_TARGET=14.0 INSTALL_OPENBLAS=false RUNNER_OS=macOS" | |
echo "CIBW_ENVIRONMENT_MACOS=$CIBW" >> "$GITHUB_ENV" | |
# the macos-13 image that's used for building the x86_64 wheel can't test | |
# a wheel with deployment target >= 14 without further work | |
echo "CIBW_TEST_SKIP=*-macosx_x86_64" >> "$GITHUB_ENV" | |
else | |
# macosx_x86_64 with OpenBLAS | |
# if INSTALL_OPENBLAS isn't specified then scipy-openblas is automatically installed | |
CIBW="RUNNER_OS=macOS" | |
PKG_CONFIG_PATH="$PWD/.openblas" | |
DYLD="$DYLD_LIBRARY_PATH:/$PWD/.openblas/lib" | |
echo "CIBW_ENVIRONMENT_MACOS=$CIBW PKG_CONFIG_PATH=$PKG_CONFIG_PATH DYLD_LIBRARY_PATH=$DYLD" >> "$GITHUB_ENV" | |
fi | |
- name: Build wheels | |
uses: pypa/cibuildwheel@c923d83ad9c1bc00211c5041d0c3f73294ff88f6 # v3.1.4 | |
env: | |
CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} | |
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }} | |
path: ./wheelhouse/*.whl |