diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b7d002f..b363b9e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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] }} runs-on: ${{ matrix.buildplat[0] }} needs: [check_lock] strategy: @@ -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] + - [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 @@ -195,15 +212,12 @@ jobs: - 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..e536045 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,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" @@ -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"] diff --git a/tools/wheels/cibw_before_build.sh b/tools/wheels/cibw_before_build.sh index b3ac41e..1232495 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,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