Skip to content

Commit

Permalink
CI Build macOS arm wheels [cd build gh] (#21827)
Browse files Browse the repository at this point in the history
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Olivier Grisel <olivier.grisel@gmail.com>
  • Loading branch information
3 people committed Dec 2, 2021
1 parent 8876439 commit 594b1f7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/wheels.yml
Expand Up @@ -173,6 +173,20 @@ jobs:
python: 310
platform_id: macosx_x86_64

# MacOS arm64
- os: macos-latest
bitness: 64
python: 38
platform_id: macosx_arm64
- os: macos-latest
bitness: 64
python: 39
platform_id: macosx_arm64
- os: macos-latest
bitness: 64
python: 310
platform_id: macosx_arm64

steps:
- name: Checkout scikit-learn
uses: actions/checkout@v1
Expand All @@ -190,10 +204,11 @@ jobs:
OPENBLAS_NUM_THREADS=2
SKLEARN_SKIP_NETWORK_TESTS=1
SKLEARN_BUILD_PARALLEL=3
MACOSX_DEPLOYMENT_TARGET=10.13
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: bash build_tools/github/repair_windows_wheels.sh {wheel} {dest_dir} ${{ matrix.bitness }}
CIBW_BEFORE_TEST_WINDOWS: bash build_tools/github/build_minimal_windows_image.sh ${{ matrix.python }} ${{ matrix.bitness }}
CIBW_TEST_REQUIRES: pytest pandas threadpoolctl
Expand Down
20 changes: 15 additions & 5 deletions build_tools/github/build_wheels.sh
Expand Up @@ -8,11 +8,21 @@ if [[ "$RUNNER_OS" == "macOS" ]]; then
# Make sure to use a libomp version binary compatible with the oldest
# supported version of the macos SDK as libomp will be vendored into the
# scikit-learn wheels for macos. The list of binaries are in
# https://packages.macports.org/libomp/. Currently, the oldest
# supported macos version is: High Sierra / 10.13. When upgrading this, be
# sure to update the MACOSX_DEPLOYMENT_TARGET environment variable in
# wheels.yml accordingly. Note that Darwin_17 == High Sierra / 10.13.
wget https://packages.macports.org/libomp/libomp-11.0.1_0+universal.darwin_17.i386-x86_64.tbz2 -O libomp.tbz2
# https://packages.macports.org/libomp/.
if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then
# arm64 builds must cross compile because CI is on x64
export PYTHON_CROSSENV=1
# SciPy requires 12.0 on arm to prevent kernel panics
# https://github.com/scipy/scipy/issues/14688
# We use the same deployment target to match SciPy.
export MACOSX_DEPLOYMENT_TARGET=12.0
wget https://packages.macports.org/libomp/libomp-11.0.1_0.darwin_20.arm64.tbz2 -O libomp.tbz2
else
# Currently, the oldest supported macos version is: High Sierra / 10.13.
# Note that Darwin_17 == High Sierra / 10.13.
export MACOSX_DEPLOYMENT_TARGET=10.13
wget https://packages.macports.org/libomp/libomp-11.0.1_0+universal.darwin_17.i386-x86_64.tbz2 -O libomp.tbz2
fi
sudo tar -C / -xvjf libomp.tbz2 opt

export CC=/usr/bin/clang
Expand Down
1 change: 1 addition & 0 deletions sklearn/_build_utils/openmp_helpers.py
Expand Up @@ -49,6 +49,7 @@ def check_openmp_support():
if "PYODIDE_PACKAGE_ABI" in os.environ:
# Pyodide doesn't support OpenMP
return False

code = textwrap.dedent(
"""\
#include <omp.h>
Expand Down
1 change: 1 addition & 0 deletions sklearn/_build_utils/pre_build_helpers.py
Expand Up @@ -102,6 +102,7 @@ def basic_check_build():
if "PYODIDE_PACKAGE_ABI" in os.environ:
# The following check won't work in pyodide
return

code = textwrap.dedent(
"""\
#include <stdio.h>
Expand Down

0 comments on commit 594b1f7

Please sign in to comment.