Skip to content

Support Python 3.13 #281

Support Python 3.13

Support Python 3.13 #281

Workflow file for this run

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.13"
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 cp313-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-* cp313-*"
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_64
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