Skip to content

Commit 94bccc7

Browse files
authored
Build ARM64 wheels for macOS (#296)
* Build ARM64 wheels for macOS * Remove nproc
1 parent 7031c17 commit 94bccc7

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ jobs:
8686
include:
8787
- os: ubuntu-20.04
8888
arch: aarch64
89+
- os: macos-11
90+
arch: arm64
8991

9092
steps:
9193
- uses: actions/checkout@v2
@@ -111,6 +113,7 @@ jobs:
111113
CIBW_TEST_REQUIRES: pytest
112114
CIBW_ARCHS: ${{ matrix.arch }}
113115
CIBW_SKIP: pp* *-musllinux_*
116+
CIBW_TEST_SKIP: "*-macosx_arm64"
114117

115118
- name: Upload Python wheels
116119
uses: actions/upload-artifact@v2

bindings/python/tools/prepare_build_environment.sh

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,36 @@ set -e
44
set -x
55

66
ROOT_DIR=$PWD
7-
ICU_VERSION=${ICU_VERSION:-70.1}
8-
ICU_ROOT=$ROOT_DIR/icu-$ICU_VERSION
9-
10-
# Install ICU.
11-
curl -L -O https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION/./-}/icu4c-${ICU_VERSION/./_}-src.tgz
12-
tar xf icu4c-*-src.tgz
13-
cd icu/source
14-
CFLAGS="-O3 -fPIC" CXXFLAGS="-O3 -fPIC" ./configure --disable-shared --enable-static --prefix=$ICU_ROOT
15-
make -j2 install
7+
ICU_ROOT=$ROOT_DIR/icu
8+
CMAKE_EXTRA_ARGS=""
9+
10+
if [ "$CIBW_ARCHS" == "arm64" ]; then
11+
12+
# Download ICU ARM64 binaries from Homebrew.
13+
brew fetch --force --bottle-tag=arm64_big_sur icu4c \
14+
| grep "Downloaded to" \
15+
| awk '{ print $3 }' \
16+
| xargs -I{} tar xf {} -C $ROOT_DIR
17+
18+
mv icu4c/*.* $ICU_ROOT
19+
20+
# Remove dynamic libraries to force static link.
21+
rm $ICU_ROOT/lib/*.dylib
22+
23+
CMAKE_EXTRA_ARGS="-DCMAKE_OSX_ARCHITECTURES=arm64"
24+
25+
else
26+
27+
# Download and compile ICU from sources.
28+
ICU_VERSION=${ICU_VERSION:-70.1}
29+
curl -L -O https://github.com/unicode-org/icu/releases/download/release-${ICU_VERSION/./-}/icu4c-${ICU_VERSION/./_}-src.tgz
30+
tar xf icu4c-*-src.tgz
31+
cd icu/source
32+
CFLAGS="-O3 -fPIC" CXXFLAGS="-O3 -fPIC" ./configure --disable-shared --enable-static --prefix=$ICU_ROOT
33+
make -j2 install
34+
35+
fi
36+
1637
cd $ROOT_DIR
1738

1839
# Install cmake.
@@ -22,6 +43,6 @@ pip install "cmake==3.18.*"
2243
rm -rf build
2344
mkdir build
2445
cd build
25-
cmake -DLIB_ONLY=ON -DICU_ROOT=$ICU_ROOT ..
26-
make -j2 install
46+
cmake -DLIB_ONLY=ON -DICU_ROOT=$ICU_ROOT $CMAKE_EXTRA_ARGS ..
47+
VERBOSE=1 make -j2 install
2748
cd $ROOT_DIR

0 commit comments

Comments
 (0)