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,33 +31,40 @@ 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'
54
67
run : |
55
- echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
56
68
echo "CC=cl" >> $GITHUB_ENV
57
69
echo "CXX=cl" >> $GITHUB_ENV
58
70
62
74
cd build
63
75
64
76
cmake .. \
77
+ -D CMAKE_GENERATOR=Ninja \
65
78
-D CMAKE_INSTALL_PREFIX=../opencv \
66
79
-D CMAKE_BUILD_TYPE=Release \
67
80
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
@@ -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,30 +129,47 @@ 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
129
- - name : Install dependencies
130
- run : pdm install -G :all --no-self
150
+ - name : Manually install PDM
151
+ if : steps.install-pdm.conclusion == 'skipped'
152
+ run : |
153
+ pipx install pdm
154
+ export PYTHONPATH=$(python${{matrix.python}} -c 'import sys; print(sys.exec_prefix)')
131
155
132
- - uses : ilammy/msvc-dev-cmd@v1
133
- id : msvc-env
134
- if : startsWith(matrix.os, 'windows')
156
+ echo "$PYTHONPATH" >> $GITHUB_PATH
157
+ echo "$PYTHONPATH/bin" >> $GITHUB_PATH
158
+ echo "LD_LIBRARY_PATH=$PYTHONPATH/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> $GITHUB_ENV
159
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENV
160
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
135
161
136
- - name : Setup MSVC environment
137
- if : steps.msvc-env.conclusion == 'success'
162
+ - uses : seanmiddleditch/gha-setup-ninja@master
163
+ id : setup-ninja
164
+ if : matrix.os.artifact-name != 'linux-musl'
165
+
166
+ - name : Manually install ninja
167
+ if : steps.setup-ninja.conclusion == 'skipped'
168
+ run : apk add samurai
169
+
170
+ - name : Setup Windows environment
171
+ id : msvc-env
172
+ if : startsWith(matrix.os.runner, 'windows')
138
173
run : |
139
174
CV_DIR=$(find ./opencv/x64 | grep -i '\.cmake$' | head -n 1)
140
175
echo "OpenCV_DIR=$(realpath $(dirname $CV_DIR))" >> $GITHUB_ENV
@@ -151,20 +186,25 @@ jobs:
151
186
152
187
- uses : actions/upload-artifact@main
153
188
with :
154
- name : wheel-${{matrix.os}}-${{matrix.python}}
189
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155
190
path : ./dist/*.whl
156
191
157
192
test :
158
- name : Test Wheel
193
+ name : Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159
194
needs : [build]
160
195
161
196
strategy :
162
197
matrix :
163
198
os :
164
- - ubuntu-latest
165
- - windows-latest
166
- - macos-13
167
- - macos-latest
199
+ - runner : ubuntu-latest
200
+ container : quay.io/pypa/manylinux_2_34_x86_64
201
+ artifact-name : linux
202
+ # - runner: ubuntu-latest
203
+ # container: quay.io/pypa/musllinux_1_2_x86_64
204
+ # artifact-name: linux-musl
205
+ - runner : windows-latest
206
+ - runner : macos-13
207
+ - runner : macos-latest
168
208
python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169
209
exclude :
170
210
- os : macos-latest
@@ -177,26 +217,41 @@ jobs:
177
217
run :
178
218
shell : bash
179
219
180
- runs-on : ${{ matrix.os }}
220
+ runs-on : ${{ matrix.os.runner }}
221
+ container : ${{ matrix.os.container }}
181
222
182
223
steps :
183
224
- uses : actions/checkout@main
184
225
185
226
- name : Download wheel
186
227
uses : actions/download-artifact@main
187
228
with :
188
- name : wheel-${{matrix.os}}-${{matrix.python}}
229
+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189
230
path : ./dist
190
231
191
232
- uses : pdm-project/setup-pdm@main
233
+ id : install-pdm
234
+ if : ${{ !matrix.os.container }}
192
235
with :
193
236
python-version : ${{ matrix.python }}
194
237
cache : true
195
238
239
+ - name : Manually install PDM
240
+ if : steps.install-pdm.conclusion == 'skipped'
241
+ run : |
242
+ pipx install pdm
243
+ export 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
+ echo "pythonLocation=$PYTHONPATH" >> $GITHUB_ENVd
249
+ echo "PKG_CONFIG_PATH=$PYTHONPATH/lib/pkgconfig" >> $GITHUB_ENV
250
+
196
251
- name : Install dependencies
197
252
run : |
198
253
pdm install -G test --no-self
199
- pdm add dist/*.whl --no-lock
254
+ pdm add -v dist/*.whl --frozen-lockfile
200
255
201
256
- name : Run tests
202
257
run : |
@@ -246,7 +301,6 @@ jobs:
246
301
247
302
- uses : pdm-project/setup-pdm@main
248
303
with :
249
- python-version : " 3"
250
304
cache : true
251
305
252
306
- name : Publish to PyPI
0 commit comments