Skip to content

Commit 5b98275

Browse files
committed
Add build and test from source workflow
1 parent 0be6336 commit 5b98275

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Build and test Windows from source
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
tags:
11+
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
id-token: write
20+
contents: read
21+
22+
defaults:
23+
run:
24+
shell: bash -l -eo pipefail {0}
25+
26+
jobs:
27+
build-and-test:
28+
runs-on: windows-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
python-version: ['3.9']
33+
ffmpeg-version: ['4.4.4', '5.1.4', '6.1.1', '7.0.1']
34+
steps:
35+
- name: Check out repo
36+
uses: actions/checkout@v3
37+
38+
- name: Setup conda env
39+
uses: conda-incubator/setup-miniconda@v2
40+
with:
41+
auto-update-conda: true
42+
miniconda-version: "latest"
43+
activate-environment: build
44+
python-version: ${{ matrix.python-version }}
45+
46+
- name: Install FFmpeg
47+
run: |
48+
conda install "ffmpeg=${{ matrix.ffmpeg-version }}" -c conda-forge
49+
ffmpeg -version
50+
51+
# On Windows, ensure the conda Library/bin directory is in PATH
52+
# This is needed for both pkg-config to find FFmpeg and for DLL loading
53+
conda_env_path=$(conda info --base)/envs/build
54+
library_bin_path="$conda_env_path/Library/bin"
55+
echo "Adding conda Library/bin to PATH: $library_bin_path"
56+
echo "$library_bin_path" >> $GITHUB_PATH
57+
58+
# Also add Library/lib/pkgconfig to PKG_CONFIG_PATH for cmake to find FFmpeg
59+
pkg_config_path="$conda_env_path/Library/lib/pkgconfig"
60+
echo "Adding to PKG_CONFIG_PATH: $pkg_config_path"
61+
echo "PKG_CONFIG_PATH=$pkg_config_path" >> $GITHUB_ENV
62+
63+
# Verify FFmpeg DLLs are accessible
64+
echo "Checking if FFmpeg DLLs are in PATH:"
65+
where avutil.dll || echo "avutil.dll not found in PATH"
66+
where avcodec.dll || echo "avcodec.dll not found in PATH"
67+
where avformat.dll || echo "avformat.dll not found in PATH"
68+
69+
- name: Install build dependencies
70+
run: |
71+
# Install pkg-config and pybind11 which are needed for Windows builds
72+
conda install -y pkg-config pybind11 -c conda-forge
73+
74+
# Verify pkg-config can find FFmpeg
75+
echo "Testing pkg-config for FFmpeg libraries:"
76+
pkg-config --exists libavcodec && echo "libavcodec found" || echo "libavcodec NOT found"
77+
pkg-config --exists libavformat && echo "libavformat found" || echo "libavformat NOT found"
78+
pkg-config --exists libavutil && echo "libavutil found" || echo "libavutil NOT found"
79+
80+
- name: Update pip and install PyTorch
81+
run: |
82+
python -m pip install --upgrade pip
83+
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
84+
85+
- name: Build torchcodec from source
86+
run: |
87+
# Build without BUILD_AGAINST_ALL_FFMPEG_FROM_S3 to use system FFmpeg
88+
echo "Building torchcodec from source using system FFmpeg..."
89+
python -m pip install -e . --no-build-isolation -v
90+
91+
- name: Test torchcodec import
92+
run: |
93+
echo "Testing torchcodec import..."
94+
python -c "import torchcodec; print('TorchCodec import successful!')"
95+
python -c "import torchcodec; print('FFmpeg versions:', torchcodec.get_ffmpeg_library_versions())"
96+
97+
- name: Install test dependencies
98+
run: |
99+
python -m pip install numpy pytest pillow
100+
101+
- name: Run Python tests
102+
run: |
103+
pytest test -v

0 commit comments

Comments
 (0)