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,28 +31,36 @@ 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
42
47
with :
43
48
repository : opencv/opencv
44
49
ref : ${{ steps.latest-release.outputs.tag }}
45
50
51
+ - uses : seanmiddleditch/gha-setup-ninja@master
52
+ id : setup-ninja
53
+ if : matrix.os.artifact-name != 'linux-musl'
54
+
55
+ - name : Manually install ninja
56
+ if : steps.setup-ninja.conclusion == 'skipped'
57
+ run : apk add samurai
58
+
46
59
- uses : mozilla-actions/sccache-action@main
47
60
48
61
- uses : ilammy/msvc-dev-cmd@v1
49
62
id : msvc-env
50
- if : startsWith(matrix.os, 'windows')
63
+ if : startsWith(matrix.os.runner , 'windows')
51
64
52
65
- name : Setup MSVC environment
53
66
if : steps.msvc-env.conclusion == 'success'
@@ -81,24 +94,29 @@ jobs:
81
94
-D WITH_PNG=OFF \
82
95
-D WITH_TIFF=OFF
83
96
84
- cmake --build . --target install --parallel 4
97
+ cmake --build . --target install --parallel $(nproc)
85
98
86
99
- uses : actions/upload-artifact@main
87
100
with :
88
- name : opencv-${{ matrix.os }}
101
+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
89
102
path : ./opencv
90
103
91
104
build :
92
- name : Build Wheel
105
+ name : Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93
106
needs : [build-opencv]
94
107
95
108
strategy :
96
109
matrix :
97
110
os :
98
- - ubuntu-latest
99
- - windows-latest
100
- - macos-13
101
- - macos-latest
111
+ - runner : ubuntu-latest
112
+ container : quay.io/pypa/manylinux_2_34_x86_64
113
+ artifact-name : linux
114
+ - runner : ubuntu-latest
115
+ container : quay.io/pypa/musllinux_1_2_x86_64
116
+ artifact-name : linux-musl
117
+ - runner : windows-latest
118
+ - runner : macos-13
119
+ - runner : macos-latest
102
120
python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103
121
exclude :
104
122
- os : macos-latest
@@ -111,27 +129,56 @@ jobs:
111
129
run :
112
130
shell : bash
113
131
114
- runs-on : ${{ matrix.os }}
132
+ runs-on : ${{ matrix.os.runner }}
133
+ container : ${{ matrix.os.container }}
115
134
116
135
steps :
117
136
- uses : actions/checkout@main
118
137
119
138
- uses : actions/download-artifact@main
120
139
with :
121
- name : opencv-${{ matrix.os }}
140
+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122
141
path : ./opencv
123
142
124
143
- uses : pdm-project/setup-pdm@main
144
+ id : install-pdm
145
+ if : ${{ !matrix.os.container }}
125
146
with :
126
147
python-version : ${{ matrix.python }}
127
148
cache : true
128
149
150
+ - name : Manually install PDM
151
+ if : steps.install-pdm.conclusion == 'skipped'
152
+ run : |
153
+ set -xve
154
+
155
+ pipx install pdm
156
+ set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
157
+
158
+ echo "$PYTHONPATH" >> $GITHUB_PATH
159
+ echo "$PYTHONPATH/bin" >> $GITHUB_PATH
160
+ echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
161
+
162
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
163
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
164
+ echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
165
+ echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
166
+ echo "PYTHON3_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
167
+
129
168
- name : Install dependencies
130
169
run : pdm install -G :all --no-self
131
170
171
+ - uses : seanmiddleditch/gha-setup-ninja@master
172
+ id : setup-ninja
173
+ if : matrix.os.artifact-name != 'linux-musl'
174
+
175
+ - name : Manually install ninja
176
+ if : steps.setup-ninja.conclusion == 'skipped'
177
+ run : apk add ninja-build
178
+
132
179
- uses : ilammy/msvc-dev-cmd@v1
133
180
id : msvc-env
134
- if : startsWith(matrix.os, 'windows')
181
+ if : startsWith(matrix.os.runner , 'windows')
135
182
136
183
- name : Setup MSVC environment
137
184
if : steps.msvc-env.conclusion == 'success'
@@ -151,20 +198,25 @@ jobs:
151
198
152
199
- uses : actions/upload-artifact@main
153
200
with :
154
- name : wheel-${{matrix.os}}-${{matrix.python}}
201
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155
202
path : ./dist/*.whl
156
203
157
204
test :
158
- name : Test Wheel
205
+ name : Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159
206
needs : [build]
160
207
161
208
strategy :
162
209
matrix :
163
210
os :
164
- - ubuntu-latest
165
- - windows-latest
166
- - macos-13
167
- - macos-latest
211
+ - runner : ubuntu-latest
212
+ container : quay.io/pypa/manylinux_2_34_x86_64
213
+ artifact-name : linux
214
+ - runner : ubuntu-latest
215
+ container : quay.io/pypa/musllinux_1_2_x86_64
216
+ artifact-name : linux-musl
217
+ - runner : windows-latest
218
+ - runner : macos-13
219
+ - runner : macos-latest
168
220
python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169
221
exclude :
170
222
- os : macos-latest
@@ -177,26 +229,46 @@ jobs:
177
229
run :
178
230
shell : bash
179
231
180
- runs-on : ${{ matrix.os }}
232
+ runs-on : ${{ matrix.os.runner }}
233
+ container : ${{ matrix.os.container }}
181
234
182
235
steps :
183
236
- uses : actions/checkout@main
184
237
185
238
- name : Download wheel
186
239
uses : actions/download-artifact@main
187
240
with :
188
- name : wheel-${{matrix.os}}-${{matrix.python}}
241
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189
242
path : ./dist
190
243
191
244
- uses : pdm-project/setup-pdm@main
245
+ id : install-pdm
246
+ if : ${{ !matrix.os.container }}
192
247
with :
193
248
python-version : ${{ matrix.python }}
194
249
cache : true
195
250
251
+ - name : Manually install PDM
252
+ if : steps.install-pdm.conclusion == 'skipped'
253
+ run : |
254
+ set -xve
255
+
256
+ pipx install pdm
257
+ set PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
258
+
259
+ echo "$PYTHONPATH" >> $GITHUB_PATH
260
+ echo "$PYTHONPATH/bin" >> $GITHUB_PATH
261
+ echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
262
+
263
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
264
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
265
+ echo "PYTHON_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
266
+ echo "PYTHON2_ROOT_DIR=$PYTHONPATH" >> $GITHUB_ENV
267
+
196
268
- name : Install dependencies
197
269
run : |
198
270
pdm install -G test --no-self
199
- pdm add dist/*.whl --no-lock
271
+ pdm add -v dist/*.whl --frozen-lockfile
200
272
201
273
- name : Run tests
202
274
run : |
@@ -246,7 +318,6 @@ jobs:
246
318
247
319
- uses : pdm-project/setup-pdm@main
248
320
with :
249
- python-version : " 3"
250
321
cache : true
251
322
252
323
- name : Publish to PyPI
0 commit comments