Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Build Python wheels for MacOS (x86_64 and arm64) #7621

Merged
merged 7 commits into from
Feb 3, 2022

Conversation

hcho3
Copy link
Collaborator

@hcho3 hcho3 commented Jan 30, 2022

  • Use cibuildwheel to build Python wheels targeting MacOS x86_64 and MacOS arm64 (aka Apple Silicon)
  • Bundle libomp 11.1.0 into the Python wheels. This step is automatically done by cibuildwheel. Using the version 11.1.0 ensures that we don't get random segfaults when running inside a Conda environment. (See BLD Fixes osx build by downgrading to 11.X [cd build] scikit-learn/scikit-learn#21227 (comment) for the list of configurations where segfaults occur.)
  • Users no longer need to run brew instal libomp prior to installing XGBoost.
  • Create a separate YAML file dedicated for wheel building, since there's lots of details involved.

This PR is inspired by scikit-learn/scikit-learn#22109.

Closes #7039

fi

python -m pip install cibuildwheel
python -m cibuildwheel python-package --output-dir wheelhouse
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command calls python.py bdist_wheel to generate the wheel.

@hcho3 hcho3 requested a review from trivialfis January 30, 2022 15:47
@hcho3 hcho3 changed the title Build Python wheels for OSX (x86_64 and arm64) [CI] Build Python wheels for OSX (x86_64 and arm64) Jan 30, 2022
@hcho3 hcho3 changed the title [CI] Build Python wheels for OSX (x86_64 and arm64) [CI] Build Python wheels for MacOS (x86_64 and arm64) Jan 30, 2022
Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

Closes #7039

Do we want to back port to 1.5.2?

Could you please document the build process?

python-package/setup.py Show resolved Hide resolved
@hcho3
Copy link
Collaborator Author

hcho3 commented Feb 1, 2022

Rendered doc: https://xgboost--7621.org.readthedocs.build/en/7621/contrib/ci.html#github-actions

Copy link
Member

@trivialfis trivialfis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cool!

@hcho3 hcho3 merged commit f6e6d0b into dmlc:master Feb 3, 2022
@hcho3 hcho3 deleted the macos_wheels branch February 3, 2022 01:35
hcho3 added a commit to dmlc/treelite that referenced this pull request Feb 3, 2022
- Rewrite `ParallelFor` using OpenMP constructs.
- Link Treelite libs with OpenMP runtime lib.
- On MacOS, bundle libomp (OpenMP runtime) with Treelite. This is to ensure that Treelite does not randomly crash. dmlc/xgboost#7621 for full explanation.
- Build PyPI wheel targeting Apple Silicon. Closes #350
- On Linux, run `auditwheel repair` command to vendor (bundle) `libgomp.so` inside the Python wheel. This is required by the Python packaging standard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Segmentation fault on MacOS with libomp 12.0.0
2 participants