9
9
10
10
jobs :
11
11
build-opencv :
12
- name : Build OpenCV
12
+ name : Build OpenCV (${{ matrix.os.artifact-name || matrix.os.runner }})
13
13
14
14
strategy :
15
15
matrix :
16
16
os :
17
- - ubuntu-latest
18
- - windows-latest
19
- - macos-13
20
- - macos-latest
17
+ - runner : ubuntu-latest
18
+ container : quay.io/pypa/manylinux_2_34_x86_64
19
+ artifact-name : linux
20
+ - runner : ubuntu-latest
21
+ container : quay.io/pypa/musllinux_1_2_x86_64
22
+ artifact-name : linux-musl
23
+ - runner : windows-latest
24
+ - runner : macos-13
25
+ - runner : macos-latest
21
26
22
27
defaults :
23
28
run :
@@ -26,16 +31,16 @@ jobs:
26
31
env :
27
32
SCCACHE_GHA_ENABLED : true
28
33
29
- runs-on : ${{ matrix.os }}
34
+ runs-on : ${{ matrix.os.runner }}
35
+ container : ${{ matrix.os.container }}
30
36
31
37
steps :
32
38
- name : Get latest release
33
39
id : latest-release
34
40
run : |
35
- curl -s https://api.github.com/repos/opencv/opencv/releases/latest \
36
- -H "Accept: application/vnd.github.v3+json" \
37
- -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
38
- | jq -r '.tag_name' | tee latest-release.txt
41
+ curl -Ls -o /dev/null -w %{url_effective} \
42
+ https://github.com/opencv/opencv/releases/latest \
43
+ | sed 's#.*tag/\(.*\)$#\1#' > latest-release.txt
39
44
echo "tag=$(cat latest-release.txt)" >> $GITHUB_OUTPUT
40
45
41
46
- uses : actions/checkout@main
45
50
46
51
- uses : mozilla-actions/sccache-action@main
47
52
53
+ - uses : seanmiddleditch/gha-setup-ninja@master
54
+ if : matrix.os.artifact-name != 'linux-musl'
55
+
48
56
- uses : ilammy/msvc-dev-cmd@v1
49
57
id : msvc-env
50
- if : startsWith(matrix.os, 'windows')
58
+ if : startsWith(matrix.os.runner , 'windows')
51
59
52
60
- name : Setup MSVC environment
53
61
if : steps.msvc-env.conclusion == 'success'
@@ -81,24 +89,29 @@ jobs:
81
89
-D WITH_PNG=OFF \
82
90
-D WITH_TIFF=OFF
83
91
84
- cmake --build . --target install --parallel 4
92
+ cmake --build . --target install --parallel $(nproc)
85
93
86
94
- uses : actions/upload-artifact@main
87
95
with :
88
- name : opencv-${{ matrix.os }}
96
+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
89
97
path : ./opencv
90
98
91
99
build :
92
- name : Build Wheel
100
+ name : Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93
101
needs : [build-opencv]
94
102
95
103
strategy :
96
104
matrix :
97
105
os :
98
- - ubuntu-latest
99
- - windows-latest
100
- - macos-13
101
- - macos-latest
106
+ - runner : ubuntu-latest
107
+ container : quay.io/pypa/manylinux_2_34_x86_64
108
+ artifact-name : linux
109
+ - runner : ubuntu-latest
110
+ container : quay.io/pypa/musllinux_1_2_x86_64
111
+ artifact-name : linux-musl
112
+ - runner : windows-latest
113
+ - runner : macos-13
114
+ - runner : macos-latest
102
115
python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103
116
exclude :
104
117
- os : macos-latest
@@ -111,31 +124,57 @@ jobs:
111
124
run :
112
125
shell : bash
113
126
114
- runs-on : ${{ matrix.os }}
127
+ runs-on : ${{ matrix.os.runner }}
128
+ container : ${{ matrix.os.container }}
115
129
116
130
steps :
117
131
- uses : actions/checkout@main
118
132
119
133
- uses : actions/download-artifact@main
120
134
with :
121
- name : opencv-${{ matrix.os }}
135
+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122
136
path : ./opencv
123
137
138
+ - name : Manually install PDM
139
+ id : install-pdm
140
+ if : matrix.os.container
141
+ run : |
142
+ set -xve
143
+
144
+ curl -fsSL https://pdm.fming.dev/install-pdm.py | python3
145
+ set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
146
+
147
+ echo "$PYTHONPATH" >> $GITHUB_PATH
148
+ echo "$PYTHONPATH/bin" >> $GITHUB_PATH
149
+ echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
150
+
151
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
152
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
153
+ echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
154
+ echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
155
+ echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
156
+
124
157
- uses : pdm-project/setup-pdm@main
158
+ if : steps.install-pdm.conclusion == 'skipped'
125
159
with :
126
160
python-version : ${{ matrix.python }}
127
161
cache : true
128
162
129
163
- name : Install dependencies
130
164
run : pdm install -G :all --no-self
131
165
166
+ - uses : seanmiddleditch/gha-setup-ninja@master
167
+ if : matrix.os.artifact-name != 'linux-musl'
168
+
132
169
- uses : ilammy/msvc-dev-cmd@v1
133
170
id : msvc-env
134
- if : startsWith(matrix.os, 'windows')
171
+ if : startsWith(matrix.os.runner , 'windows')
135
172
136
173
- name : Setup MSVC environment
137
174
if : steps.msvc-env.conclusion == 'success'
138
175
run : |
176
+ choco install -y ninja
177
+
139
178
CV_DIR=$(find ./opencv/x64 | grep -i '\.cmake$' | head -n 1)
140
179
echo "OpenCV_DIR=$(realpath $(dirname $CV_DIR))" >> $GITHUB_ENV
141
180
echo "OpenCV_STATIC=ON" >> $GITHUB_ENV
@@ -151,20 +190,25 @@ jobs:
151
190
152
191
- uses : actions/upload-artifact@main
153
192
with :
154
- name : wheel-${{matrix.os}}-${{matrix.python}}
193
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155
194
path : ./dist/*.whl
156
195
157
196
test :
158
- name : Test Wheel
197
+ name : Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159
198
needs : [build]
160
199
161
200
strategy :
162
201
matrix :
163
202
os :
164
- - ubuntu-latest
165
- - windows-latest
166
- - macos-13
167
- - macos-latest
203
+ - runner : ubuntu-latest
204
+ container : quay.io/pypa/manylinux_2_34_x86_64
205
+ artifact-name : linux
206
+ - runner : ubuntu-latest
207
+ container : quay.io/pypa/musllinux_1_2_x86_64
208
+ artifact-name : linux-musl
209
+ - runner : windows-latest
210
+ - runner : macos-13
211
+ - runner : macos-latest
168
212
python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169
213
exclude :
170
214
- os : macos-latest
@@ -177,26 +221,47 @@ jobs:
177
221
run :
178
222
shell : bash
179
223
180
- runs-on : ${{ matrix.os }}
224
+ runs-on : ${{ matrix.os.runner }}
225
+ container : ${{ matrix.os.container }}
181
226
182
227
steps :
183
228
- uses : actions/checkout@main
184
229
185
230
- name : Download wheel
186
231
uses : actions/download-artifact@main
187
232
with :
188
- name : wheel-${{matrix.os}}-${{matrix.python}}
233
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189
234
path : ./dist
190
235
236
+ - name : Manually install PDM
237
+ id : install-pdm
238
+ if : matrix.os.container
239
+ run : |
240
+ set -xve
241
+
242
+ curl -fsSL https://pdm.fming.dev/install-pdm.py | python
243
+ set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
244
+
245
+ echo "$PYTHONPATH" >> $GITHUB_PATH
246
+ echo "$PYTHONPATH/bin" >> $GITHUB_PATH
247
+ echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
248
+
249
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
250
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
251
+ echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
252
+ echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
253
+ echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
254
+
191
255
- uses : pdm-project/setup-pdm@main
256
+ if : steps.install-pdm.conclusion == 'skipped'
192
257
with :
193
258
python-version : ${{ matrix.python }}
194
259
cache : true
195
260
196
261
- name : Install dependencies
197
262
run : |
198
263
pdm install -G test --no-self
199
- pdm add dist/*.whl --no-lock
264
+ pdm add -v dist/*.whl --frozen-lockfile
200
265
201
266
- name : Run tests
202
267
run : |
@@ -246,7 +311,6 @@ jobs:
246
311
247
312
- uses : pdm-project/setup-pdm@main
248
313
with :
249
- python-version : " 3"
250
314
cache : true
251
315
252
316
- name : Publish to PyPI
0 commit comments