-
Notifications
You must be signed in to change notification settings - Fork 1.1k
204 lines (175 loc) · 8.05 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
# 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 nightlies
on:
push:
branches: [ main, srj/pypi-try ]
release:
types: [ created ]
env:
LLVM_VER_MAJOR: 17
LLVM_VER_MINOR: 0
LLVM_VER_PATCH: 6
LLVM_VER: ${LLVM_VER_MAJOR}.${LLVM_VER_MINOR}.${LLVM_VER_PATCH}
HALIDE_CMAKE_OPTS: -DCMAKE_BUILD_TYPE=Release -DWITH_DOCS=NO -DWITH_PYTHON_BINDINGS=NO -DWITH_PYTHON_STUBS=NO -DWITH_TESTS=NO -DWITH_TUTORIALS=NO -DWITH_UTILS=NO
DEV_PREFIX: b
MANYLINUX_INSTALL_DISTRO: buster
permissions:
contents: read # to fetch code (actions/checkout)
packages: read # to fetch packages (docker)
jobs:
pip-all:
name: Package Halide Python bindings
runs-on: ${{ matrix.buildplat[0] }}
concurrency:
group: pip-all-${{ matrix.buildplat[0] }}-${{ matrix.buildplat[1] }}-${{ matrix.buildplat[2] }}-${{ matrix.python }}
cancel-in-progress: true
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
packages: read # to fetch packages (docker)
strategy:
fail-fast: false
matrix:
# python: [ cp38, cp39, cp310, cp311, cp312 ]
python: [ cp311 ]
buildplat:
# [runner, pytag, arch]
- [ubuntu-22.04, manylinux_x86_64, x86_64]
- [ubuntu-22.04, manylinux_aarch64, aarch64]
# - [macos-12, macosx_universal2, arm64;x86_64]
# - [windows-2022, win_amd64, x64]
steps:
- uses: actions/checkout@v4
# cibuildwheel is confused by the presence of the .so
# prebuilts for Hexagon and considers them an error.
# Just pre-emptively remove them to avoid this.
- name: Remove Hexagon prebuilts
shell: bash
run: rm -rf src/runtime/hexagon_remote/bin/
# ---------- Linux-specific LLVM stuff
# - name: Log in to GitHub Container Registry
# if: runner.os == 'Linux'
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
# ---------- non-Linux-specific LLVM stuff
- name: Cache LLVM build folder
if: runner.os != 'Linux'
id: cache-llvm
uses: actions/[email protected]
with:
path: local-llvm
key: llvmorg-${{ env.LLVM_VER }}-${{ runner.os }}-${{ runner.arch }}
- uses: ilammy/msvc-dev-cmd@v1
- uses: lukka/get-cmake@latest
- uses: actions/checkout@v4
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true'
with:
path: llvm-src
repository: llvm/llvm-project
ref: llvmorg-${{ env.LLVM_VER }}
- name: Configure LLVM
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true'
run: >
cmake -G Ninja -S llvm-src/llvm -B llvm-build
-DCMAKE_BUILD_TYPE=Release
"-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64"
-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_LIBXML2=OFF
-DLLVM_ENABLE_OCAMLDOC=OFF
"-DLLVM_ENABLE_PROJECTS=clang;lld"
-DLLVM_ENABLE_RTTI=ON
-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=X86;ARM;NVPTX;AArch64;Hexagon;PowerPC;WebAssembly"
- name: Build LLVM
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true'
run: cmake --build llvm-build
- name: Install LLVM
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true'
run: cmake --install llvm-build --prefix local-llvm
# Remove the LLVM source tree after building it, otherwise we can
# run out of local space while building halide
- name: Clean LLVM Source
if: runner.os != 'Linux' && steps.cache-llvm.outputs.cache-hit != 'true'
shell: bash
run: rm -rf llvm-src
# ------------------------ Build Halide
- name: Configure Halide (Windows)
if: runner.os == 'Windows'
run: >
cmake -G "Visual Studio 17 2022" -T ClangCL -A "${{ matrix.buildplat[2] }}" -S . -B halide-build
${{ env.HALIDE_CMAKE_OPTS }}
-DLLVM_DIR=${{ github.workspace }}/local-llvm/lib/cmake/llvm
- name: Configure Halide (macOS)
if: runner.os == 'macOS'
run: >
cmake -G Ninja -S . -B halide-build
${{ env.HALIDE_CMAKE_OPTS }}
"-DCMAKE_OSX_ARCHITECTURES=${{ matrix.buildplat[2] }}"
-DLLVM_DIR=${{ github.workspace }}/local-llvm/lib/cmake/llvm
- name: Build Halide
if: runner.os != 'Linux'
run: cmake --build halide-build --target install --config Release
- name: Install Halide
if: runner.os != 'Linux'
run: cmake --install halide-build --config Release --prefix local-halide
- name: Build Wheels
uses: pypa/[email protected]
env:
CMAKE_PREFIX_PATH: ${{ github.workspace }}/local-halide
CIBW_ARCHS_LINUX: "${{ matrix.buildplat[2] }}"
CIBW_ARCHS_MACOS: "universal2"
CIBW_BUILD: "${{ matrix.python }}-${{ matrix.buildplat[1] }}"
CIBW_CONFIG_SETTINGS: --global-option=egg_info --global-option=--tag-build=${{ env.DEV_PREFIX }} --global-option=--tag-date
CIBW_BEFORE_ALL_LINUX: |
sudo add-apt-repository "deb http://apt.llvm.org/${{ env.MANYLINUX_INSTALL_DISTRO }}/ llvm-toolchain-${{ env.MANYLINUX_INSTALL_DISTRO }}-${{ env.LLVM_VER_MAJOR }} main"
sudo apt install libllvm${{ env.LLVM_VER_MAJOR }} llvm-${{ env.LLVM_VER_MAJOR }} llvm-${{ env.LLVM_VER_MAJOR }}-dev llvm-${{ env.LLVM_VER_MAJOR }}-runtime libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev libfuzzer-${{ env.LLVM_VER_MAJOR }}-dev lld-18 libc++-${{ env.LLVM_VER_MAJOR }}-dev libc++abi-${{ env.LLVM_VER_MAJOR }}-dev libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm64 libc++-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libc++abi-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm32 libclang-rt-${{ env.LLVM_VER_MAJOR }}-dev-wasm64 libclang-${{ env.LLVM_VER_MAJOR }}-dev libzstd-dev liblld-${{ env.LLVM_VER_MAJOR }} liblld-${{ env.LLVM_VER_MAJOR }}-dev
cmake -G Ninja -S . -B halide-build ${{ env.HALIDE_CMAKE_OPTS }} && \
cmake --build halide-build --target install --config Release && \
cmake --install halide-build --config Release --prefix local-halide
# CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/halide/manylinux2014_x86_64-llvm:${{ env.LLVM_VER }}
# CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/halide/manylinux2014_aarch64-llvm:${{ env.LLVM_VER }}
- uses: actions/upload-artifact@v4
with:
name: wheels
path: ./wheelhouse/*.whl
publish:
name: Publish on PyPI
needs: [ pip-all ]
runs-on: ubuntu-22.04
steps:
- uses: actions/download-artifact@v4
with:
name: wheels
path: dist
- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
verbose: true
# - uses: pypa/[email protected]
# if: github.event_name == 'release' && github.event.action == 'published'
# with:
# user: __token__
# password: ${{ secrets.PYPI_TOKEN }}