Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ updates:
interval: "monthly"

- package-ecosystem: "cargo"
directory: "/native"
directory: "/av"
schedule:
interval: "monthly"
195 changes: 195 additions & 0 deletions .github/workflows/build-av.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
# Callers run build-python.yml first: validation installs its dist-python wheel.
name: Build tensorcodec-av
on:
workflow_call:
permissions:
contents: read
jobs:
linux:
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
target: x86_64
- runner: ubuntu-24.04-arm
target: aarch64
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.2.0
with:
python-version: '3.12'
- uses: actions/cache/restore@v6
id: native-cache
with:
path: .native-deps
key: manylinux2014-${{ matrix.target }}-${{ hashFiles('scripts/build_nasm.sh', 'scripts/build_openssl.sh', 'scripts/build_dav1d.sh', 'scripts/build_ffmpeg.sh') }}
- name: Build manylinux2014 wheel
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
manylinux: '2014'
command: build
args: -m av/Cargo.toml --release --locked --auditwheel repair --out dist
before-script-linux: |
/opt/python/cp310-cp310/bin/python -m pip install libclang==18.1.1
export LIBCLANG_PATH="$(/opt/python/cp310-cp310/bin/python -c 'from clang import cindex; print(cindex.Config.library_path)')"
export BINDGEN_EXTRA_CLANG_ARGS="-I$(gcc -print-file-name=include)"
prefix="$PWD/.native-deps"
export PKG_CONFIG_PATH="$prefix/openssl/lib/pkgconfig"
export LD_LIBRARY_PATH="$prefix/openssl/lib:$prefix/ffmpeg/lib"
if [ ! -f "$prefix/ready" ]; then
yum install -y perl-core
/opt/python/cp310-cp310/bin/python -m pip install meson==1.12.1 ninja==1.13.2
export PATH="/opt/python/cp310-cp310/bin:$PATH"
if [ "$(uname -m)" = x86_64 ]; then
bash scripts/build_nasm.sh "$prefix/nasm"
export PATH="$prefix/nasm/bin:$PATH"
fi
bash scripts/build_openssl.sh "$prefix/openssl"
bash scripts/build_ffmpeg.sh "$prefix/ffmpeg"
touch "$prefix/ready"
fi
export FFMPEG_DIR="$prefix/ffmpeg"
- name: Check native cache completeness
if: always()
id: native-ready
run: |
if [ -f .native-deps/ready ]; then echo 'ready=true' >> "$GITHUB_OUTPUT"; fi
- uses: actions/cache/save@v6
if: always() && steps.native-ready.outputs.ready == 'true' && steps.native-cache.outputs.cache-hit != 'true'
with:
path: .native-deps
key: ${{ steps.native-cache.outputs.cache-primary-key }}
- name: Check final wheel size
run: uv run --no-project python scripts/check_wheel_size.py dist/*.whl --output reports/wheel-size.json
- uses: actions/upload-artifact@v7
if: always()
with:
name: wheel-size-linux-${{ matrix.target }}
path: reports/wheel-size.json
if-no-files-found: warn
- uses: actions/download-artifact@v8
with:
name: dist-python
path: python-dist
- name: Install validation tools and wheels
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
uv venv
uv pip install pytest numpy twine 'opencv-python-headless>=4.12' 'Pillow>=11.3' dist/*.whl python-dist/*.whl
- name: Generate baseline runtime fixtures
run: uv run --no-sync python scripts/check_wheel_runtime.py generate .runtime-fixtures
- name: Test on glibc 2.17 with Python 3.10 and 3.13
run: |
docker run --rm -v "$PWD:/io:ro" quay.io/pypa/manylinux2014_${{ matrix.target }} bash -euxc '
for abi in cp310-cp310 cp313-cp313; do
python="/opt/python/$abi/bin/python"
"$python" -m venv "/tmp/$abi"
runtime="/tmp/$abi/bin/python"
if [ "$abi" = cp310-cp310 ]; then "$runtime" -m pip install --only-binary=:all: numpy==1.26.4; fi
"$runtime" -m pip install --only-binary=:all: /io/dist/*.whl /io/python-dist/*.whl
env -u LD_LIBRARY_PATH "$runtime" /io/scripts/check_wheel_runtime.py check /io/.runtime-fixtures
done
'
- name: Install pinned reference
run: uv pip install torch==2.14.1 torchcodec==0.17.0 --index-url https://download.pytorch.org/whl/cpu
- name: Use bundled FFmpeg for the reference
run: uv run --no-sync python scripts/configure_oracle_ffmpeg.py
- name: Validate distribution and playback
run: |
uv run --no-sync python -m twine check --strict dist/*
uv run --no-sync pytest tests/test_video_contract.py tests/test_audio_contract.py --backend torchcodec
uv run --no-sync pytest --compare
- uses: actions/upload-artifact@v7
with:
name: dist-av-linux-${{ matrix.target }}
path: dist/*.whl
if-no-files-found: error
macos:
runs-on: macos-15
env:
MACOSX_DEPLOYMENT_TARGET: '14.0'
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.2.0
with:
python-version: '3.12'
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: av
- uses: prefix-dev/setup-pixi@v0.10.2
with:
pixi-version: v0.81.0
run-install: false
global-environments: ffmpeg=7.1.1=gpl_*
global-cache: true
- name: Install build tools
run: |
brew install nasm pkg-config coreutils meson ninja
uv venv
uv pip install numpy pytest 'opencv-python-headless>=4.12' 'Pillow>=11.3' 'maturin>=1.8,<2' delocate twine
echo "$PWD/.venv/bin" >> "$GITHUB_PATH"
echo "LIBCLANG_PATH=$(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib" >> "$GITHUB_ENV"
echo "$HOME/.pixi/envs/ffmpeg/bin" >> "$GITHUB_PATH"
- uses: actions/cache/restore@v6
id: native-cache
with:
path: .native-deps/macos
key: macos14-arm64-${{ hashFiles('scripts/build_openssl.sh', 'scripts/build_dav1d.sh', 'scripts/build_ffmpeg.sh', 'scripts/build_macos_wheel.sh') }}
- name: Build and bundle wheel
run: bash scripts/build_macos_wheel.sh
- uses: actions/cache/save@v6
if: always() && steps.native-cache.outputs.cache-hit != 'true' && hashFiles('.native-deps/macos/ready') != ''
with:
path: .native-deps/macos
key: ${{ steps.native-cache.outputs.cache-primary-key }}
- name: Hide build-time FFmpeg libraries
run: mv .native-deps/macos .native-deps/macos-build-only
- uses: actions/download-artifact@v8
with:
name: dist-python
path: python-dist
- name: Validate installed wheels
run: |
uv pip install dist/*.whl python-dist/*.whl
python -m twine check --strict dist/*
pytest
python scripts/check_wheel_runtime.py generate .runtime-fixtures
- name: Test clean Python 3.10 and 3.13 environments
run: |
for version in 3.10 3.13; do
uv venv "/tmp/runtime-$version" --python "$version"
uv pip install --python "/tmp/runtime-$version/bin/python" dist/*.whl python-dist/*.whl
"/tmp/runtime-$version/bin/python" scripts/check_wheel_runtime.py check .runtime-fixtures
done
- name: Restore build cache
if: always()
run: |
if [ -d .native-deps/macos-build-only ]; then
mv .native-deps/macos-build-only .native-deps/macos
fi
- uses: actions/upload-artifact@v7
with:
name: dist-av-macos-arm64
path: dist/*.whl
if-no-files-found: error
sdist:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.2.0
with:
python-version: '3.12'
- name: Build and check source distribution
run: |
uvx --from 'maturin>=1.8,<2' maturin sdist -m av/Cargo.toml --out dist
uvx twine check --strict dist/*
- uses: actions/upload-artifact@v7
with:
name: dist-av-sdist
path: dist/*.tar.gz
if-no-files-found: error
68 changes: 68 additions & 0 deletions .github/workflows/build-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build tensorcodec
on:
workflow_call:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.12'
- name: Build and check wheel and sdist
run: |
python -m pip install build twine
python -m build --outdir dist
python -m twine check --strict dist/*
- uses: actions/upload-artifact@v7
with:
name: dist-python
path: dist/*
if-no-files-found: error
test-without-av:
needs: build
strategy:
fail-fast: false
matrix:
include:
- runner: windows-2025
python: '3.12'
opencv: 'opencv-python-headless>=4.12'
- runner: macos-15-intel
python: '3.10'
opencv: 'opencv-python-headless==4.12.0.88' # lower bound
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
- uses: actions/download-artifact@v8
with:
name: dist-python
path: dist
# Fixtures need libaom; Homebrew's FFmpeg lacks it, so use conda-forge's like the other jobs.
- uses: prefix-dev/setup-pixi@v0.10.2
env:
PIXI_HOME: ${{ runner.temp }}/pixi
with:
pixi-version: v0.81.0
run-install: false
global-environments: ffmpeg=7.1.1=gpl_*
global-cache: true
- name: Put fixture FFmpeg on PATH
env:
FFMPEG_BIN: ${{ runner.temp }}/pixi/envs/ffmpeg/${{ runner.os == 'Windows' && 'Library/bin' || 'bin' }}
run: echo "$FFMPEG_BIN" >> "$GITHUB_PATH"
- name: Install tensorcodec without tensorcodec-av
run: |
python -m pip install pytest 'Pillow>=11.3' '${{ matrix.opencv }}'
python -m pip install --no-index --find-links dist "tensorcodec[images]"
python -c "import importlib.util as u; assert u.find_spec('tensorcodec_av') is None"
- name: Test image codecs
run: python -m pytest tests/test_images.py tests/test_image_encoders.py tests/test_av_optional.py tests/test_versions.py
25 changes: 15 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
macos:
uses: ./.github/workflows/macos-wheels.yml
python:
uses: ./.github/workflows/build-python.yml
av:
needs: python
uses: ./.github/workflows/build-av.yml
test:
runs-on: ubuntu-24.04
steps:
Expand All @@ -24,7 +27,7 @@ jobs:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: native
workspaces: av
- uses: prefix-dev/setup-pixi@v0.10.2
with:
pixi-version: v0.81.0
Expand All @@ -35,7 +38,7 @@ jobs:
run: |
python -m venv .venv
.venv/bin/python -m pip install --upgrade pip
.venv/bin/pip install numpy pytest ruff 'maturin>=1.8,<2' 'opencv-python-headless>=4.13,<5' 'Pillow>=11.3'
.venv/bin/pip install numpy pytest ruff 'maturin>=1.8,<2' 'opencv-python-headless>=4.12' 'Pillow>=11.3'
echo "$GITHUB_WORKSPACE/.venv/bin" >> "$GITHUB_PATH"
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> "$GITHUB_ENV"
- name: Configure prebuilt FFmpeg
Expand All @@ -51,12 +54,14 @@ jobs:
"$prefix/bin/ffmpeg" -version
- name: Static checks
run: |
ruff check src/tensorcodec tests scripts benchmarks/image_codecs.py
ruff format --check src/tensorcodec tests scripts benchmarks/image_codecs.py
cargo fmt --manifest-path native/Cargo.toml --check
cargo clippy --manifest-path native/Cargo.toml --locked -- -D warnings
- name: Build extension against prebuilt FFmpeg
run: maturin develop --locked
ruff check src/tensorcodec av/python tests scripts benchmarks/image_codecs.py
ruff format --check src/tensorcodec av/python tests scripts benchmarks/image_codecs.py
cargo fmt --manifest-path av/Cargo.toml --check
cargo clippy --manifest-path av/Cargo.toml --locked -- -D warnings
- name: Build tensorcodec-av against prebuilt FFmpeg and install tensorcodec
run: |
maturin develop -m av/Cargo.toml --locked
pip install -e .
- name: Install pinned reference
run: python -m pip install torch==2.14.1 torchcodec==0.17.0 --index-url https://download.pytorch.org/whl/cpu
- name: Validate independent contract against reference
Expand Down
Loading
Loading