-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Build Python wheels for MacOS (x86_64 and arm64) (#7621)
* Build Python wheels for OSX (x86_64 and arm64) * Use Conda's libomp when running Python tests * fix * Add comment to explain CIBW_TARGET_OSX_ARM64 * Update release script * Add comments in build_python_wheels.sh * Document wheel pipeline
- Loading branch information
Showing
8 changed files
with
123 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: XGBoost-Python-Wheels | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
python-wheels: | ||
name: Build wheel for ${{ matrix.platform_id }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: macos-latest | ||
python: 37 | ||
platform_id: macosx_x86_64 | ||
wheel_tag: macosx_10_15_x86_64.macosx_11_0_x86_64.macosx_12_0_x86_64 | ||
- os: macos-latest | ||
python: 38 | ||
platform_id: macosx_arm64 | ||
wheel_tag: macosx_12_0_arm64 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: 'true' | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
- name: Set env var for ARM64 | ||
shell: bash | ||
run: echo "::set-output name=value::CIBW_TARGET_OSX_ARM64=1" | ||
id: arm64_flag | ||
if: matrix.platform_id == 'macosx_arm64' | ||
- name: Build wheels | ||
env: | ||
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} | ||
CIBW_ARCHS: all | ||
CIBW_ENVIRONMENT: ${{ steps.arm64_flag.outputs.value }} | ||
CIBW_TEST_SKIP: "*-macosx_arm64" | ||
CIBW_BUILD_VERBOSITY: 3 | ||
run: bash tests/ci_build/build_python_wheels.sh | ||
|
||
- name: Rename Python wheel | ||
run: | | ||
python tests/ci_build/rename_whl.py wheelhouse/*.whl ${{ github.sha }} ${{ matrix.wheel_tag }} | ||
- name: Extract branch name | ||
shell: bash | ||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
id: extract_branch | ||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/heads/release_') | ||
- name: Upload Python wheel | ||
if: github.ref == 'refs/heads/master' || contains(github.ref, 'refs/heads/release_') | ||
run: | | ||
python -m pip install awscli | ||
python -m awscli s3 cp wheelhouse/*.whl s3://xgboost-nightly-builds/${{ steps.extract_branch.outputs.branch }}/ --acl public-read | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_IAM_S3_UPLOADER }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_IAM_S3_UPLOADER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -x | ||
|
||
# Bundle libomp 11.1.0 when targeting MacOS. | ||
# This is a workaround in order to prevent segfaults when running inside a Conda environment. | ||
# See https://github.com/dmlc/xgboost/issues/7039#issuecomment-1025125003 for more context. | ||
# The workaround is also used by the scikit-learn project. | ||
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 | ||
# XGBoost wheels for MacOS. | ||
|
||
if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then | ||
# arm64 builds must cross compile because CI is on x64 | ||
# cibuildwheel will take care of cross-compilation. | ||
export PYTHON_CROSSENV=1 | ||
export MACOSX_DEPLOYMENT_TARGET=12.0 | ||
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-arm64/llvm-openmp-11.1.0-hf3c4609_1.tar.bz2" | ||
else | ||
export MACOSX_DEPLOYMENT_TARGET=10.13 | ||
OPENMP_URL="https://anaconda.org/conda-forge/llvm-openmp/11.1.0/download/osx-64/llvm-openmp-11.1.0-hda6cdc1_1.tar.bz2" | ||
fi | ||
|
||
sudo conda create -n build $OPENMP_URL | ||
PREFIX="/usr/local/miniconda/envs/build" | ||
|
||
export CC=/usr/bin/clang | ||
export CXX=/usr/bin/clang++ | ||
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp" | ||
export CFLAGS="$CFLAGS -I$PREFIX/include" | ||
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include" | ||
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp" | ||
fi | ||
|
||
python -m pip install cibuildwheel | ||
python -m cibuildwheel python-package --output-dir wheelhouse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ dependencies: | |
- pylint | ||
- numpy | ||
- scipy | ||
- llvm-openmp | ||
- scikit-learn | ||
- pandas | ||
- matplotlib | ||
|