-
Notifications
You must be signed in to change notification settings - Fork 68
183 lines (165 loc) · 7.96 KB
/
build_wheels.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
name: Build and deploy python wheels to PyPI
on:
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
push:
tags:
- "v*.*.*"
jobs:
build_manylinux_wheels:
name: Build linux wheels with ${{ matrix.py_ver_prefix }}-${{ matrix.linux_arch }}-${{ matrix.device }}
runs-on: ubuntu-20.04
strategy:
matrix:
py_ver_prefix: [cp36, cp37, cp38, cp39, cp310]
linux_arch: [x86_64, i686, aarch64, s390x, ppc64le] #the maximum timeout of a job is 360 minutes, which is easy to time out, so we compile different system architectures separately.
device: [cpu, gpu]
exclude:
- linux_arch: i686
device: gpu
- linux_arch: aarch64
device: gpu
- linux_arch: s390x
device: gpu
- linux_arch: ppc64le
device: gpu
fail-fast: false
timeout-minutes: 1440
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Get python path
run: |
sudo apt update
sudo apt install -y jq
echo PY_PATH=$(echo '{"cp36": "cp36-cp36m", "cp37": "cp37-cp37m", "cp38": "cp38-cp38", "cp39": "cp39-cp39", "cp310": "cp310-cp310", "cp311": "cp311-cp311", "cp312": "cp312-cp312", "pp37": "pp37-pypy37_pp73", "pp38": "pp38-pypy38_pp73", "pp39": "pp39-pypy39_pp73"}' | jq .${{matrix.py_ver_prefix}} ) >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Get necessary envs that the current process has access to
id: set_env
run: |
from os import environ, sched_getaffinity
# get the cpu cores
num_cpus = len(sched_getaffinity(0))
output_file = environ["GITHUB_OUTPUT"]
with open(output_file, "a", encoding="utf-8") as output_stream:
output_stream.write(f"count={num_cpus}\n")
shell: python
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_ENVIRONMENT: >
LD_LIBRARY_PATH=/opt/python/${{ env.PY_PATH }}/lib:/opt/python/cp38-cp38/lib:/opt/python/cp310-cp310/lib
CMAKE_BUILD_PARALLEL_LEVEL=${{ steps.set_env.outputs.count }}
GIT_SHA=${{ github.sha }}
DEVICE=${{ matrix.device }}
CUDA_PATH=/usr/local/cuda
SCRIPT_EXEC_MODE=x86
CIBW_BUILD_VERBOSITY: 1
CIBW_BUILD: ${{ matrix.py_ver_prefix }}-*
CIBW_SKIP: "*musllinux*" #disable musllinux now
CIBW_ARCHS_LINUX: ${{ matrix.linux_arch }}
#CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/${{ github.repository }}_manylinux2014_x86_64_shared_python:latest
#CIBW_MANYLINUX_I686_IMAGE: ghcr.io/${{ github.repository }}_manylinux2014_i686_shared_python:latest
#CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/${{ github.repository }}_manylinux2014_aarch64_shared_python:latest
#CIBW_MANYLINUX_PPC64LE_IMAGE: ghcr.io/${{ github.repository }}_manylinux2014_ppc64le_shared_python:latest
#CIBW_MANYLINUX_S390X_IMAGE: ghcr.io/${{ github.repository }}_manylinux2014_s390x_shared_python:latest
CIBW_MANYLINUX_X86_64_IMAGE: smartbrave/manylinux2014_x86_64_shared_python:latest
CIBW_MANYLINUX_I686_IMAGE: smartbrave/manylinux2014_i686_shared_python:latest
CIBW_MANYLINUX_AARCH64_IMAGE: smartbrave/manylinux2014_aarch64_shared_python:latest
CIBW_MANYLINUX_PPC64LE_IMAGE: smartbrave/manylinux2014_ppc64le_shared_python:latest
CIBW_MANYLINUX_S390X_IMAGE: smartbrave/manylinux2014_s390x_shared_python:latest
CIBW_BEFORE_ALL_LINUX: >
(./scripts/build_ffmpeg.sh --device=${{ matrix.device }})
CIBW_REPAIR_WHEEL_COMMAND_LINUX:
tmp_dir=$(mktemp -d) &&
unzip -d ${tmp_dir} {wheel} &&
auditwheel -v repair $(ldd ${tmp_dir}/bmf/lib/* | awk '{if(NF>1){print $1}}' | grep "avdevice\|avfilter\|avformat\|avcodec\|postproc\|swresample\|swscale\|avutil\|cuda\|libnpp\|libxcb\|libXau\|libbz2\|bmf_module_sdk\|engine\|hmp" | sort | uniq | awk '{printf(" --exclude %s", $1);}') -w {dest_dir} {wheel} &&
rm -rf ${tmp_dir}
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_macos_wheels:
name: Build macos wheels with ${{ matrix.py_ver_prefix }}-${{ matrix.macos_arch }}
runs-on: macos-12 # On the macOS-12 system, the wheel package generated by using the xcode14.0~14.3 version compiler will have problems at python runtime which installed by homebrew, and the error is reported: "Symbol not found: _PyBaseObject_Type", please refer to issue: https://github.com/pybind/pybind11/pull/4301 and https://github.com/python/cpython/issues/97524. So we use macos-11 here.
strategy:
matrix:
py_ver_prefix: [cp36, cp37, cp38, cp39, cp310]
macos_arch: [x86_64, arm64, universal2]
exclude:
- py_ver_prefix: cp36
macos_arch: arm64
- py_ver_prefix: cp36
macos_arch: universal2
- py_ver_prefix: cp37
macos_arch: arm64
- py_ver_prefix: cp37
macos_arch: universal2
- py_ver_prefix: cp38 # the universal python package is experimental on Intel host, so we disable cross-compiling for python3.8.
macos_arch: arm64
- py_ver_prefix: cp38
macos_arch: universal2
fail-fast: false
timeout-minutes: 1440
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: Build wheels
uses: pypa/[email protected]
env:
#TODO get real cpu counts
# HAVE_STD_REGEX and RUN_HAVE_STD_REGES is needed by google benchmark when compiling ARM64 on x86_64 for macos.
CIBW_ENVIRONMENT: CMAKE_BUILD_PARALLEL_LEVEL=10 GIT_SHA=${{ github.sha }} PKG_CONFIG_PATH="$(pwd)/ffmpeg_${{ matrix.macos_arch }}/lib/pkgconfig" CMAKE_ARGS="-DHAVE_STD_REGEX=ON -DRUN_HAVE_STD_REGEX=1"
CIBW_BUILD: ${{ matrix.py_ver_prefix }}-*
CIBW_BUILD_VERBOSITY: 1
CIBW_ARCHS_MACOS: ${{ matrix.macos_arch }}
CIBW_BEFORE_ALL_MACOS: >
sed -i '' '/sigma_gn /s/^/\/\//g' bmf/hml/third_party/benchmark/src/complexity.cc &&
brew list python@3.$(echo ${{ matrix.py_ver_prefix }} | cut -c 4-); if [ $? -eq 0 ]; then brew uninstall --ignore-dependencies python@3.$(echo ${{ matrix.py_ver_prefix }} | cut -c 4-); fi
CIBW_BEFORE_BUILD: >
./scripts/build_ffmpeg.sh --arch=${{ matrix.macos_arch }} &&
for xcode_python_root in /Applications/Xcode*/Contents/Developer/Library/Frameworks/Python3.framework;do if [ -d ${xcode_python_root} ]; then mv ${xcode_python_root} ${xcode_python_root}.bak; fi; done
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
upload_all_to_pypi:
needs: [build_manylinux_wheels, build_macos_wheels]
runs-on: ubuntu-latest # pypa/gh-action-pypi-publish only support linux
if: startsWith(github.ref, 'refs/tags/')
#if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package distributions to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
skip-existing: true
repository-url: https://test.pypi.org/legacy/
user: __token__
password: ${{ secrets.TEST_PYPI_TOKEN }}
#packages-dir: wheelhouse/
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
verbose: true
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
#packages-dir: wheelhouse/