8000 BLD: try to build most macOS wheels on GHA (#25945) · numpy/numpy@4913772 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4913772

Browse files
authored
BLD: try to build most macOS wheels on GHA (#25945)
1 parent 7fc3d0f commit 4913772

File tree

4 files changed

+49
-34
lines changed

4 files changed

+49
-34
lines changed

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
name: macOS x86-64 conda
2222
# To enable this workflow on a fork, comment out:
2323
if: github.repository == 'numpy/numpy'
24-
runs-on: macos-latest
24+
runs-on: macos-13
2525
strategy:
2626
fail-fast: false
2727
matrix:

.github/workflows/wheels.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
echo github.ref ${{ github.ref }}
5959
6060
build_wheels:
61-
name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }}
61+
name: Build wheel ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
6262
needs: get_commit_message
6363
if: >-
6464
contains(needs.get_commit_message.outputs.message, '[wheel build]') ||
@@ -73,11 +73,15 @@ jobs:
7373
# Github Actions doesn't support pairing matrix values together, let's improvise
7474
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
7575
buildplat:
76-
- [ubuntu-20.04, manylinux_x86_64]
77-
- [ubuntu-20.04, musllinux_x86_64]
78-
- [macos-12, macosx_x86_64]
79-
- [windows-2019, win_amd64]
80-
- [windows-2019, win32]
76+
- [ubuntu-20.04, manylinux_x86_64, ""]
77+
- [ubuntu-20.04, musllinux_x86_64, ""]
78+
- [macos-13, macosx_x86_64, openblas]
79+
80+
# targeting macos >= 14. Could probably build on macos-14, but it would be a cross-compile
81+
- [macos-13, macosx_x86_64, accelerate]
82+
- [macos-14, macosx_arm64, accelerate] # always use accelerate
83+
- [windows-2019, win_amd64, ""]
84+
- [windows-2019, win32, ""]
8185
python: ["cp39", "cp310", "cp311", "cp312", "pp39"]
8286
exclude:
8387
# Don't build PyPy 32-bit windows
@@ -123,6 +127,27 @@ jobs:
123127
with:
124128
python-version: "3.x"
125129

130+
- name: Setup macOS
131+
if: matrix.buildplat[0] == 'macos-13' || matrix.buildplat[0] == 'macos-14'
132+
run: |
133+
if [[ ${{ matrix.buildplat[2] }} == 'accelerate' ]]; then
134+
# macosx_arm64 and macosx_x86_64 with accelerate
135+
# only target Sonoma onwards
136+
CIBW="MACOSX_DEPLOYMENT_TARGET=14.0 INSTALL_OPENBLAS=false RUNNER_OS=macOS"
137+
echo "CIBW_ENVIRONMENT_MACOS=$CIBW" >> "$GITHUB_ENV"
138+
139+
# the macos-13 image that's used for building the x86_64 wheel can't test
140+
# a wheel with deployment target >= 14 without further work
141+
echo "CIBW_TEST_SKIP=*-macosx_x86_64" >> "$GITHUB_ENV"
142+
else
143+
# macosx_x86_64 with OpenBLAS
144+
# if INSTALL_OPENBLAS isn't specified then scipy-openblas is automatically installed
145+
CIBW="RUNNER_OS=macOS"
146+
PKG_CONFIG_PATH="$PWD/.openblas"
147+
DYLD="$DYLD_LIBRARY_PATH:/$PWD/.openblas/lib"
148+
echo "CIBW_ENVIRONMENT_MACOS=$CIBW PKG_CONFIG_PATH=$PKG_CONFIG_PATH DYLD_LIBRARY_PATH=$DYLD" >> "$GITHUB_ENV"
149+
fi
150+
126151
- name: Build wheels
127152
uses: pypa/cibuildwheel@ce3fb7832089eb3e723a0a99cab7f3eaccf074fd # v2.16.5
128153
env:
@@ -131,18 +156,21 @@ jobs:
131156

132157
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
133158
with:
134-
name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }}
159+
name: ${{ matrix.python }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}
135160
path: ./wheelhouse/*.whl
136161

137-
- uses: conda-incubator/setup-miniconda@030178870c779d9e5e1b4e563269f3aa69b04081 # v3.0.3
162+
- uses: mamba-org/setup-micromamba@v1
138163
with:
139164
# for installation of anaconda-client, required for upload to
140165
# anaconda.org
141-
# default (and activated) environment name is test
142166
# Note that this step is *after* specific pythons have been used to
143167
# build and test the wheel
144-
auto-update-conda: true
145-
python-version: "3.10"
168+
# for installation of anaconda-client, for upload to anaconda.org
169+
# environment will be activated after creation, and in future bash steps
170+
init-shell: bash
171+
environment-name: upload-env
172+
create-args: >-
173+
anaconda-client
146174
147175
- name: Upload wheels
148176
if: success()
@@ -153,7 +181,6 @@ jobs:
153181
NUMPY_STAGING_UPLOAD_TOKEN: ${{ secrets.NUMPY_STAGING_UPLOAD_TOKEN }}
154182
NUMPY_NIGHTLY_UPLOAD_TOKEN: ${{ secrets.NUMPY_NIGHTLY_UPLOAD_TOKEN }}
155183
run: |
156-
conda install -y anaconda-client
157184
source tools/wheels/upload_wheels.sh
158185
set_upload_vars
159186
# trigger an upload to

pyproject.toml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ tracker = "https://github.com/numpy/numpy/issues"
140140
# build wheels for in CI are controlled in `.github/workflows/wheels.yml` and
141141
# `tools/ci/cirrus_wheels.yml`.
142142
build-frontend = "build"
143-
skip = "cp36-* cp37-* cp-38* pp37-* *-manylinux_i686 *_ppc64le *_s390x"
143+
skip = "cp36-* cp37-* cp-38* pp37-* *-manylinux_i686 *_ppc64le *_s390x *_universal2"
144144
before-build = "bash {project}/tools/wheels/cibw_before_build.sh {project}"
145145
# The build will use openblas64 everywhere, except on arm64 macOS >=14.0 (uses Accelerate)
146146
config-settings = "setup-args=-Duse-ilp64=true setup-args=-Dallow-noblas=false build-dir=build"
@@ -161,21 +161,15 @@ LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/project/.openblas/lib"
161161

162162
[tool.cibuildwheel.macos]
163163
# universal2 wheels are not supported (see gh-21233), use `delocate-fuse` if you need them
164-
archs = "x86_64 arm64"
165-
test-skip = "*_universal2:arm64"
164+
# note that universal2 wheels are not built, they're listed in the tool.cibuildwheel.skip
165+
# section
166166
# Not clear why the DYLD_LIBRARY_PATH is not passed through from the environment
167167
repair-wheel-command = [
168168
"export DYLD_LIBRARY_PATH=$PWD/.openblas/lib",
169169
"echo DYLD_LIBRARY_PATH $DYLD_LIBRARY_PATH",
170170
"delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}",
171171
]
172172

173-
[tool.cibuildwheel.macos.environment]
174-
# In cibuildwheel, {project} is $PWD
175-
RUNNER_OS="macOS"
176-
PKG_CONFIG_PATH="$PWD/.openblas"
177-
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/$PWD/.openblas/lib"
178-
179173
[tool.cibuildwheel.windows]
180174
# This does not work, use CIBW_ENVIRONMENT_WINDOWS
181175
environment = {PKG_CONFIG_PATH="./.openblas"}

tools/ci/cirrus_wheels.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ linux_aarch64_task:
5050

5151
######################################################################
5252
# Build macosx_arm64 natively
53+
#
54+
# macosx_arm64 for macos >= 14 used to be built here, but are now
55+
# built on GHA.
5356
######################################################################
5457

5558
macosx_arm64_task:
5659
use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
5760
macos_instance:
5861
matrix:
59-
image: ghcr.io/cirruslabs/macos-sonoma-xcode
6062
image: ghcr.io/cirruslabs/macos-monterey-xcode
6163

6264
matrix:
@@ -81,18 +83,10 @@ macosx_arm64_task:
8183
8284
ver=$(sw_vers -productVersion)
8385
macos_target=$(python -c "print('14.0') if '$ver' >= '14.0' else print('11.0')")
84-
if [ $macos_target == '14.0' ]; then
85-
# Use native Accelerate
86-
export INSTALL_OPENBLAS=false
87-
export CIBW_ENVIRONMENT_MACOS="MACOSX_DEPLOYMENT_TARGET=$macos_target INSTALL_OPENBLAS=false RUNNER_OS=macOS"
88-
# export CIBW_REPAIR_WHEEL_COMMAND_MACOS=""
89-
else
90-
# Use scipy-openblas wheels
91-
export INSTALL_OPENBLAS=true
92-
export CIBW_ENVIRONMENT_MACOS="MACOSX_DEPLOYMENT_TARGET=$macos_target INSTALL_OPENBLAS=true RUNNER_OS=macOS PKG_CONFIG_PATH=$PWD/.openblas"
93-
fi
86+
# Use scipy-openblas wheels
87+
export INSTALL_OPENBLAS=true
88+
export CIBW_ENVIRONMENT_MACOS="MACOSX_DEPLOYMENT_TARGET=$macos_target INSTALL_OPENBLAS=true RUNNER_OS=macOS PKG_CONFIG_PATH=$PWD/.openblas"
9489
95-
9690
# needed for submodules
9791
git submodule update --init
9892
# need to obtain all the tags so setup.py can determine FULLVERSION

0 commit comments

Comments
 (0)
0