Elffuss BraidHub

kikocis/ncnn public

master · 12.8 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.20.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.20.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.20.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.290.0/mac/vulkansdk-macos-1.3.290.0.dmg?Human=true -O vulkansdk-macos-1.3.290.0.dmg
188 hdiutil attach vulkansdk-macos-1.3.290.0.dmg
189 sudo /Volumes/vulkansdk-macos-1.3.290.0/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $GITHUB_WORKSPACE/vulkansdk-macos-1.3.290.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.20.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=$MAC_DEPLOYMENT_TARGET 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.290.0/macOS/lib/libMoltenVK.dylib
205 MACOSX_DEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET
206 with:
207 output-dir: wheelhouse
208
209 - name: Build wheels for macos arm64
210 if: matrix.os == 'macos-13' && matrix.arch == 'arm64'
211 uses: pypa/cibuildwheel@v2.20.0
212 env:
213 CIBW_ARCHS_MACOS: ${{ matrix.arch }}
214 CIBW_BUILD: ${{ matrix.build }}
215 CIBW_BUILD_VERBOSITY: 1
216 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=3
217 CMAKE_TOOLCHAIN_FILE=$GITHUB_WORKSPACE/toolchains/ios.toolchain.cmake PLATFORM=MAC_ARM64 ARCHS="arm64"
218 DEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET ENABLE_BITCODE=OFF ENABLE_ARC=OFF ENABLE_VISIBILITY=OFF
219 OpenMP_C_FLAGS="-Xclang -fopenmp" OpenMP_CXX_FLAGS="-Xclang -fopenmp"
220 OpenMP_C_LIB_NAMES="libomp" OpenMP_CXX_LIB_NAMES="libomp"
221 OpenMP_libomp_LIBRARY="libomp.a"
222 Vulkan_LIBRARY=$GITHUB_WORKSPACE/vulkansdk-macos-1.3.290.0/macOS/lib/libMoltenVK.dylib
223 MACOSX_DEPLOYMENT_TARGET=$MAC_DEPLOYMENT_TARGET
224 with:
225 output-dir: wheelhouse
226
227 - name: Show files
228 run: ls -lh wheelhouse
229 shell: bash
230
231 - name: Verify clean directory
232 run: git diff --exit-code
233 shell: bash
234
235 - name: Upload wheels
236 uses: actions/upload-artifact@v4
237 with:
238 name: wheels-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.build_id }}
239 path: wheelhouse/*.whl
240
241 build_wheels_qemu_cp:
242 name: ${{ matrix.arch }} ${{ matrix.build_cp }} ${{ matrix.build_sub }}
243 runs-on: ubuntu-20.04
244
245 strategy:
246 fail-fast: false
247 matrix:
248 arch: [aarch64, ppc64le, s390x]
249 build_cp: [cp36, cp37, cp38, cp39, cp310, cp311, cp312, cp313]
250 build_sub: [manylinux, musllinux]
251
252 steps:
253 - uses: actions/checkout@v4
254 with:
255 submodules: true
256
257 - uses: actions/setup-python@v5
258 with:
259 python-version: '3.x'
260
261 - name: Set up QEMU
262 uses: docker/setup-qemu-action@v3
263 with:
264 platforms: all
265
266 - name: Build wheels for manylinux with qemu
267 uses: pypa/cibuildwheel@v2.20.0
268 env:
269 CIBW_ARCHS_LINUX: ${{ matrix.arch }}
270 CIBW_BUILD: ${{ matrix.build_cp }}-${{ matrix.build_sub }}*
271 CIBW_BUILD_VERBOSITY: 1
272 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=4
273 with:
274 output-dir: wheelhouse
275
276 - name: Show files
277 run: ls -lh wheelhouse
278 shell: bash
279
280 - name: Verify clean directory
281 run: git diff --exit-code
282 shell: bash
283
284 - name: Upload wheels
285 uses: actions/upload-artifact@v4
286 with:
287 name: wheels_qemu_cp-${{ matrix.arch }}-${{ matrix.build_cp }}-${{ matrix.build_sub }}
288 path: wheelhouse/*.whl
289
290 build_wheels_qemu_pp:
291 name: ${{ matrix.arch }} ${{ matrix.build_pp }}
292 runs-on: ubuntu-20.04
293
294 strategy:
295 fail-fast: false
296 matrix:
297 arch: [aarch64]
298 build_pp: [pp37, pp38, pp39, pp310]
299
300 steps:
301 - uses: actions/checkout@v4
302 with:
303 submodules: true
304
305 - uses: actions/setup-python@v5
306 with:
307 python-version: '3.x'
308
309 - name: Set up QEMU
310 uses: docker/setup-qemu-action@v3
311 with:
312 platforms: all
313
314 - name: Build wheels for manylinux with qemu
315 uses: pypa/cibuildwheel@v2.20.0
316 env:
317 CIBW_ARCHS_LINUX: ${{ matrix.arch }}
318 CIBW_BUILD: ${{ matrix.build_pp }}-*
319 CIBW_BUILD_VERBOSITY: 1
320 CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=4
321 with:
322 output-dir: wheelhouse
323
324 - name: Show files
325 run: ls -lh wheelhouse
326 shell: bash
327
328 - name: Verify clean directory
329 run: git diff --exit-code
330 shell: bash
331
332 - name: Upload wheels
333 uses: actions/upload-artifact@v4
334 with:
335 name: wheels_qemu_pp-${{ matrix.arch }}-${{ matrix.build_pp }}
336 path: wheelhouse/*.whl
337
338 upload_all:
339 permissions:
340 contents: none
341 name: Upload
342 needs: [build_wheels, build_wheels_qemu_cp, build_wheels_qemu_pp, build_sdist]
343 runs-on: ubuntu-latest
344
345 steps:
346 - uses: actions/setup-python@v5
347 with:
348 python-version: '3.x'
349
350 - uses: actions/download-artifact@v4
351 with:
352 path: dist
353 merge-multiple: true
354
355 - uses: pypa/gh-action-pypi-publish@release/v1
356 with:
357 user: __token__
358 password: ${{ secrets.PYPI_API_TOKEN }}