From e671fa658a2b8abd62e32c93713846f8d34e82bf Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Sat, 14 Nov 2026 00:17:38 +0000 Subject: [PATCH 1/5] Add Android and iOS wheels --- .github/workflows/wheels.yml | 61 +++++++++++++++++++++---------- .gitignore | 1 + cibuildwheel.toml | 31 +++++++++++++--- tools/wheels/cibw_before_build.sh | 25 +++++++++---- 4 files changed, 87 insertions(+), 31 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b7d002f..7ff79e5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -23,8 +23,9 @@ on: - main - maintenance/** push: - branches: - - main # FOR TESTING ONLY + # FIXME + # branches: + # - main # FOR TESTING ONLY workflow_dispatch: inputs: environment: @@ -91,7 +92,7 @@ jobs: build_wheels: if: github.repository == 'numpy/numpy-release' - name: BLD > ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }} + name: ${{ matrix.python }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }} runs-on: ${{ matrix.buildplat[0] }} needs: [check_lock] strategy: @@ -102,26 +103,44 @@ jobs: # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 buildplat: - [ubuntu-24.04, manylinux_x86_64, ""] - - [ubuntu-24.04, musllinux_x86_64, ""] - - [ubuntu-24.04-arm, manylinux_aarch64, ""] - - [ubuntu-24.04-arm, musllinux_aarch64, ""] - - [macos-15-intel, macosx_x86_64, openblas] - - # targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile - - [macos-15-intel, macosx_x86_64, accelerate] - - [macos-15, macosx_arm64, openblas] - - [macos-15, macosx_arm64, accelerate] - - [windows-2022, win_amd64, ""] - - [windows-11-arm, win_arm64, ""] + # FIXME + # - [ubuntu-24.04, musllinux_x86_64, ""] + # - [ubuntu-24.04-arm, manylinux_aarch64, ""] + # - [ubuntu-24.04-arm, musllinux_aarch64, ""] + # - [macos-15-intel, macosx_x86_64, openblas] + + # # targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile + # - [macos-15-intel, macosx_x86_64, accelerate] + # - [macos-15, macosx_arm64, openblas] + # - [macos-15, macosx_arm64, accelerate] + # - [windows-2022, win_amd64, ""] + # - [windows-11-arm, win_arm64, ""] + - [ubuntu-24.04, android_arm64_v8a] + - [ubuntu-24.04, android_x86_64] + - [macos-26, ios_arm64_iphoneos] + - [macos-26, ios_arm64_iphonesimulator] python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"] exclude: - buildplat: [ macos-15-intel, macosx_x86_64, openblas ] python: "cp314t" + # Mobile platforms require Python 3.13 or later, and don't support free- + # threading yet. + - {buildplat: [ubuntu-24.04, android_arm64_v8a], python: cp312} + - {buildplat: [ubuntu-24.04, android_arm64_v8a], python: cp314t} + - {buildplat: [ubuntu-24.04, android_arm64_v8a], python: cp315t} + - {buildplat: [ubuntu-24.04, android_x86_64], python: cp312} + - {buildplat: [ubuntu-24.04, android_x86_64], python: cp314t} + - {buildplat: [ubuntu-24.04, android_x86_64], python: cp315t} + - {buildplat: [macos-26, ios_arm64_iphoneos], python: cp312} + - {buildplat: [macos-26, ios_arm64_iphoneos], python: cp314t} + - {buildplat: [macos-26, ios_arm64_iphoneos], python: cp315t} + - {buildplat: [macos-26, ios_arm64_iphonesimulator], python: cp312} + - {buildplat: [macos-26, ios_arm64_iphonesimulator], python: cp314t} + - {buildplat: [macos-26, ios_arm64_iphonesimulator], python: cp315t} include: - buildplat: [ ubuntu-22.04, pyodide_wasm32, "" ] python: "cp314" - steps: - name: Checkout numpy-release uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -192,18 +211,22 @@ jobs: echo "CIBW_ENVIRONMENT_MACOS=PKG_CONFIG_PATH=$PWD/.openblas" >> "$GITHUB_ENV" fi + - name: Setup iOS + if: startsWith(matrix.buildplat[1], 'ios_') + run: | + # ACCELERATE_NEW_LAPACK with ILP64 requires a higher iOS version than + # cibuildwheel's default. + echo "CIBW_ENVIRONMENT_IOS=IPHONEOS_DEPLOYMENT_TARGET=17.0" >> "$GITHUB_ENV" + - name: Pyodide setup if: ${{ matrix.buildplat[1] == 'pyodide_wasm32' }} run: | - echo "CIBW_PLATFORM=pyodide" >> "$GITHUB_ENV" echo "CIBW_ENVIRONMENT_PYODIDE=INSTALL_OPENBLAS=false" >> "$GITHUB_ENV" - name: Build wheels uses: pypa/cibuildwheel@f9b966cfadf4109556cadc5bb39ddb72d0ce664e # v4.3.5 - env: - CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} - SRC: ${{ github.workspace }}/numpy-src with: + only: ${{ matrix.python }}-${{ matrix.buildplat[1] }} package-dir: numpy-src output-dir: dist config-file: cibuildwheel.toml diff --git a/.gitignore b/.gitignore index 513c1d7..44c7356 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.openblas numpy-src dist diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 4e34497..6a818fb 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -10,7 +10,7 @@ dependency-versions = "pinned" # we install all build dependencies ourselves in the cibw_before_build step build-frontend = { name = "build", args = ["--no-isolation"] } -before-build = "bash {project}/tools/wheels/cibw_before_build.sh {project}" +before-build = "bash {project}/tools/wheels/cibw_before_build.sh {project} {package}" before-test = "bash {project}/tools/wheels/cibw_before_test.sh {project}" test-command = "bash {project}/tools/wheels/cibw_test_command.sh {project}" enable = ["cpython-prerelease"] @@ -20,6 +20,10 @@ enable = ["cpython-prerelease"] setup-args = ["-Duse-ilp64=true", "-Dallow-noblas=false"] build-dir = "build" +[tool.cibuildwheel.ios] +before-build = [] +xbuild-tools = ["ninja"] + [tool.cibuildwheel.linux] manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" @@ -30,23 +34,40 @@ musllinux-aarch64-image = "musllinux_1_2" # RUNNER_OS is a GitHub Actions specific env var; define it here so it's # defined when running cibuildwheel locally RUNNER_OS="Linux" -# /project will be the $PWD equivalent inside the Docker container used to build the wheel -PKG_CONFIG_PATH="/project/.openblas" [tool.cibuildwheel.windows] config-settings = {setup-args = ["--vsenv", "-Dallow-noblas=false"], build-dir="build"} repair-wheel-command = "bash -el ./tools/wheels/repair_windows.sh {wheel} {dest_dir}" +[[tool.cibuildwheel.overrides]] +select = ["*-android_*", "*-*linux_*"] +environment.PKG_CONFIG_PATH = "$(pwd)/.openblas" + [[tool.cibuildwheel.overrides]] select = ["*-win32"] config-settings = {setup-args = ["--vsenv", "-Dallow-noblas=true"], build-dir="build"} repair-wheel-command = "" +[[tool.cibuildwheel.overrides]] +select = ["*-android*", "*-ios*"] +before-test = "" +test-groups = ["test-core"] + +[[tool.cibuildwheel.overrides]] +select = ["*-android*", "*-ios*", "*-pyodide*"] +# Mobile and WASM platforms can't run the cibw_test_command shell script, so they must +# run Python directly. +test-command = """ + python -m pytest --pyargs numpy \ + -m 'not slow' \ + -W ignore::PendingDeprecationWarning \ + -p no:cacheprovider +""" + [tool.cibuildwheel.pyodide] # Pyodide ensures that the wheels are already repaired by auditwheel-emscripten repair-wheel-command = "" -test-command = "python -m pytest --pyargs numpy -m 'not slow'" [tool.cibuildwheel.pyodide.config-settings] build-dir = "build" -setup-args = ["--cross-file=$SRC/tools/ci/emscripten/emscripten.meson.cross", "-Dblas=none", "-Dlapack=none"] +setup-args = ["--cross-file={package}/tools/ci/emscripten/emscripten.meson.cross", "-Dblas=none", "-Dlapack=none"] diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh index b3ac41e..28ebe68 100644 --- a/tools/wheels/cibw_before_build.sh +++ b/tools/wheels/cibw_before_build.sh @@ -1,8 +1,7 @@ set -xe -PROJECT_DIR="${1:-$PWD}" -NUMPY_SRC_DIR="${1:-$PWD}/numpy-src" - +PROJECT_DIR="${1:?}" +NUMPY_SRC_DIR="${2:?}" # Update license echo "" >> $NUMPY_SRC_DIR/LICENSE.txt @@ -24,7 +23,6 @@ if [[ $(python -c"import sys; print(sys.maxsize)") < $(python -c"import sys; pri export INSTALL_OPENBLAS=false fi -OPENBLAS_GRP="" # Install OpenBLAS from scipy-openblas32|64 if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then # By default, use scipy-openblas64 @@ -34,7 +32,6 @@ if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then if [[ $RUNNER_ARCH == "ARM64" && $RUNNER_OS == "Windows" ]] ; then OPENBLAS=openblas32 fi - OPENBLAS_GRP="--group $OPENBLAS" fi # install build dependencies via uv @@ -43,8 +40,22 @@ uv --version # the lock file lives in this repo, not in the numpy checkout; the check_lock job in # wheels.yml verifies it still matches numpy's dependency groups PYTHON_EXE="$(python -c 'import sys; print(sys.executable)')" -uv export --project "$PROJECT_DIR" --no-default-groups --group build --no-emit-project $OPENBLAS_GRP --frozen | \ - uv pip install --python "$PYTHON_EXE" --no-deps --require-hashes -r - + +function install_group { + uv export --project "$PROJECT_DIR" --no-default-groups --group ${1:?} --no-emit-project --frozen | \ + uv pip install --python "$PYTHON_EXE" --no-deps --require-hashes -r - +} + +# On Android we need to temporarily clear CIBW_HOST_TRIPLET in order to install build +# tools for the build platform, not the host platform. +CIBW_HOST_TRIPLET= install_group build + +# uv caches each virtual environment's platform, so we need to clear that before +# installing OpenBLAS for the host system. +uv cache clear +if [ -n "$OPENBLAS" ]; then + install_group $OPENBLAS +fi # Configure the pkg-config file for OpenBLAS if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then From 67cf6f2146a496cf82bd40df9f0508e28c4a1bfc Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Sat, 14 Nov 2026 01:32:19 +0000 Subject: [PATCH 2/5] Temporarily disable `if` lines --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7ff79e5..3e7f50f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -45,7 +45,7 @@ jobs: check_lock: name: Check uv.lock file runs-on: ubuntu-latest - if: (github.repository == 'numpy/numpy-release' || github.repository == '') + # FIXME if: (github.repository == 'numpy/numpy-release' || github.repository == '') steps: - name: Checkout numpy-release @@ -91,7 +91,7 @@ jobs: build_wheels: - if: github.repository == 'numpy/numpy-release' + # FIXME if: github.repository == 'numpy/numpy-release' name: ${{ matrix.python }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }} runs-on: ${{ matrix.buildplat[0] }} needs: [check_lock] From cf145fab0cf9c8b78657746800ed30e32ba56a82 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Sat, 14 Nov 2026 13:27:18 +0000 Subject: [PATCH 3/5] Linux and iOS fixes --- .github/workflows/wheels.yml | 14 ++++---------- cibuildwheel.toml | 8 ++++++-- tools/wheels/cibw_before_build.sh | 21 +++++++++++++++++---- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 3e7f50f..4e2581c 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -112,14 +112,15 @@ jobs: # # targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile # - [macos-15-intel, macosx_x86_64, accelerate] # - [macos-15, macosx_arm64, openblas] - # - [macos-15, macosx_arm64, accelerate] - # - [windows-2022, win_amd64, ""] + - [macos-15, macosx_arm64, accelerate] + - [windows-2022, win_amd64, ""] + # FIXME # - [windows-11-arm, win_arm64, ""] - [ubuntu-24.04, android_arm64_v8a] - [ubuntu-24.04, android_x86_64] - [macos-26, ios_arm64_iphoneos] - [macos-26, ios_arm64_iphonesimulator] - python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"] + python: ["cp313"] # FIXME ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"] exclude: - buildplat: [ macos-15-intel, macosx_x86_64, openblas ] python: "cp314t" @@ -211,13 +212,6 @@ jobs: echo "CIBW_ENVIRONMENT_MACOS=PKG_CONFIG_PATH=$PWD/.openblas" >> "$GITHUB_ENV" fi - - name: Setup iOS - if: startsWith(matrix.buildplat[1], 'ios_') - run: | - # ACCELERATE_NEW_LAPACK with ILP64 requires a higher iOS version than - # cibuildwheel's default. - echo "CIBW_ENVIRONMENT_IOS=IPHONEOS_DEPLOYMENT_TARGET=17.0" >> "$GITHUB_ENV" - - name: Pyodide setup if: ${{ matrix.buildplat[1] == 'pyodide_wasm32' }} run: | diff --git a/cibuildwheel.toml b/cibuildwheel.toml index 6a818fb..e536045 100644 --- a/cibuildwheel.toml +++ b/cibuildwheel.toml @@ -21,8 +21,11 @@ setup-args = ["-Duse-ilp64=true", "-Dallow-noblas=false"] build-dir = "build" [tool.cibuildwheel.ios] -before-build = [] -xbuild-tools = ["ninja"] +# ACCELERATE_NEW_LAPACK with ILP64 requires a higher iOS version than cibuildwheel's +# default. +environment.IPHONEOS_DEPLOYMENT_TARGET = "17.0" +environment.INSTALL_OPENBLAS = "false" +xbuild-tools = ["ninja", "uv"] [tool.cibuildwheel.linux] manylinux-x86_64-image = "manylinux_2_28" @@ -41,6 +44,7 @@ repair-wheel-command = "bash -el ./tools/wheels/repair_windows.sh {wheel} {dest_ [[tool.cibuildwheel.overrides]] select = ["*-android_*", "*-*linux_*"] +inherit.environment = "append" environment.PKG_CONFIG_PATH = "$(pwd)/.openblas" [[tool.cibuildwheel.overrides]] diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh index 28ebe68..1232495 100644 --- a/tools/wheels/cibw_before_build.sh +++ b/tools/wheels/cibw_before_build.sh @@ -46,12 +46,25 @@ function install_group { uv pip install --python "$PYTHON_EXE" --no-deps --require-hashes -r - } -# On Android we need to temporarily clear CIBW_HOST_TRIPLET in order to install build -# tools for the build platform, not the host platform. -CIBW_HOST_TRIPLET= install_group build +# When cross-compiling, we need to temporarily modify the virtual environment in order +# to install for the build platform, not the host platform. +site_packages=$(python3 -c ' +import sys +print(next(entry for entry in sys.path if entry.endswith("site-packages"))) +') +cross_pth="$site_packages/_cross_venv.pth" +if [ -e "$cross_pth" ]; then + mv "$cross_pth" "$cross_pth.disabled" +fi + +install_group build + +if [ -e "$cross_pth.disabled" ]; then + mv "$cross_pth.disabled" "$cross_pth" +fi # uv caches each virtual environment's platform, so we need to clear that before -# installing OpenBLAS for the host system. +# installing OpenBLAS for the host platform. uv cache clear if [ -n "$OPENBLAS" ]; then install_group $OPENBLAS From bad3cea54cc98f0b8138e43e1d41dc0901f08717 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Sat, 14 Nov 2026 14:15:14 +0000 Subject: [PATCH 4/5] Enable all wheels --- .github/workflows/wheels.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 4e2581c..16fd490 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -103,24 +103,22 @@ jobs: # https://github.com/github/feedback/discussions/7835#discussioncomment-1769026 buildplat: - [ubuntu-24.04, manylinux_x86_64, ""] - # FIXME - # - [ubuntu-24.04, musllinux_x86_64, ""] - # - [ubuntu-24.04-arm, manylinux_aarch64, ""] - # - [ubuntu-24.04-arm, musllinux_aarch64, ""] - # - [macos-15-intel, macosx_x86_64, openblas] - - # # targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile - # - [macos-15-intel, macosx_x86_64, accelerate] - # - [macos-15, macosx_arm64, openblas] + - [ubuntu-24.04, musllinux_x86_64, ""] + - [ubuntu-24.04-arm, manylinux_aarch64, ""] + - [ubuntu-24.04-arm, musllinux_aarch64, ""] + - [macos-15-intel, macosx_x86_64, openblas] + + # targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile + - [macos-15-intel, macosx_x86_64, accelerate] + - [macos-15, macosx_arm64, openblas] - [macos-15, macosx_arm64, accelerate] - [windows-2022, win_amd64, ""] - # FIXME - # - [windows-11-arm, win_arm64, ""] + - [windows-11-arm, win_arm64, ""] - [ubuntu-24.04, android_arm64_v8a] - [ubuntu-24.04, android_x86_64] - [macos-26, ios_arm64_iphoneos] - [macos-26, ios_arm64_iphonesimulator] - python: ["cp313"] # FIXME ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"] + python: ["cp312", "cp313", "cp314", "cp314t", "cp315", "cp315t"] exclude: - buildplat: [ macos-15-intel, macosx_x86_64, openblas ] python: "cp314t" From ecba1e957af98c3d9b86294fb7c5618b93934ca5 Mon Sep 17 00:00:00 2001 From: Malcolm Smith Date: Sat, 14 Nov 2026 17:02:36 +0000 Subject: [PATCH 5/5] Revert temporary changes --- .github/workflows/wheels.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 16fd490..b363b9e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -23,9 +23,8 @@ on: - main - maintenance/** push: - # FIXME - # branches: - # - main # FOR TESTING ONLY + branches: + - main # FOR TESTING ONLY workflow_dispatch: inputs: environment: @@ -45,7 +44,7 @@ jobs: check_lock: name: Check uv.lock file runs-on: ubuntu-latest - # FIXME if: (github.repository == 'numpy/numpy-release' || github.repository == '') + if: (github.repository == 'numpy/numpy-release' || github.repository == '') steps: - name: Checkout numpy-release @@ -91,7 +90,7 @@ jobs: build_wheels: - # FIXME if: github.repository == 'numpy/numpy-release' + if: github.repository == 'numpy/numpy-release' name: ${{ matrix.python }}-${{ matrix.buildplat[1] }} ${{ matrix.buildplat[2] }} runs-on: ${{ matrix.buildplat[0] }} needs: [check_lock]