Skip to content

Commit

Permalink
add gh action to build python wheels for macos arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
lu1and10 committed Dec 21, 2023
1 parent 9ba0355 commit de9e9a6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/python_wheel_macos_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Python Wheel Build MacOS Arm64

on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master

jobs:
MacOS:
runs-on: macos-13
env:
MACOSX_DEPLOYMENT_TARGET: 11.0

steps:
- uses: actions/checkout@v4

- name: Install libomp and fftw
run: |
pkg=$(brew fetch --force --bottle-tag=arm64_ventura fftw | grep 'Downloaded to' | cut -d' ' -f3)
brew install $pkg
pkg=$(brew fetch --force --bottle-tag=arm64_ventura libomp | grep 'Downloaded to' | cut -d' ' -f3)
brew install $pkg
- name: Compile libfinufft
run: |
cp make.inc.gh_macos_arm64_whl make.inc
make lib
- name: Build wheels
uses: pypa/[email protected]
env:
FINUFFT_DIR: ${{ github.workspace }}
CC: Clang
CXX: Clang++
CIBW_ARCHS_MACOS: arm64
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-*
with:
package-dir: ./python/finufft
output-dir: wheelhouse

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: macos-wheels
path: wheelhouse/*.whl

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
28 changes: 28 additions & 0 deletions make.inc.gh_macos_arm64_whl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Makefile variable overrides for Mac OSX compilation with CLANG.
CFLAGS = -O3 -arch arm64

CXX=clang++
CC=clang

OMP_ROOT = $(shell brew --prefix libomp)
# taken from makefile...
CFLAGS += -I include -I/usr/local/include -I/opt/homebrew/include -I$(OMP_ROOT)/include -target arm64-apple-macos11
FFLAGS = $(CFLAGS)
CXXFLAGS = $(CFLAGS)
LIBS += -L/usr/local/lib -L/opt/homebrew/lib -L$(OMP_ROOT)/lib -target arm64-apple-macos11 -arch arm64

# OpenMP with clang needs following...
OMPFLAGS = -Xpreprocessor -fopenmp
OMPLIBS = -L/usr/local/lib -L/opt/homebrew/lib -lomp
# since fftw3_omp doesn't work in OSX, we need...
FFTWOMPSUFFIX=threads


# MATLAB interface: this will probably segfault. Instead we suggest you use
# make.inc.macosx_clang_matlab

# Some of these will depend on your FFTW library location...
MFLAGS += -I/usr/local/include -I/opt/homebrew/include -L/usr/local/lib -L/opt/homebrew/lib -lm
# may need to edit for your MATLAB version location...
MEX = $(shell ls -d /Applications/MATLAB_R20**.app)/bin/mex
# Also see docs/install.rst for possible edits to MATLAB's MEX XML file.

0 comments on commit de9e9a6

Please sign in to comment.