-
Notifications
You must be signed in to change notification settings - Fork 1.1k
238 lines (204 loc) · 7.97 KB
/
pip.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Relevant GHA docs links:
# https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container
# https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-ghcrio
name: Build PyPI package
on:
push:
branches: [ main, build/pip-packaging ]
release:
types: [ created ]
env:
# TODO: detect this from repo somehow
LLVM_VERSION: 18.1.8
FLATBUFFERS_VERSION: 23.5.26
WABT_VERSION: 1.0.36
concurrency:
group: '${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
permissions:
contents: read # to fetch code (actions/checkout)
packages: read # to fetch packages (docker)
jobs:
build-wheels:
name: Build Halide wheels for ${{ matrix.platform_tag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform_tag: manylinux_x86_64
- os: windows-latest
platform_tag: win_amd64
- os: macos-13
platform_tag: macosx_x86_64
- os: macos-14
platform_tag: macosx_arm64
env:
MACOSX_DEPLOYMENT_TARGET: 11
steps:
- name: Login to GitHub Container Registry
if: matrix.os == 'ubuntu-latest'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: ilammy/msvc-dev-cmd@v1
- uses: lukka/get-cmake@v3.28.4
- uses: actions/setup-python@v5
with:
python-version: 3.8
if: runner.os == "macOS" && runner.arch == "ARM64"
########################################################################
# flatbuffers
########################################################################
- name: Cache flatbuffers build folder
if: matrix.os != 'ubuntu-latest'
id: cache-flatbuffers
uses: actions/cache@v4
with:
path: opt/flatbuffers
key: flatbuffers-${{ env.FLATBUFFERS_VERSION }}-${{ matrix.platform_tag }}
- uses: actions/checkout@v4
if: matrix.os != 'ubuntu-latest' && steps.cache-flatbuffers.outputs.cache-hit != 'true'
with:
path: flatbuffers-src
repository: google/flatbuffers
ref: v${{ env.FLATBUFFERS_VERSION }}
- name: Configure flatbuffers
if: matrix.os != 'ubuntu-latest' && steps.cache-flatbuffers.outputs.cache-hit != 'true'
run: >
cmake -G Ninja -S flatbuffers-src -B flatbuffers-build
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/opt/flatbuffers"
"-DFLATBUFFERS_BUILD_TESTS=NO"
- name: Install flatbuffers
if: matrix.os != 'ubuntu-latest' && steps.cache-flatbuffers.outputs.cache-hit != 'true'
run: |
cmake --build flatbuffers-build --target install
cmake -E rm -rf flatbuffers-src flatbuffers-build
########################################################################
# wabt
########################################################################
- name: Cache wabt build folder
if: matrix.os != 'ubuntu-latest'
id: cache-wabt
uses: actions/cache@v4
with:
path: opt/wabt
key: wabt-${{ env.WABT_VERSION }}-${{ matrix.platform_tag }}
- uses: actions/checkout@v4
if: matrix.os != 'ubuntu-latest' && steps.cache-wabt.outputs.cache-hit != 'true'
with:
submodules: 'true'
path: wabt-src
repository: WebAssembly/wabt
ref: ${{ env.WABT_VERSION }}
- name: Configure wabt
if: matrix.os != 'ubuntu-latest' && steps.cache-wabt.outputs.cache-hit != 'true'
run: >
cmake -G Ninja -S wabt-src -B wabt-build
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/opt/wabt"
"-DWITH_EXCEPTIONS=ON"
"-DBUILD_TESTS=OFF"
"-DBUILD_TOOLS=OFF"
"-DBUILD_LIBWASM=OFF"
"-DUSE_INTERNAL_SHA256=ON"
- name: Install wabt
if: matrix.os != 'ubuntu-latest' && steps.cache-wabt.outputs.cache-hit != 'true'
run: |
cmake --build wabt-build --target install
cmake -E rm -rf wabt-src wabt-build
########################################################################
# LLVM
########################################################################
- name: Cache LLVM build folder
if: matrix.os != 'ubuntu-latest'
id: cache-llvm
uses: actions/cache@v4
with:
path: opt/llvm
key: llvm-${{ env.LLVM_VERSION }}-${{ matrix.platform_tag }}
- uses: actions/checkout@v4
if: matrix.os != 'ubuntu-latest' && steps.cache-llvm.outputs.cache-hit != 'true'
with:
path: llvm-src
repository: llvm/llvm-project
ref: llvmorg-${{ env.LLVM_VERSION }}
- name: Configure LLVM
if: matrix.os != 'ubuntu-latest' && steps.cache-llvm.outputs.cache-hit != 'true'
run: >
cmake -G Ninja -S llvm-src/llvm -B llvm-build
"-DCMAKE_BUILD_TYPE=Release"
"-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/opt/llvm"
"-DLLVM_ENABLE_ASSERTIONS=ON"
"-DLLVM_ENABLE_BINDINGS=OFF"
"-DLLVM_ENABLE_CURL=OFF"
"-DLLVM_ENABLE_DIA_SDK=OFF"
"-DLLVM_ENABLE_EH=ON"
"-DLLVM_ENABLE_HTTPLIB=OFF"
"-DLLVM_ENABLE_IDE=OFF"
"-DLLVM_ENABLE_LIBEDIT=OFF"
"-DLLVM_ENABLE_LIBXML2=OFF"
"-DLLVM_ENABLE_OCAMLDOC=OFF"
"-DLLVM_ENABLE_PROJECTS=clang;lld"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_ENABLE_RUNTIMES=compiler-rt"
"-DLLVM_ENABLE_TERMINFO=OFF"
"-DLLVM_ENABLE_WARNINGS=OFF"
"-DLLVM_ENABLE_ZLIB=OFF"
"-DLLVM_ENABLE_ZSTD=OFF"
"-DLLVM_INCLUDE_BENCHMARKS=OFF"
"-DLLVM_INCLUDE_EXAMPLES=OFF"
"-DLLVM_INCLUDE_TESTS=OFF"
"-DLLVM_TARGETS_TO_BUILD=WebAssembly;X86;AArch64;ARM;Hexagon;NVPTX;PowerPC;RISCV"
- name: Install LLVM
if: matrix.os != 'ubuntu-latest' && steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cmake --build llvm-build --target install
cmake -E rm -rf llvm-src llvm-build
########################################################################
# Wheels
########################################################################
- name: Debug windows
uses: mxschmitt/action-tmate@v3
if: runner.os == "Windows"
- name: Build wheels
uses: pypa/cibuildwheel@v2.20.0
env:
CIBW_BUILD: "cp3*-${{ matrix.platform_tag }}"
CIBW_SKIP: "cp3{5,6,7}*"
CIBW_ENVIRONMENT_MACOS: "CMAKE_PREFIX_PATH=${{ github.workspace }}/opt"
CIBW_ENVIRONMENT_WINDOWS: >
CMAKE_GENERATOR=Ninja
CMAKE_PREFIX_PATH=${{ github.workspace }}/opt
CIBW_MANYLINUX_X86_64_IMAGE: "ghcr.io/halide/manylinux_2_28_x86_64-llvm:${{ env.LLVM_VERSION }}"
- uses: actions/upload-artifact@v4
with:
name: wheels
path: ./wheelhouse/*.whl
publish:
name: Publish on PyPI
needs: build-wheels
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
path: dist
- uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- uses: pypa/gh-action-pypi-publish@v1.5.1
if: github.event_name == 'release' && github.event.action == 'published'
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}