Skip to content

Commit

Permalink
Build ARM64 wheels for macOS (#296)
Browse files Browse the repository at this point in the history
* Build ARM64 wheels for macOS

* Remove nproc
  • Loading branch information
guillaumekln authored Aug 29, 2022
1 parent 7031c17 commit 94bccc7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
include:
- os: ubuntu-20.04
arch: aarch64
- os: macos-11
arch: arm64

steps:
- uses: actions/checkout@v2
Expand All @@ -111,6 +113,7 @@ jobs:
CIBW_TEST_REQUIRES: pytest
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: pp* *-musllinux_*
CIBW_TEST_SKIP: "*-macosx_arm64"

- name: Upload Python wheels
uses: actions/upload-artifact@v2
Expand Down
43 changes: 32 additions & 11 deletions bindings/python/tools/prepare_build_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,36 @@ set -e
set -x

ROOT_DIR=$PWD
ICU_VERSION=${ICU_VERSION:-70.1}
ICU_ROOT=$ROOT_DIR/icu-$ICU_VERSION

# Install ICU.
curl -L -O https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION/./-}/icu4c-${ICU_VERSION/./_}-src.tgz
tar xf icu4c-*-src.tgz
cd icu/source
CFLAGS="-O3 -fPIC" CXXFLAGS="-O3 -fPIC" ./configure --disable-shared --enable-static --prefix=$ICU_ROOT
make -j2 install
ICU_ROOT=$ROOT_DIR/icu
CMAKE_EXTRA_ARGS=""

if [ "$CIBW_ARCHS" == "arm64" ]; then

# Download ICU ARM64 binaries from Homebrew.
brew fetch --force --bottle-tag=arm64_big_sur icu4c \
| grep "Downloaded to" \
| awk '{ print $3 }' \
| xargs -I{} tar xf {} -C $ROOT_DIR

mv icu4c/*.* $ICU_ROOT

# Remove dynamic libraries to force static link.
rm $ICU_ROOT/lib/*.dylib

CMAKE_EXTRA_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64"

else

# Download and compile ICU from sources.
ICU_VERSION=${ICU_VERSION:-70.1}
curl -L -O https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION/./-}/icu4c-${ICU_VERSION/./_}-src.tgz
tar xf icu4c-*-src.tgz
cd icu/source
CFLAGS="-O3 -fPIC" CXXFLAGS="-O3 -fPIC" ./configure --disable-shared --enable-static --prefix=$ICU_ROOT
make -j2 install

fi

cd $ROOT_DIR

# Install cmake.
Expand All @@ -22,6 +43,6 @@ pip install "cmake==3.18.*"
rm -rf build
mkdir build
cd build
cmake -DLIB_ONLY=ON -DICU_ROOT=$ICU_ROOT ..
make -j2 install
cmake -DLIB_ONLY=ON -DICU_ROOT=$ICU_ROOT $CMAKE_EXTRA_ARGS ..
VERBOSE=1 make -j2 install
cd $ROOT_DIR

0 comments on commit 94bccc7

Please sign in to comment.