Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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] }}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shortening the name makes the web UI much more readable, especially when expanding the matrix in the flowchart.

runs-on: ${{ matrix.buildplat[0] }}
needs: [check_lock]
strategy:
Expand All @@ -113,15 +113,32 @@ jobs:
- [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]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold on, what's with the two entries for iOS and android?

I can't remember that being discussed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss it in numpy/numpy#33334.

- [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
Expand Down Expand Up @@ -195,15 +212,12 @@ jobs:
- name: Pyodide setup
if: ${{ matrix.buildplat[1] == 'pyodide_wasm32' }}
run: |
echo "CIBW_PLATFORM=pyodide" >> "$GITHUB_ENV"

@mhsmith mhsmith Nov 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this variable because it's unnecessary when using the only argument.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SRC was only used in one place in cibuildwheel.toml, where I've replaced it with cibuildwheel's built-in {package} syntax.

with:
only: ${{ matrix.python }}-${{ matrix.buildplat[1] }}
package-dir: numpy-src
output-dir: dist
config-file: cibuildwheel.toml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.openblas
numpy-src
dist
35 changes: 30 additions & 5 deletions cibuildwheel.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -20,6 +20,13 @@ enable = ["cpython-prerelease"]
setup-args = ["-Duse-ilp64=true", "-Dallow-noblas=false"]
build-dir = "build"

[tool.cibuildwheel.ios]
# 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"
manylinux-aarch64-image = "manylinux_2_28"
Expand All @@ -30,23 +37,41 @@ 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_*"]
inherit.environment = "append"
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"]
38 changes: 31 additions & 7 deletions tools/wheels/cibw_before_build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
set -xe

PROJECT_DIR="${1:-$PWD}"
NUMPY_SRC_DIR="${1:-$PWD}/numpy-src"

PROJECT_DIR="${1:?}"
NUMPY_SRC_DIR="${2:?}"

@mhsmith mhsmith Nov 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed NUMPY_SRC_DIR to a command-line argument, to make it more convenient to run cibuildwheel locally against an arbitrary NumPy checkout.


# Update license
echo "" >> $NUMPY_SRC_DIR/LICENSE.txt
Expand All @@ -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
Expand All @@ -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
Expand All @@ -43,8 +40,35 @@ 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 -
}

# 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 platform.
uv cache clear
if [ -n "$OPENBLAS" ]; then
install_group $OPENBLAS
fi

# Configure the pkg-config file for OpenBLAS
if [[ "$INSTALL_OPENBLAS" = "true" ]] ; then
Expand Down