Skip to content

Commit

Permalink
CICD: Switch to MacOS ARM runners
Browse files Browse the repository at this point in the history
  • Loading branch information
RUrlus committed May 14, 2024
1 parent be98a98 commit 4365cb4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nonvendored_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=OFF"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="10.13" CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=OFF"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="12.0" CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=OFF"

- name: Show files
run: ls -lh wheelhouse
Expand Down
81 changes: 59 additions & 22 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,51 @@ jobs:

- uses: actions/setup-python@v5
with:
python-version: "3.11"
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-17.0.6 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.16.5
run: python -m pip install cibuildwheel==2.18.0

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_ENVIRONMENT: CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=ON"
CIBW_TEST_COMMAND: pytest {project}/tests && python -c "from diptest import _has_openmp_support; assert _has_openmp_support"
# only build for x86_64; ARM wheels are build seperately
CIBW_ARCHS_MACOS: "x86_64"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="10.13" CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=ON"
# 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="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=ON -DOpenMP_ROOT=$HOME/.local/libomp"

- name: Verify clean directory
run: git diff --exit-code
Expand All @@ -70,9 +102,9 @@ jobs:
name: artifact-${{ matrix.os }}
path: wheelhouse/*.whl

build_arm_wheels:
name: MacOS ARM wheels
runs-on: macos-latest
build_macos_intel:
name: MacOS x86_64 wheels
runs-on: macos-13
strategy:
fail-fast: false

Expand All @@ -86,7 +118,7 @@ jobs:
uses: actions/cache@v4
with:
path: llvm-project
key: macos-arm-openmp
key: ${{ runner.os }}-openmp

- name: Clone OpenMP repo
if: steps.clone-openmp.outputs.cache-hit != 'true'
Expand All @@ -101,19 +133,19 @@ jobs:
rm -rf llvm-project
mkdir openmp_build
cmake -S openmp -B openmp_build \
-DCMAKE_OSX_ARCHITECTURES="arm64" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="10.13" \
-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/cibuildwheel@v2.17.0
- uses: pypa/cibuildwheel@v2.18.0
env:
# only build for ARM; x86_64 wheels are build seperately
CIBW_ARCHS: "arm64"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="10.13" CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=ON -DOpenMP_ROOT=/usr/local"
# only build for x86_64, arm wheels are build seperately
CIBW_ARCHS: "x86_64"
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET="12.0" CMAKE_ARGS="-DDIPTEST_ENABLE_ARCH_FLAGS=OFF -DDIPTEST_ENABLE_OPENMP=ON -DOpenMP_ROOT=/usr/local"

- name: Verify clean directory
run: git diff --exit-code
Expand All @@ -122,33 +154,36 @@ jobs:
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: artifact-macos-arm
name: artifact-macos-x86-64
path: wheelhouse/*.whl

publish-to-testpypi:
name: Publish release on TestPyPi
needs: [build_sdist, build_wheels, build_arm_wheels]
needs: [build_sdist, build_wheels, build_macos_intel]
runs-on: ubuntu-latest
if: 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@v1.8.14
- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
skip_existing: true
skip-existing: true

pypi-publish:
name: Publish release on PyPi
needs: [build_sdist, build_wheels, build_arm_wheels, publish-to-testpypi]
needs: [build_sdist, build_wheels, build_macos_intel, publish-to-testpypi]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
environment: release
Expand All @@ -157,13 +192,15 @@ jobs:

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@v1.8.14
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true
skip-existing: true

0 comments on commit 4365cb4

Please sign in to comment.