Elffuss BraidHub

kikocis/ncnn public

e91df65e9177 · 12.7 KiBRawPermalink
1name: release-python
2# on: [push, pull_request]
3on:
4 push:
5 tags:
6 - '*'
7
8env:
9 DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer
10 MAC_DEPLOYMENT_TARGET: '11.0'
11 ENABLE_BITCODE: OFF
12 ENABLE_ARC: OFF
13 ENABLE_VISIBILITY: OFF
14
15jobs:
16 build_sdist:
17 name: Build SDist
18 runs-on: ubuntu-latest
19 steps:
20 - uses: actions/checkout@v4
21 with:
22 submodules: true
23
24 - uses: actions/setup-python@v5
25 with:
26 python-version: '3.x'
27
28 - name: Install deps
29 run: python -m pip install twine build
30
31 - name: Build SDist
32 run: python -m build -s
33
34 - name: Check metadata
35 run: twine check dist/*
36
37 - uses: actions/upload-artifact@v4
38 with:
39 name: sdist
40 path: dist/*.tar.gz
41
42 build_wheels:
43 name: ${{ matrix.arch }} ${{ matrix.build_id }} on ${{ matrix.os }}
44 runs-on: ${{ matrix.os }}
45 strategy:
46 fail-fast: false
47 matrix:
48 include:
49 - { os: ubuntu-20.04, arch: x86_64, build: 'cp*-manylinux*', build_id: cp-manylinux }
50 - { os: ubuntu-20.04, arch: x86_64, build: 'cp*-musllinux*', build_id: cp-musllinux }
51 - { os: ubuntu-20.04, arch: x86_64, build: 'pp*', build_id: pp }
52 - { os: ubuntu-20.04, arch: i686, build: 'cp*-manylinux*', build_id: cp-manylinux }
53 - { os: ubuntu-20.04, arch: i686, build: 'cp*-musllinux*', build_id: cp-musllinux }
54 - { os: ubuntu-20.04, arch: i686, build: 'pp*', build_id: pp }
55 - { os: windows-2019, arch: x86, build: 'cp*', build_id: cp }
56 - { os: windows-2019, arch: AMD64, build: 'cp*', build_id: cp }
57 - { os: windows-2019, arch: AMD64, build: 'pp*', build_id: pp }
58 - { os: windows-2019, arch: ARM64, build: 'cp*', build_id: cp }
59 - { os: macos-13, arch: x86_64, build: 'cp*', build_id: cp }
60 - { os: macos-13, arch: x86_64, build: 'pp*', build_id: pp }
61 - { os: macos-13, arch: arm64, build: 'cp*', build_id: cp }
62
63 env:
64 OPENMP_VERSION: '18.1.2'
65 OPENMP_CMAKE_OPTIONS: |
66 -DCMAKE_TOOLCHAIN_FILE=../../toolchains/ios.toolchain.cmake \
67 -DDEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET \
68 -DENABLE_BITCODE=$ENABLE_BITCODE \
69 -DENABLE_ARC=$ENABLE_ARC \
70 -DENABLE_VISIBILITY=$ENABLE_VISIBILITY \
71 -DCMAKE_INSTALL_PREFIX=install \
72 -DCMAKE_BUILD_TYPE=Release \
73 -DPERL_EXECUTABLE=/usr/local/bin/perl \
74 -DLIBOMP_ENABLE_SHARED=OFF \
75 -DLIBOMP_OMPT_SUPPORT=OFF \
76 -DLIBOMP_USE_HWLOC=OFF \
77
78 steps:
79 - uses: actions/checkout@v4
80 with:
81 submodules: true
82
83 - uses: actions/setup-python@v5
84 with:
85 python-version: '3.x'
86
87 # build wheels for ubuntu-20.04
88 - name: Build wheels for ubuntu
89 if: matrix.os == 'ubuntu-20.04'
90 uses: pypa/cibuildwheel@v2.17.0
91 env:
92 CIBW_ARCHS_LINUX: ${{ matrix.arch }}
93 CIBW_BUILD: ${{ matrix.build }}
94 CIBW_BUILD_VERBOSITY: 1
95 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=4
96 with:
97 output-dir: wheelhouse
98
99 # build wheels for windows-2019
100 - name: Build wheels for windows
101 if: matrix.os == 'windows-2019' && (matrix.arch == 'AMD64' || matrix.arch == 'x86')
102 uses: pypa/cibuildwheel@v2.17.0
103 env:
104 CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
105 CIBW_BUILD: ${{ matrix.build }}
106 CIBW_BUILD_VERBOSITY: 1
107 CIBW_ENVIRONMENT_WINDOWS: CMAKE_BUILD_PARALLEL_LEVEL=4
108 CIBW_BEFORE_BUILD: pip install delvewheel
109 CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel}
110 with:
111 output-dir: wheelhouse
112
113 - name: Build wheels for windows ARM64
114 if: matrix.os == 'windows-2019' && matrix.arch == 'ARM64'
115 uses: pypa/cibuildwheel@v2.17.0
116 env:
117 CIBW_ARCHS_WINDOWS: ${{ matrix.arch }}
118 CIBW_BUILD: ${{ matrix.build }}
119 CIBW_BUILD_VERBOSITY: 1
120 CIBW_ENVIRONMENT_WINDOWS: CMAKE_BUILD_PARALLEL_LEVEL=4
121 CIBW_BEFORE_BUILD: pip install delvewheel
122 CIBW_REPAIR_WHEEL_COMMAND: delvewheel repair -w {dest_dir} {wheel} --no-dll "msvcp140.dll;vcomp140.dll"
123 with:
124 output-dir: wheelhouse
125
126 # build wheels for macos-13
127 - name: cache-openmp for macos
128 if: matrix.os == 'macos-13'
129 id: cache-openmp
130 uses: actions/cache@v4
131 with:
132 path: openmp-install
133 key: openmp-macos-install-20240403
134
135 - name: openmp for macos
136 if: matrix.os == 'macos-13' && steps.cache-openmp.outputs.cache-hit != 'true'
137 run: |
138 wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/cmake-${{ env.OPENMP_VERSION }}.src.tar.xz
139 tar -xf cmake-${{ env.OPENMP_VERSION }}.src.tar.xz
140 wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.OPENMP_VERSION }}/openmp-${{ env.OPENMP_VERSION }}.src.tar.xz
141 tar -xf openmp-${{ env.OPENMP_VERSION }}.src.tar.xz
142 mv cmake-${{ env.OPENMP_VERSION }}.src/Modules/* openmp-${{ env.OPENMP_VERSION }}.src/cmake/
143 cd openmp-${{ env.OPENMP_VERSION }}.src
144 wget https://github.com/nihui/llvm-project/commit/ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch
145 patch -p2 -i ef8c35bcf5d9cfdb0764ffde6a63c04ec715bc37.patch
146 wget https://github.com/nihui/llvm-project/commit/5c12711f9a21f41bea70566bf15a4026804d6b20.patch
147 patch -p2 -i 5c12711f9a21f41bea70566bf15a4026804d6b20.patch
148
149 - name: openmp-build-x86_64 for macos
150 if: matrix.os == 'macos-13' && steps.cache-openmp.outputs.cache-hit != 'true'
151 run: |
152 cd openmp-${{ env.OPENMP_VERSION }}.src
153 mkdir -p build-x86_64 && cd build-x86_64
154 cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=MAC -DARCHS="x86_64" ..
155 cmake --build . -j 4
156 cmake --build . --target install
157
158 - name: openmp-build-arm64 for macos
159 if: matrix.os == 'macos-13' && steps.cache-openmp.outputs.cache-hit != 'true'
160 run: |
161 cd openmp-${{ env.OPENMP_VERSION }}.src
162 mkdir -p build-arm64 && cd build-arm64
163 cmake ${{ env.OPENMP_CMAKE_OPTIONS }} -DPLATFORM=MAC_ARM64 -DARCHS="arm64" ..
164 cmake --build . -j 4
165 cmake --build . --target install
166
167 - name: openmp-merge-fat-library for macos
168 if: matrix.os == 'macos-13' && steps.cache-openmp.outputs.cache-hit != 'true'
169 run: |
170 mkdir -p $GITHUB_WORKSPACE/openmp-install
171 cp -a openmp-${{ env.OPENMP_VERSION }}.src/build-x86_64/install/include $GITHUB_WORKSPACE/openmp-install
172 mkdir -p $GITHUB_WORKSPACE/openmp-install/lib
173 lipo -create \
174 openmp-${{ env.OPENMP_VERSION }}.src/build-x86_64/install/lib/libomp.a \
175 openmp-${{ env.OPENMP_VERSION }}.src/build-arm64/install/lib/libomp.a \
176 -o $GITHUB_WORKSPACE/openmp-install/lib/libomp.a
177
178 - name: install-openmp for macos
179 if: matrix.os == 'macos-13'
180 run: |
181 sudo cp $GITHUB_WORKSPACE/openmp-install/include/* $DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
182 sudo cp $GITHUB_WORKSPACE/openmp-install/lib/libomp.a $DEVELOPER_DIR/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib
183
184 - name: vulkansdk for macos
185 if: matrix.os == 'macos-13'
186 run: |
187 wget https://sdk.lunarg.com/sdk/download/1.3.236.0/mac/vulkansdk-macos-1.3.236.0.dmg?Human=true -O vulkansdk-macos-1.3.236.0.dmg
188 hdiutil attach vulkansdk-macos-1.3.236.0.dmg
189 sudo /Volumes/vulkansdk-macos-1.3.236.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $GITHUB_WORKSPACE/vulkansdk-macos-1.3.236.0 --accept-licenses --default-answer --confirm-command install
190
191 - name: Build wheels for macos x86_64
192 if: matrix.os == 'macos-13' && matrix.arch == 'x86_64'
193 uses: pypa/cibuildwheel@v2.17.0
194 env:
195 CIBW_ARCHS_MACOS: ${{ matrix.arch }}
196 CIBW_BUILD: ${{ matrix.build }}
197 CIBW_BUILD_VERBOSITY: 1
198 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=3
199 CMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/toolchains/ios.toolchain.cmake PLATFORM=MAC ARCHS="x86_64"
200 DEPLOYMENT_TARGET="10.9" ENABLE_BITCODE=OFF ENABLE_ARC=OFF ENABLE_VISIBILITY=OFF
201 OpenMP_C_FLAGS="-Xclang -fopenmp" OpenMP_CXX_FLAGS="-Xclang -fopenmp"
202 OpenMP_C_LIB_NAMES="libomp" OpenMP_CXX_LIB_NAMES="libomp"
203 OpenMP_libomp_LIBRARY="libomp.a"
204 Vulkan_LIBRARY=$GITHUB_WORKSPACE/vulkansdk-macos-1.3.236.0/MoltenVK/dylib/macOS/libMoltenVK.dylib
205 with:
206 output-dir: wheelhouse
207
208 - name: Build wheels for macos arm64
209 if: matrix.os == 'macos-13' && matrix.arch == 'arm64'
210 uses: pypa/cibuildwheel@v2.17.0
211 env:
212 CIBW_ARCHS_MACOS: ${{ matrix.arch }}
213 CIBW_BUILD: ${{ matrix.build }}
214 CIBW_BUILD_VERBOSITY: 1
215 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=3
216 CMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/toolchains/ios.toolchain.cmake PLATFORM=MAC_ARM64 ARCHS="arm64"
217 DEPLOYMENT_TARGET="11.0" ENABLE_BITCODE=OFF ENABLE_ARC=OFF ENABLE_VISIBILITY=OFF
218 OpenMP_C_FLAGS="-Xclang -fopenmp" OpenMP_CXX_FLAGS="-Xclang -fopenmp"
219 OpenMP_C_LIB_NAMES="libomp" OpenMP_CXX_LIB_NAMES="libomp"
220 OpenMP_libomp_LIBRARY="libomp.a"
221 Vulkan_LIBRARY=$GITHUB_WORKSPACE/vulkansdk-macos-1.3.236.0/MoltenVK/dylib/macOS/libMoltenVK.dylib
222 with:
223 output-dir: wheelhouse
224
225 - name: Show files
226 run: ls -lh wheelhouse
227 shell: bash
228
229 - name: Verify clean directory
230 run: git diff --exit-code
231 shell: bash
232
233 - name: Upload wheels
234 uses: actions/upload-artifact@v4
235 with:
236 name: wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.build_id }}
237 path: wheelhouse/*.whl
238
239 build_wheels_qemu_cp:
240 name: ${{ matrix.arch }} ${{ matrix.build_cp }} ${{ matrix.build_sub }}
241 runs-on: ubuntu-20.04
242
243 strategy:
244 fail-fast: false
245 matrix:
246 arch: [aarch64, ppc64le, s390x]
247 build_cp: [cp36, cp37, cp38, cp39, cp310, cp311, cp312]
248 build_sub: [manylinux, musllinux]
249
250 steps:
251 - uses: actions/checkout@v4
252 with:
253 submodules: true
254
255 - uses: actions/setup-python@v5
256 with:
257 python-version: '3.x'
258
259 - name: Set up QEMU
260 uses: docker/setup-qemu-action@v3
261 with:
262 platforms: all
263
264 - name: Build wheels for manylinux with qemu
265 uses: pypa/cibuildwheel@v2.17.0
266 env:
267 CIBW_ARCHS_LINUX: ${{ matrix.arch }}
268 CIBW_BUILD: ${{ matrix.build_cp }}-${{ matrix.build_sub }}*
269 CIBW_BUILD_VERBOSITY: 1
270 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=4
271 with:
272 output-dir: wheelhouse
273
274 - name: Show files
275 run: ls -lh wheelhouse
276 shell: bash
277
278 - name: Verify clean directory
279 run: git diff --exit-code
280 shell: bash
281
282 - name: Upload wheels
283 uses: actions/upload-artifact@v4
284 with:
285 name: wheels_qemu_cp-${{ matrix.arch }}-${{ matrix.build_cp }}-${{ matrix.build_sub }}
286 path: wheelhouse/*.whl
287
288 build_wheels_qemu_pp:
289 name: ${{ matrix.arch }} ${{ matrix.build_pp }}
290 runs-on: ubuntu-20.04
291
292 strategy:
293 fail-fast: false
294 matrix:
295 arch: [aarch64]
296 build_pp: [pp37, pp38, pp39, pp310]
297
298 steps:
299 - uses: actions/checkout@v4
300 with:
301 submodules: true
302
303 - uses: actions/setup-python@v5
304 with:
305 python-version: '3.x'
306
307 - name: Set up QEMU
308 uses: docker/setup-qemu-action@v3
309 with:
310 platforms: all
311
312 - name: Build wheels for manylinux with qemu
313 uses: pypa/cibuildwheel@v2.17.0
314 env:
315 CIBW_ARCHS_LINUX: ${{ matrix.arch }}
316 CIBW_BUILD: ${{ matrix.build_pp }}-*
317 CIBW_BUILD_VERBOSITY: 1
318 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=4
319 with:
320 output-dir: wheelhouse
321
322 - name: Show files
323 run: ls -lh wheelhouse
324 shell: bash
325
326 - name: Verify clean directory
327 run: git diff --exit-code
328 shell: bash
329
330 - name: Upload wheels
331 uses: actions/upload-artifact@v4
332 with:
333 name: wheels_qemu_pp-${{ matrix.arch }}-${{ matrix.build_pp }}
334 path: wheelhouse/*.whl
335
336 upload_all:
337 permissions:
338 contents: none
339 name: Upload
340 needs: [build_wheels, build_wheels_qemu_cp, build_wheels_qemu_pp, build_sdist]
341 runs-on: ubuntu-latest
342
343 steps:
344 - uses: actions/setup-python@v5
345 with:
346 python-version: '3.x'
347
348 - uses: actions/download-artifact@v4
349 with:
350 path: dist
351 merge-multiple: true
352
353 - uses: pypa/gh-action-pypi-publish@release/v1
354 with:
355 user: __token__
356 password: ${{ secrets.PYPI_API_TOKEN }}