8000 CI Adds macOS arm64 wheel building [cd build cirrus] [cd build gh] · scikit-learn/scikit-learn@aae48fe · GitHub
[go: up one dir, main page]

Skip to content

Commit aae48fe

Browse files
committed
CI Adds macOS arm64 wheel building [cd build cirrus] [cd build gh]
1 parent 9a98487 commit aae48fe

File tree

6 files changed

+86
-6
lines changed

6 files changed

+86
-6
lines changed

.cirrus.star

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This script uses starlark for configuring when a cirrus CI job runs:
2+
# https://cirrus-ci.org/guide/programming-tasks/
3+
4+
load("cirrus", "env", "fs", "http")
5+
6+
def main(ctx):
7+
# Only run for scikit-learn/scikit-learn. For debugging on a fork, you can
8+
# comment out the following condition.
9+
# if env.get("CIRRUS_REPO_FULL_NAME") != "scikit-learn/scikit-learn":
10+
# return []
11+
12+
arm_wheel_yaml = "build_tools/cirrus/arm_wheel.yml"
13+
14+
# Nightly jobs always run
15+
if env.get("CIRRUS_CRON", "") == "nightly":
16+
return fs.read(arm_wheel_yaml)
17+
18+
# Get commit message for event. There is not command line access in starlark,
19+
# so we need to query the GitHub API for the commit message.
20+
# Note that `CIRRUS_CHANGE_MESSAGE` can not be used because it is set to
21+
# a the PR's title and not the latest commit message in the PR.
22+
SHA = env.get("CIRRUS_CHANGE_IN_REPO")
23+
REPO = env.get("CIRRUS_REPO_FULL_NAME")
24+
url = "https://api.github.com/repos/" + REPO + "/git/commits/" + SHA
25+
response = http.get(url).json()
26+
commit_msg = response["message"]
27+
28+
if "[skip ci]" in commit_msg or ("[cd build]" not in commit_msg and "[cd build cirrus]" not in commit_msg):
29+
return []
30+
31+
return fs.read(arm_wheel_yaml)

.github/workflows/wheels.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ jobs:
145145
CIBW_TEST_COMMAND: bash {project}/build_tools/github/test_wheels.sh
146146
CIBW_TEST_COMMAND_WINDOWS: bash {project}/build_tools/github/test_windows_wheels.sh ${{ matrix.python }}
147147
CIBW_BUILD_VERBOSITY: 1
148+
CONDA_HOME: /usr/local/miniconda
148149

149150
run: bash build_tools/github/build_wheels.sh
150151

build_tools/cirrus/arm_wheel.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
macos_arm64_wheel_task:
2+
macos_instance:
3+
image: ghcr.io/cirruslabs/macos-monterey-xcode
4+
env:
5+
CONFTEST_PATH: ${CIRRUS_WORKING_DIR}/conftest.py
6+
CONFTEST_NAME: conftest.py
7+
CIBW_ENVIRONMENT: OMP_NUM_THREADS=2
8+
OPENBLAS_NUM_THREADS=2
9+
SKLEARN_SKIP_NETWORK_TESTS=1
10+
SKLEARN_BUILD_PARALLEL=5
11+
CPU_COUNT=2
12+
CIBW_TEST_COMMAND: bash {project}/build_tools/github/test_wheels.sh
13+
CIBW_TEST_REQUIRES: pytest pandas threadpoolctl pytest-xdist
14+
CIBW_BUILD_VERBOSITY: 1
15+
PATH: $HOME/mambaforge/bin/:$PATH
16+
CONDA_HOME: $HOME/mambaforge
17+
matrix:
18+
- env:
19+
# cibuildwheel can not test on Python 3.8 even on a Apple Silicon machine.
20+
# For details see: https://github.com/pypa/cibuildwheel/pull/1169
21+
CIBW_BUILD: cp38-macosx_arm64
22+
CIBW_TEST_SKIP: "*"
23+
- env:
24+
CIBW_BUILD: cp39-macosx_arm64
25+
- env:
26+
CIBW_BUILD: cp310-macosx_arm64
27+
- env:
28+
CIBW_BUILD: cp311-macosx_arm64
29+
30+
conda_script:
31+
- curl -L -o ~/mambaforge.sh https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
32+
- bash ~/mambaforge.sh -b -p ~/mambaforge
33+
34+
cibuildwheel_script:
35+
- bash build_tools/github/build_wheels.sh
36+
37+
wheels_artifacts:
38+
path: "wheelhouse/*"

build_tools/github/build_wheels.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ set -e
44
set -x
55

66
# OpenMP is not present on macOS by default
7-
if [[ "$RUNNER_OS" == "macOS" ]]; then
7+
if [[ $(uname) == "Darwin" ]]; then
88
# Make sure to use a libomp version binary compatible with the oldest
99
# supported version of the macos SDK as libomp will be vendored into the
1010
# scikit-learn wheels for macos.
1111

1212
if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then
13-
# arm64 builds must cross compile because CI is on x64
14-
export PYTHON_CROSSENV=1
13+
if [[ $(uname -m) == "x86_64" ]]; then
14+
# arm64 builds must cross compile because CI is on x64
15+
export PYTHON_CROSSENV=1
16+
fi
1517
# SciPy requires 12.0 on arm to prevent kernel panics
1618
# https://github.com/scipy/scipy/issues/14688
1719
# We use the same deployment target to match SciPy.
@@ -23,7 +25,7 @@ if [[ "$RUNNER_OS" == "macOS" ]]; then
2325
fi
2426

2527
sudo conda create -n build $OPENMP_URL
26-
PREFIX="/usr/local/miniconda/envs/build"
28+
PREFIX="$CONDA_HOME/envs/build"
2729

2830
export CC=/usr/bin/clang
2931
export CXX=/usr/bin/clang++

build_tools/github/test_wheels.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
set -e
44
set -x
55

6-
if [[ "$OSTYPE" != "linux-gnu" ]]; then
6+
UNAME=$(uname)
7+
8+
if [[ "$UNAME" != "Linux" ]]; then
79
# The Linux test environment is run in a Docker container and
810
# it is not possible to copy the test configuration file (yet)
911
cp $CONFTEST_PATH $CONFTEST_NAME
@@ -12,4 +14,9 @@ fi
1214
# Test that there are no links to system libraries in the
1315
# threadpoolctl output section of the show_versions output:
1416
python -c "import sklearn; sklearn.show_versions()"
15-
pytest --pyargs sklearn
17+
18+
if [ ! -z "$CPU_COUNT" ]; then
19+
pytest --pyargs sklearn -n $CPU_COUNT
20+
else
21+
pytest --pyargs sklearn
22+
fi

doc/developers/contributing.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ message, the following actions are taken.
546546
[ci skip] CI is skipped completely
547547
[cd build] CD is run (wheels and source distribution are built)
548548
[cd build gh] CD is run only for GitHub Actions
549+
[cd build cirrus] CD is run only for Cirrus CI
549550
[lint skip] Azure pipeline skips linting
550551
[scipy-dev] Build & test with our dependencies (numpy, scipy, etc ...) development builds
551552
[nogil] Build & test with the nogil experimental branches of CPython, Cython, NumPy, SciPy...

0 commit comments

Comments
 (0)
0