diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ae3c6cab0216e..f0f3427961cb8 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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 @@ -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 diff --git a/build_tools/github/build_wheels.sh b/build_tools/github/build_wheels.sh index 2671c50f66bb3..0a8f93e3d2c0b 100755 --- a/build_tools/github/build_wheels.sh +++ b/build_tools/github/build_wheels.sh @@ -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 diff --git a/sklearn/_build_utils/openmp_helpers.py b/sklearn/_build_utils/openmp_helpers.py index ebb3e67cd058f..192e96cd30765 100644 --- a/sklearn/_build_utils/openmp_helpers.py +++ b/sklearn/_build_utils/openmp_helpers.py @@ -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 diff --git a/sklearn/_build_utils/pre_build_helpers.py b/sklearn/_build_utils/pre_build_helpers.py index 15bf2ba41dbc5..bf898a1b6639f 100644 --- a/sklearn/_build_utils/pre_build_helpers.py +++ b/sklearn/_build_utils/pre_build_helpers.py @@ -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