99
1010jobs :
1111 build-opencv :
12- name : Build OpenCV
12+ name : Build OpenCV (${{ matrix.os.artifact-name || matrix.os.runner }})
1313
1414 strategy :
1515 matrix :
1616 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
2126
2227 defaults :
2328 run :
@@ -26,16 +31,16 @@ jobs:
2631 env :
2732 SCCACHE_GHA_ENABLED : true
2833
29- runs-on : ${{ matrix.os }}
34+ runs-on : ${{ matrix.os.runner }}
35+ container : ${{ matrix.os.container }}
3036
3137 steps :
3238 - name : Get latest release
3339 id : latest-release
3440 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
3944 echo "tag=$(cat latest-release.txt)" >> $GITHUB_OUTPUT
4045
4146 - uses : actions/checkout@main
4550
4651 - uses : mozilla-actions/sccache-action@main
4752
53+ - uses : seanmiddleditch/gha-setup-ninja@master
54+ if : matrix.os.artifact-name != 'linux-musl'
55+
4856 - uses : ilammy/msvc-dev-cmd@v1
4957 id : msvc-env
50- if : startsWith(matrix.os, 'windows')
58+ if : startsWith(matrix.os.runner , 'windows')
5159
5260 - name : Setup MSVC environment
5361 if : steps.msvc-env.conclusion == 'success'
@@ -81,24 +89,29 @@ jobs:
8189 -D WITH_PNG=OFF \
8290 -D WITH_TIFF=OFF
8391
84- cmake --build . --target install --parallel 4
92+ cmake --build . --target install --parallel $(nproc)
8593
8694 - uses : actions/upload-artifact@main
8795 with :
88- name : opencv-${{ matrix.os }}
96+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
8997 path : ./opencv
9098
9199 build :
92- name : Build Wheel
100+ name : Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93101 needs : [build-opencv]
94102
95103 strategy :
96104 matrix :
97105 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
102115 python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103116 exclude :
104117 - os : macos-latest
@@ -111,31 +124,57 @@ jobs:
111124 run :
112125 shell : bash
113126
114- runs-on : ${{ matrix.os }}
127+ runs-on : ${{ matrix.os.runner }}
128+ container : ${{ matrix.os.container }}
115129
116130 steps :
117131 - uses : actions/checkout@main
118132
119133 - uses : actions/download-artifact@main
120134 with :
121- name : opencv-${{ matrix.os }}
135+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122136 path : ./opencv
123137
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+
124157 - uses : pdm-project/setup-pdm@main
158+ if : steps.install-pdm.conclusion == 'skipped'
125159 with :
126160 python-version : ${{ matrix.python }}
127161 cache : true
128162
129163 - name : Install dependencies
130164 run : pdm install -G :all --no-self
131165
166+ - uses : seanmiddleditch/gha-setup-ninja@master
167+ if : matrix.os.artifact-name != 'linux-musl'
168+
132169 - uses : ilammy/msvc-dev-cmd@v1
133170 id : msvc-env
134- if : startsWith(matrix.os, 'windows')
171+ if : startsWith(matrix.os.runner , 'windows')
135172
136173 - name : Setup MSVC environment
137174 if : steps.msvc-env.conclusion == 'success'
138175 run : |
176+ choco install -y ninja
177+
139178 CV_DIR=$(find ./opencv/x64 | grep -i '\.cmake$' | head -n 1)
140179 echo "OpenCV_DIR=$(realpath $(dirname $CV_DIR))" >> $GITHUB_ENV
141180 echo "OpenCV_STATIC=ON" >> $GITHUB_ENV
@@ -151,20 +190,25 @@ jobs:
151190
152191 - uses : actions/upload-artifact@main
153192 with :
154- name : wheel-${{matrix.os}}-${{matrix.python}}
193+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155194 path : ./dist/*.whl
156195
157196 test :
158- name : Test Wheel
197+ name : Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159198 needs : [build]
160199
161200 strategy :
162201 matrix :
163202 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
168212 python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169213 exclude :
170214 - os : macos-latest
@@ -177,26 +221,47 @@ jobs:
177221 run :
178222 shell : bash
179223
180- runs-on : ${{ matrix.os }}
224+ runs-on : ${{ matrix.os.runner }}
225+ container : ${{ matrix.os.container }}
181226
182227 steps :
183228 - uses : actions/checkout@main
184229
185230 - name : Download wheel
186231 uses : actions/download-artifact@main
187232 with :
188- name : wheel-${{matrix.os}}-${{matrix.python}}
233+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189234 path : ./dist
190235
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+
191255 - uses : pdm-project/setup-pdm@main
256+ if : steps.install-pdm.conclusion == 'skipped'
192257 with :
193258 python-version : ${{ matrix.python }}
194259 cache : true
195260
196261 - name : Install dependencies
197262 run : |
198263 pdm install -G test --no-self
199- pdm add dist/*.whl --no-lock
264+ pdm add -v dist/*.whl --frozen-lockfile
200265
201266 - name : Run tests
202267 run : |
@@ -246,7 +311,6 @@ jobs:
246311
247312 - uses : pdm-project/setup-pdm@main
248313 with :
249- python-version : " 3"
250314 cache : true
251315
252316 - name : Publish to PyPI
0 commit comments