Skip to content

BLD: Set rpath for libomp on MacOS to fix compatibility with latest XGBoost version #134

BLD: Set rpath for libomp on MacOS to fix compatibility with latest XGBoost version

BLD: Set rpath for libomp on MacOS to fix compatibility with latest XGBoost version #134

Workflow file for this run

name: Build and Publish
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published
jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Build SDist
run: pipx run build --sdist
- name: Check metadata
run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: artifact-sdist
path: dist/*.tar.gz
build_wheels:
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Cache OpenMP repo
if: matrix.os == 'macos-latest'
id: clone-openmp
uses: actions/cache@v4
with:
path: llvm-project
key: ${{ runner.os }}-openmp
- name: Clone OpenMP repo
if: matrix.os == 'macos-latest' && steps.clone-openmp.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-19.1.1 https://github.com/llvm/llvm-project
- name: Build OpenMP
if: matrix.os == 'macos-latest'
shell: bash
run: |
PATH="$HOME/.local/:$PATH"
mv llvm-project/openmp ./openmp
mv llvm-project/cmake ./cmake
rm -rf llvm-project
mkdir openmp_build
cmake -S openmp -B openmp_build \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="12.0" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="$HOME/.local/libomp"
cmake --build openmp_build --target install --config Release
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.21.3
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: CMAKE_ARGS="-DSDTN_ENABLE_ARCH_FLAGS=OFF -DSDTN_ENABLE_OPENMP=ON -DSDTN_DISABLE_OPENMP=OFF"
CIBW_TEST_COMMAND: pytest {project}/tests && python -c "from sparse_dot_topn import _has_openmp_support;assert _has_openmp_support"
# only build for arm; x86_64 wheels are build seperately
CIBW_ARCHS_MACOS: "arm64"
CIBW_ENVIRONMENT_MACOS: PATH="$HOME/.local/:$PATH" MACOSX_DEPLOYMENT_TARGET=12.0 DYLD_LIBRARY_PATH="$HOME/.local/libomp/lib" CMAKE_ARGS="-DSDTN_ENABLE_ARCH_FLAGS=OFF -DSDTN_VENDOR_OPENMP=ON -DSDTN_ENABLE_OPENMP=ON -DSDTN_DISABLE_OPENMP=OFF -DOpenMP_ROOT=$HOME/.local/libomp"
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}
path: wheelhouse/*.whl
build_macos_intel:
name: MacOS x86_64 wheels
runs-on: macos-13
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Cache OpenMP repo
id: clone-openmp
uses: actions/cache@v4
with:
path: llvm-project
key: ${{ runner.os }}-openmp
- name: Clone OpenMP repo
if: steps.clone-openmp.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-19.1.1 https://github.com/llvm/llvm-project
- name: Build OpenMP
shell: bash
run: |
mv llvm-project/openmp ./openmp
mv llvm-project/cmake ./cmake
rm -rf llvm-project
mkdir openmp_build
cmake -S openmp -B openmp_build \
-DCMAKE_OSX_ARCHITECTURES="x86_64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="12.0" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="/usr/local"
cmake --build openmp_build --target install --config Release
- uses: pypa/[email protected]
env:
# only build for x86_64, arm wheels are build seperately
CIBW_ARCHS: "x86_64"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=12.0 CMAKE_ARGS="-DSDTN_ENABLE_ARCH_FLAGS=OFF -DSDTN_VENDOR_OPENMP=ON -DSDTN_ENABLE_OPENMP=ON -DSDTN_DISABLE_OPENMP=OFF -DOpenMP_ROOT=/usr/local"
- name: Verify clean directory
run: git diff --exit-code
shell: bash
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: artifact-macos-x86-64
path: wheelhouse/*.whl
publish-to-testpypi:
name: Publish release on TestPyPi
needs: [build_sdist, build_wheels, build_macos_intel]
runs-on: ubuntu-latest
if: github.repository_owner == 'ing-bank' && github.event_name == 'release' # prevent forks from running this step
environment: testrelease
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
pypi-publish:
name: Publish release on PyPi
needs: [build_sdist, build_wheels, build_macos_intel, publish-to-testpypi]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published' && github.event.prerelease == false
environment: release
permissions:
id-token: write
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true