Skip to content

Commit

Permalink
Use new GitHub native aarch64 macOS runners
Browse files Browse the repository at this point in the history
Now that GitHub has native arm64 macOS runners we can leverage these to
build and test our arm64 macOS wheels directly instead of relying on
cross-target compilation, which prevented us from exercising the wheels
in the CI.

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal committed Feb 6, 2024
1 parent 1fae231 commit dcf747d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ jobs:

build_macosx_wheels:
needs: [build_sdist]
name: macosx_${{ matrix.cibw_arch }} wheels
runs-on: macos-11
name: macosx_${{ matrix.arch }} wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
cibw_arch: ["x86_64", "arm64"]

include:
- os: macos-11
arch: x86_64
- os: macos-14
arch: arm64
steps:
- uses: actions/download-artifact@v4
with:
Expand All @@ -113,24 +115,32 @@ jobs:
run: |
tar zxvf dist/*.tar.gz --strip-components=1
- name: Sets env vars for compilation
if: matrix.cibw_arch == 'arm64'
run: |
echo "CFLAGS=-target arm64-apple-macos11" >> $GITHUB_ENV
echo "MEMRAY_LIBBACKTRACE_TARGET=arm64-apple-macos11" >> $GITHUB_ENV
echo "LZ4_INSTALL_DIR=/tmp/lz4_install/usr/local/" >> $GITHUB_ENV
echo "CFLAGS=-arch ${{matrix.arch}}" >> $GITHUB_ENV
- name: Set x86_64-specific environment variables
if: matrix.arch == 'x86_64'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV
- name: Set arm64-specific environment variables
if: matrix.arch == 'arm64'
run: |
echo "MACOSX_DEPLOYMENT_TARGET=11.0" >> $GITHUB_ENV
- name: Build wheels
uses: pypa/cibuildwheel@v2.16.5
env:
CIBW_BUILD: "cp3{8..12}-*"
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
CIBW_PRERELEASE_PYTHONS: True
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest {package}/tests
CIBW_BUILD_VERBOSITY: 1
MACOSX_DEPLOYMENT_TARGET: "10.14"

CFLAGS: "${{env.CFLAGS}} -I${{env.LZ4_INSTALL_DIR}}/include"
LDFLAGS: "-L${{env.LZ4_INSTALL_DIR}}/lib -Wl,-rpath,${{env.LZ4_INSTALL_DIR}}/lib"
DYLD_LIBRARY_PATH: "${{env.LZ4_INSTALL_DIR}}/lib"
- uses: actions/upload-artifact@v4
with:
name: macosx_${{ matrix.cibw_arch }}-wheels
name: macosx_${{ matrix.arch }}-wheels
path: ./wheelhouse/*.whl

build_and_test_wheels:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ before-all = [
"git clone --depth 1 --branch v1.9.4 https://github.com/lz4/lz4 lz4",
"cd lz4",
"make",
"make install"
"make install DESTDIR=/tmp/lz4_install"
]
before-test = [
"codesign --remove-signature /Library/Frameworks/Python.framework/Versions/*/bin/python3 || true",
Expand Down

0 comments on commit dcf747d

Please sign in to comment.