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