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+
4855 - uses : ilammy/msvc-dev-cmd@v1
4956 id : msvc-env
50- if : startsWith(matrix.os, 'windows')
57+ if : startsWith(matrix.os.runner , 'windows')
5158
5259 - name : Setup MSVC environment
5360 if : steps.msvc-env.conclusion == 'success'
@@ -81,24 +88,29 @@ jobs:
8188 -D WITH_PNG=OFF \
8289 -D WITH_TIFF=OFF
8390
84- cmake --build . --target install --parallel 4
91+ cmake --build . --target install --parallel $(nproc)
8592
8693 - uses : actions/upload-artifact@main
8794 with :
88- name : opencv-${{ matrix.os }}
95+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
8996 path : ./opencv
9097
9198 build :
92- name : Build Wheel
99+ name : Build Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
93100 needs : [build-opencv]
94101
95102 strategy :
96103 matrix :
97104 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
102114 python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
103115 exclude :
104116 - os : macos-latest
@@ -111,31 +123,56 @@ jobs:
111123 run :
112124 shell : bash
113125
114- runs-on : ${{ matrix.os }}
126+ runs-on : ${{ matrix.os.runner }}
127+ container : ${{ matrix.os.container }}
115128
116129 steps :
117130 - uses : actions/checkout@main
118131
119132 - uses : actions/download-artifact@main
120133 with :
121- name : opencv-${{ matrix.os }}
134+ name : opencv-${{ matrix.os.artifact-name || matrix.os.runner }}
122135 path : ./opencv
123136
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+
124156 - uses : pdm-project/setup-pdm@main
157+ if : steps.install-pdm.conclusion == 'skipped'
125158 with :
126159 python-version : ${{ matrix.python }}
127160 cache : true
128161
129162 - name : Install dependencies
130163 run : pdm install -G :all --no-self
131164
165+ - uses : seanmiddleditch/gha-setup-ninja@master
166+
132167 - uses : ilammy/msvc-dev-cmd@v1
133168 id : msvc-env
134- if : startsWith(matrix.os, 'windows')
169+ if : startsWith(matrix.os.runner , 'windows')
135170
136171 - name : Setup MSVC environment
137172 if : steps.msvc-env.conclusion == 'success'
138173 run : |
174+ choco install -y ninja
175+
139176 CV_DIR=$(find ./opencv/x64 | grep -i '\.cmake$' | head -n 1)
140177 echo "OpenCV_DIR=$(realpath $(dirname $CV_DIR))" >> $GITHUB_ENV
141178 echo "OpenCV_STATIC=ON" >> $GITHUB_ENV
@@ -151,20 +188,25 @@ jobs:
151188
152189 - uses : actions/upload-artifact@main
153190 with :
154- name : wheel-${{matrix.os}}-${{matrix.python}}
191+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
155192 path : ./dist/*.whl
156193
157194 test :
158- name : Test Wheel
195+ name : Test Wheel (${{ matrix.os.artifact-name || matrix.os.runner }}, Python ${{ matrix.python }})
159196 needs : [build]
160197
161198 strategy :
162199 matrix :
163200 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
168210 python : ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
169211 exclude :
170212 - os : macos-latest
@@ -177,26 +219,47 @@ jobs:
177219 run :
178220 shell : bash
179221
180- runs-on : ${{ matrix.os }}
222+ runs-on : ${{ matrix.os.runner }}
223+ container : ${{ matrix.os.container }}
181224
182225 steps :
183226 - uses : actions/checkout@main
184227
185228 - name : Download wheel
186229 uses : actions/download-artifact@main
187230 with :
188- name : wheel-${{matrix.os}}-${{matrix.python}}
231+ name : wheel-${{ matrix.os.artifact-name || matrix.os.runner }}-${{ matrix.python }}
189232 path : ./dist
190233
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+
191253 - uses : pdm-project/setup-pdm@main
254+ if : steps.install-pdm.conclusion == 'skipped'
192255 with :
193256 python-version : ${{ matrix.python }}
194257 cache : true
195258
196259 - name : Install dependencies
197260 run : |
198261 pdm install -G test --no-self
199- pdm add dist/*.whl --no-lock
262+ pdm add -v dist/*.whl --frozen-lockfile
200263
201264 - name : Run tests
202265 run : |
@@ -246,7 +309,6 @@ jobs:
246309
247310 - uses : pdm-project/setup-pdm@main
248311 with :
249- python-version : " 3"
250312 cache : true
251313
252314 - name : Publish to PyPI
0 commit comments