-
Notifications
You must be signed in to change notification settings - Fork 38
401 lines (367 loc) · 14.5 KB
/
pythonapp.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
name: Python application
on: [push, pull_request]
env:
FFMPEG_VERSION: "6.0" # https://ffmpeg.org/releases/
SDL_VERSION: "2.26.4" # https://github.com/libsdl-org/SDL/releases
SDL_MIXER_VERSION: "2.6.3" # https://github.com/libsdl-org/SDL_mixer/releases
USE_SDL2_MIXER: "1"
MACOSX_DEPLOYMENT_TARGET: "10.9"
MACOSX_DEPLOYMENT_TARGET_ARM: "11.0"
jobs:
windows_wheels_tests:
runs-on: windows-latest
env:
FF_BUILD_DIR: ~/ff_deps
SDL_ROOT: ~/ff_deps/SDL2
FFMPEG_ROOT: ~/ff_deps/ffmpeg
strategy:
matrix:
python: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Get dependencies
run: |
mkdir "$env:FF_BUILD_DIR"
cd "$env:FF_BUILD_DIR"
curl -sLO "https://github.com/GyanD/codexffmpeg/releases/download/$env:FFMPEG_VERSION/ffmpeg-$env:FFMPEG_VERSION-full_build-shared.zip"
7z x "ffmpeg-$env:FFMPEG_VERSION-full_build-shared.zip"
ren "ffmpeg-$env:FFMPEG_VERSION-full_build-shared" ffmpeg
curl -sLO "https://github.com/libsdl-org/SDL/releases/download/release-$env:SDL_VERSION/SDL2-devel-$env:SDL_VERSION-VC.zip"
7z x "SDL2-devel-$env:SDL_VERSION-VC.zip"
ren "SDL2-$env:SDL_VERSION" SDL2
curl -sLO "https://github.com/libsdl-org/SDL_mixer/releases/download/release-$env:SDL_MIXER_VERSION/SDL2_mixer-devel-$env:SDL_MIXER_VERSION-VC.zip"
7z x "SDL2_mixer-devel-$env:SDL_MIXER_VERSION-VC.zip"
mkdir "SDL2\bin"
mkdir "SDL2\include\SDL2"
Copy-Item "SDL2\COPYING.txt" -destination "SDL2\bin"
Copy-Item "SDL2\README-SDL.txt" -destination "SDL2\bin"
Copy-Item "SDL2\lib\x64\*.dll" -destination "SDL2\bin" -Recurse -Force
Copy-Item "SDL2\lib\x64\*.lib" -destination "SDL2\lib" -Recurse -Force
Copy-Item "SDL2_mixer-$env:SDL_MIXER_VERSION\lib\x64\*.dll" -destination "SDL2\bin" -Recurse -Force
Copy-Item "SDL2_mixer-$env:SDL_MIXER_VERSION\lib\x64\*.lib" -destination "SDL2\lib" -Recurse -Force
Copy-Item "SDL2_mixer-$env:SDL_MIXER_VERSION\include\*" -destination "SDL2\include" -Recurse -Force
Copy-Item "SDL2\include\*.h" -destination "SDL2\include\SDL2" -Recurse -Force
echo "Dependency paths are:"
ls $env:SDL_ROOT
ls $env:FFMPEG_ROOT
- name: Install pip deps
run: |
python -m pip install --upgrade pip virtualenv wheel setuptools cython~=3.0.11 pytest
- name: Make sdist
if: matrix.python == '3.13'
run: python setup.py sdist --formats=gztar
- name: Make wheel
run: |
$env:SDL_ROOT=(get-item $env:SDL_ROOT).FullName
$env:FFMPEG_ROOT=(get-item $env:FFMPEG_ROOT).FullName
python setup.py bdist_wheel
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: py_wheel
path: dist
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v0.1.15
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python -m pip install twine
twine upload dist/*
- name: Test
run: |
# see https://social.msdn.microsoft.com/Forums/security/en-US/0c13bd1a-388f-48cf-a190-7259d39a080f/ffmpeg-doesnt-work-from-inside-a-container-but-works-on-the-host?forum=windowscontainers
# https://trac.ffmpeg.org/ticket/6875, https://stackoverflow.com/questions/46147012/opencv-import-failed-in-windows-container-on-windows-server-2016
# and https://social.msdn.microsoft.com/Forums/en-US/a95032d2-c469-494a-b3f9-521b1389a6c9/cant-use-opencvpython-package-in-windows-container-windows-server-2016-standard?forum=windowscontainers
# for the reason we need to manually copy some missing dlls to the PATH
Invoke-WebRequest "https://github.com/matham/ffpyplayer/releases/download/v4.1.0/ffmpeg_win_dll_container_deps.zip" -OutFile "ffmpeg_win_dll_container_deps.zip"
7z x "ffmpeg_win_dll_container_deps.zip"
$env:PATH="$env:PATH;$env:GITHUB_WORKSPACE\ffmpeg_win_dll_container_deps\x64"
ls "$env:GITHUB_WORKSPACE\ffmpeg_win_dll_container_deps\x64"
$dist_path=(get-item dist).FullName
$root=(get-item .).FullName
$env:FFPYPLAYER_TEST_DIRS="$root\ffpyplayer\tests;$root\examples"
cd ~/
python -m pip install --no-index --find-links=$dist_path ffpyplayer
$name = python -c "import ffpyplayer, os.path;print(os.path.dirname(ffpyplayer.__file__))"
echo $name
# powershell interprets writing to stderr as an error, so only raise error if the return code is none-zero
try {
pytest "$name\tests"
} catch {
if ($LastExitCode -ne 0) {
throw $_
} else {
echo $_
}
}
linux_test_src:
runs-on: ubuntu-latest
needs: windows_wheels_tests
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/download-artifact@v3
with:
name: py_wheel
path: dist
- name: Install
run: |
sudo apt update
sudo apt install -y ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev
sudo apt install -y libavutil-dev libswscale-dev libswresample-dev libpostproc-dev libsdl2-dev libsdl2-2.0-0
sudo apt install -y libsdl2-mixer-2.0-0 libsdl2-mixer-dev python3-dev python3
python3 -m pip install pytest
root=`pwd`
cd ~/
python3 -m pip install `ls $root/dist/ffpyplayer*.tar.gz`
- name: Test
run: |
root=`pwd`
export FFPYPLAYER_TEST_DIRS="$root/ffpyplayer/tests:$root/examples"
cd ~/
name=`python3 -c "import ffpyplayer, os.path;print(os.path.dirname(ffpyplayer.__file__))"`
echo $name
pytest "$name/tests"
linux_test_wheel:
runs-on: ubuntu-latest
needs: linux_wheels
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/download-artifact@v3
with:
name: py_wheel
path: dist
- name: Install
run: |
python3 -m pip install --upgrade pip pytest
root=`pwd`
cd ~/
python3 -m pip install --no-index --find-links=$root/dist ffpyplayer
- name: Test
run: |
root=`pwd`
export FFPYPLAYER_TEST_DIRS="$root/ffpyplayer/tests:$root/examples"
cd ~/
name=`python3 -c "import ffpyplayer, os.path;print(os.path.dirname(ffpyplayer.__file__))"`
echo $name
pytest "$name/tests"
linux_wheels:
env:
CIBW_ENVIRONMENT_LINUX: "USE_SDL2_MIXER=0 PKG_CONFIG_PATH=$HOME/ffmpeg_build/lib/pkgconfig:$HOME/ffmpeg_build/lib64/pkgconfig LD_LIBRARY_PATH=$HOME/ffmpeg_build/lib:$HOME/ffmpeg_build/lib64:$LD_LIBRARY_PATH"
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_ARCHS: ${{ matrix.cibw_archs }}
CIBW_BEFORE_ALL_LINUX: >
cp -r `pwd`/ffmpeg_build $HOME/ffmpeg_build &&
source .ci/yum_deps.sh
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest ]
cibw_archs: [ x86_64 ]
cibw_build: [ 'cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64' ]
# include:
# - cibw_archs: aarch64
# cibw_build: cp37-manylinux_aarch64
# - cibw_archs: aarch64
# cibw_build: cp38-manylinux_aarch64
# - cibw_archs: aarch64
# cibw_build: cp39-manylinux_aarch64
# - cibw_archs: aarch64
# cibw_build: cp310-manylinux_aarch64
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Set up QEMU
if: ${{ matrix.cibw_archs == 'aarch64' }}
uses: docker/setup-qemu-action@v1
- uses: actions/cache@v3
id: deps-cache
with:
path: ffmpeg_build
key: ${{ runner.os }}-${{ matrix.cibw_archs }}-deps-cache-${{ hashFiles('**/build-wheels.sh') }}-${{ hashFiles('**/yum_deps.sh') }}
- name: Build dependencies
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }}
run: |
mkdir dist
docker run --rm -v `pwd`:/io:rw quay.io/pypa/manylinux2014_${{ matrix.cibw_archs }} /io/.ci/build-wheels.sh
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel~=2.20.0
- name: Make wheels
run: |
python -m cibuildwheel --output-dir dist
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: py_wheel
path: dist
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v0.1.15
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python -m pip install twine
twine upload dist/*
osx_wheels_create:
runs-on: macos-13
env:
USE_SDL2_MIXER: 0
FFMPEG_BUILD_PATH: "ffmpeg_build"
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: "cp37-* cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >
DYLD_FALLBACK_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-listdeps {wheel} &&
DYLD_FALLBACK_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
strategy:
matrix:
arch: [ "x86_64", "arm64" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Cache ffmpeg
id: cache-ffmpeg
uses: actions/cache@v3
with:
path: ~/${{ env.FFMPEG_BUILD_PATH }}_${{ matrix.arch }}
key: ${{ runner.os }}-ffmpeg-${{ matrix.arch }}-${{ env.MACOSX_DEPLOYMENT_TARGET }}-${{ env.MACOSX_DEPLOYMENT_TARGET_ARM }}-${{ hashFiles('.ci/build_wheels_osx.sh') }}
- name: Build FFmpeg
if: steps.cache-ffmpeg.outputs.cache-hit != 'true'
run: bash .ci/build_wheels_osx.sh "${{ matrix.arch }}"
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel~=2.20.0
- name: Build wheels
run: |
export REPAIR_LIBRARY_PATH="$HOME/${{ env.FFMPEG_BUILD_PATH }}_${{ matrix.arch }}/lib"
export PKG_CONFIG_PATH="$HOME/${{ env.FFMPEG_BUILD_PATH }}_${{ matrix.arch }}/lib/pkgconfig:$PKG_CONFIG_PATH"
python -m cibuildwheel --output-dir dist
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: py_wheel
path: dist
osx_wheels_fuse_test_upload:
runs-on: macos-13
needs: osx_wheels_create
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: actions/download-artifact@v3
with:
name: py_wheel
path: dist
- name: Fuse FFmpeg arm64/x86
run: |
pip install delocate
cd dist
bash ../.ci/merge_osx_deps.sh
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: py_wheel
path: dist
- name: Upload to GitHub Release
uses: softprops/action-gh-release@v0.1.15
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/')
env:
TWINE_USERNAME: "__token__"
TWINE_PASSWORD: ${{ secrets.pypi_password }}
run: |
python -m pip install twine
twine upload dist/*
- name: Test
run: |
root=`pwd`
export FFPYPLAYER_TEST_DIRS="$root/ffpyplayer/tests:$root/examples"
cd ~/
python -m pip install --upgrade pip virtualenv wheel setuptools pytest
python -m pip install --no-index --find-links=$root/dist ffpyplayer
name=`python -c "import ffpyplayer, os.path;print(os.path.dirname(ffpyplayer.__file__))"`
echo $name
pytest "$name/tests"
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.x
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install
run: |
sudo apt update
sudo apt install ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev
sudo apt install libavutil-dev libswscale-dev libswresample-dev libpostproc-dev libsdl2-dev libsdl2-2.0-0
sudo apt install libsdl2-mixer-2.0-0 libsdl2-mixer-dev python3-dev
python -m pip install --upgrade pip virtualenv wheel setuptools sphinx sphinx_rtd_theme
python -m pip install -e .
- name: Generate docs
run: |
cd doc
make html
- name: gh-pages upload
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp -r doc/build/html ~/docs_temp
git config --global user.email "moiein2000@gmail.com"
git config --global user.name "Matthew Einhorn"
git remote rm origin || true
git remote add origin "https://x-access-token:${GITHUB_TOKEN}@github.com/matham/ffpyplayer.git"
git checkout --orphan gh-pages
cp -r .git ~/docs_git
cd ..
rm -rf ffpyplayer
mkdir ffpyplayer
cd ffpyplayer
cp -r ~/docs_git .git
cp -r ~/docs_temp/* .
touch .nojekyll
git add .
git commit -a -m "Docs for git-$GITHUB_SHA"
git push origin gh-pages -f