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

CICD: Switch to MacOS ARM runners #52

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sdist.include = [
]

[tool.scikit-build.cmake.define]
CMAKE_OSX_DEPLOYMENT_TARGET = "10.13"
CMAKE_OSX_DEPLOYMENT_TARGET = "12.0"
DIPTEST_CPP_STANDARD = "11"
DIPTEST_ENABLE_DEVMODE = false
DIPTEST_ENABLE_DEBUG = false
Expand Down Expand Up @@ -73,7 +73,7 @@ repair-wheel-command = "auditwheel repair -w {dest_dir} {wheel}"

[tool.cibuildwheel.macos]
archs = ["x86_64", "arm64"]
environment = { MACOSX_DEPLOYMENT_TARGET = "10.13", CMAKE_ARGS = "-DDIPTEST_ENABLE_ARCH_FLAGS=OFF" }
environment = { MACOSX_DEPLOYMENT_TARGET = "12.0", CMAKE_ARGS = "-DDIPTEST_ENABLE_ARCH_FLAGS=OFF" }
repair-wheel-command = "delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"

[tool.cibuildwheel.windows]
Expand Down
Loading