Skip to content

Commit 4d86626

Browse files
authored
Add support for publishing macOS M1 ARM64 wheels (#2559) (#2562)
* Add support for publishing macOS M1 ARM64 wheels * Link against the tensorflow-macos when building for ARM Macs
1 parent 45928da commit 4d86626

File tree

5 files changed

+55
-3
lines changed

5 files changed

+55
-3
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
set -e -x
2+
3+
export TF_NEED_CUDA=0
4+
5+
python --version
6+
python -m pip install --default-timeout=1000 delocate wheel setuptools tensorflow==$TF_VERSION
7+
8+
python configure.py
9+
10+
# For dynamic linking, we want the ARM version of TensorFlow.
11+
# Since we cannot run it on x86 so we need to force pip to install it regardless
12+
python -m pip install \
13+
--platform=macosx_11_0_arm64 \
14+
--no-deps \
15+
--target=$(python -c 'import site; print(site.getsitepackages()[0])') \
16+
--upgrade \
17+
tensorflow-macos==$TF_VERSION
18+
19+
bazel build \
20+
--cpu=darwin_arm64 \
21+
--copt -mmacosx-version-min=11.0 \
22+
--linkopt -mmacosx-version-min=11.0 \
23+
--noshow_progress \
24+
--noshow_loading_progress \
25+
--verbose_failures \
26+
--test_output=errors \
27+
build_pip_pkg
28+
29+
bazel-bin/build_pip_pkg artifacts "--plat-name macosx_11_0_arm64 $NIGHTLY_FLAG"
30+
delocate-wheel -w wheelhouse artifacts/*.whl
31+
File renamed without changes.

.github/workflows/release.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ jobs:
4141
os: ['macos-latest', 'windows-latest', 'ubuntu-18.04']
4242
py-version: ['3.6', '3.7', '3.8', '3.9']
4343
tf-version: ['2.4.2', '2.6.0']
44+
cpu: ['x86']
45+
include:
46+
- os: 'macos-11'
47+
cpu: 'arm64'
48+
tf-version: '2.5.0'
49+
py-version: '3.8'
50+
- os: 'macos-11'
51+
cpu: 'arm64'
52+
tf-version: '2.5.0'
53+
py-version: '3.9'
4454
fail-fast: false
4555
steps:
4656
- uses: actions/[email protected]
@@ -68,12 +78,13 @@ jobs:
6878
PY_VERSION: ${{ matrix.py-version }}
6979
TF_VERSION: ${{ matrix.tf-version }}
7080
NIGHTLY_TIME: ${{ steps.author-date.outputs.result }}
81+
CPU: ${{ matrix.cpu }}
7182
shell: bash
72-
run: bash .github/workflows/make_wheel_${OS}.sh
83+
run: bash .github/workflows/make_wheel_${OS}_${CPU}.sh
7384
- if: matrix.py-version != '3.9' || matrix.tf-version != '2.4.2'
7485
uses: actions/upload-artifact@v1
7586
with:
76-
name: ${{ runner.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-wheel
87+
name: ${{ runner.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-${{ matrix.cpu }}-wheel
7788
path: wheelhouse
7889
upload-wheels:
7990
name: Publish wheels to PyPi
@@ -84,12 +95,22 @@ jobs:
8495
os: ['macOS', 'Windows', 'Linux']
8596
py-version: ['3.6', '3.7', '3.8', '3.9']
8697
tf-version: ['2.6.0']
98+
cpu: ['x86']
99+
include:
100+
- os: 'macos-11'
101+
cpu: 'arm64'
102+
tf-version: '2.5.0'
103+
py-version: '3.8'
104+
- os: 'macos-11'
105+
cpu: 'arm64'
106+
tf-version: '2.5.0'
107+
py-version: '3.9'
87108
fail-fast: false
88109
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release'
89110
steps:
90111
- uses: actions/download-artifact@v1
91112
with:
92-
name: ${{ matrix.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-wheel
113+
name: ${{ matrix.os }}-${{ matrix.py-version }}-tf${{ matrix.tf-version }}-${{ matrix.cpu }}-wheel
93114
path: ./dist
94115
- run: |
95116
set -e -x

0 commit comments

Comments
 (0)