Skip to content

Python Distribution #422

Python Distribution

Python Distribution #422

Workflow file for this run

# Test PySceneDetect on Linux/OSX/Windows and generate Python distribution (sdist/wheel).
name: Python Distribution
on:
schedule:
- cron: '0 0 * * *'
pull_request:
paths:
- dist/**
- scenedetect/**
- tests/**
push:
paths:
- dist/**
- scenedetect/**
- tests/**
branches:
- main
- develop
- 'releases/**'
tags:
- v*-release
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13, macos-14, ubuntu-20.04, ubuntu-latest, windows-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
# macos-14 builders use M1 (ARM64) which does not have a Python 3.7 package available.
- os: macos-14
python-version: "3.7"
env:
# Version is extracted below and used to find correct package install path.
scenedetect_version: ""
# Setuptools must be pinned for the Python 3.7 builders.
setuptools_version: "${{ matrix.python-version == '3.7' && '==62.3.4' || '' }}"
steps:
- uses: actions/checkout@v4
- name: Setup FFmpeg
# TODO: This action currently does not work for non-x64 builders (e.g. macos-14):
# https://github.com/federicocarboni/setup-ffmpeg/issues/21
if: ${{ runner.arch == 'X64' }}
uses: ./.github/actions/setup-ffmpeg
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install Dependencies
run: |
python -m pip install --upgrade pip build wheel virtualenv setuptools${{ env.setuptools_version }}
pip install av opencv-python-headless --only-binary :all:
pip install -r requirements_headless.txt
- name: Checkout test resources
run: |
git fetch --depth=1 https://github.com/Breakthrough/PySceneDetect.git refs/heads/resources:refs/remotes/origin/resources
git checkout refs/remotes/origin/resources -- tests/resources/
- name: Unit Tests
run: |
python -m pytest -vv
- name: Smoke Test (Module)
run: |
python -m scenedetect version
python -m scenedetect -i tests/resources/testvideo.mp4 -b opencv time --end 2s
python -m scenedetect -i tests/resources/testvideo.mp4 -b pyav time --end 2s
python -m pip uninstall -y scenedetect
- name: Build Package
shell: bash
run: |
python -m build
echo "scenedetect_version=`python -c \"import scenedetect; print(scenedetect.__version__.replace('-', '.'))\"`" >> "$GITHUB_ENV"
- name: Smoke Test Package (Source Dist)
run: |
python -m pip install dist/scenedetect-${{ env.scenedetect_version }}.tar.gz
scenedetect version
scenedetect -i tests/resources/testvideo.mp4 -b opencv time --end 2s
scenedetect -i tests/resources/testvideo.mp4 -b pyav time --end 2s
python -m pip uninstall -y scenedetect
- name: Smoke Test Package (Wheel)
run: |
python -m pip install dist/scenedetect-${{ env.scenedetect_version }}-py3-none-any.whl
scenedetect version
scenedetect -i tests/resources/testvideo.mp4 -b opencv time --end 2s
scenedetect -i tests/resources/testvideo.mp4 -b pyav time --end 2s
python -m pip uninstall -y scenedetect
- name: Upload Package
if: ${{ matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: scenedetect-dist
path: |
dist/*.tar.gz
dist/*.whl