Build Windows CPU wheel #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and test Windows from source | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - nightly | |
| - main | |
| - release/* | |
| tags: | |
| - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} | |
| cancel-in-progress: true | |
| permissions: | |
| id-token: write | |
| contents: read | |
| defaults: | |
| run: | |
| shell: bash -l -eo pipefail {0} | |
| jobs: | |
| build-and-test: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.9'] | |
| ffmpeg-version: ['4.4.2', '5.1.2', '6.1.1', '7.0.1'] | |
| steps: | |
| - name: Check out repo | |
| uses: actions/checkout@v3 | |
| - name: Setup conda env | |
| uses: conda-incubator/setup-miniconda@v2 | |
| with: | |
| auto-update-conda: true | |
| miniconda-version: "latest" | |
| activate-environment: build | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install FFmpeg | |
| run: | | |
| # Install FFmpeg and try to get development packages | |
| conda install "ffmpeg=${{ matrix.ffmpeg-version }}" -c conda-forge --quiet | |
| ffmpeg -version | |
| # On Windows, ensure the conda Library/bin directory is in PATH | |
| # This is needed for both pkg-config to find FFmpeg and for DLL loading | |
| conda_env_path=$(conda info --base)/envs/build | |
| library_bin_path="$conda_env_path/Library/bin" | |
| library_lib_path="$conda_env_path/Library/lib" | |
| library_include_path="$conda_env_path/Library/include" | |
| echo "Adding conda Library paths:" | |
| echo " bin: $library_bin_path" | |
| echo " lib: $library_lib_path" | |
| echo " include: $library_include_path" | |
| echo "$library_bin_path" >> $GITHUB_PATH | |
| # Also add Library/lib/pkgconfig to PKG_CONFIG_PATH for cmake to find FFmpeg | |
| pkg_config_path="$conda_env_path/Library/lib/pkgconfig" | |
| echo "Adding to PKG_CONFIG_PATH: $pkg_config_path" | |
| echo "PKG_CONFIG_PATH=$pkg_config_path" >> $GITHUB_ENV | |
| # Set additional environment variables that CMake might need | |
| echo "CMAKE_PREFIX_PATH=$conda_env_path/Library" >> $GITHUB_ENV | |
| echo "LIBRARY_PATH=$library_lib_path" >> $GITHUB_ENV | |
| echo "INCLUDE_PATH=$library_include_path" >> $GITHUB_ENV | |
| # Add the Library/lib directory to the linker path for Visual Studio | |
| echo "LIB=$library_lib_path;$LIB" >> $GITHUB_ENV | |
| echo "LIBPATH=$library_lib_path;$LIBPATH" >> $GITHUB_ENV | |
| # Verify FFmpeg DLLs are accessible | |
| echo "Checking if FFmpeg DLLs are in PATH:" | |
| where avutil.dll || echo "avutil.dll not found in PATH" | |
| where avcodec.dll || echo "avcodec.dll not found in PATH" | |
| where avformat.dll || echo "avformat.dll not found in PATH" | |
| - name: Install build dependencies | |
| run: | | |
| # Install pkg-config and pybind11 which are needed for Windows builds | |
| conda install -y pkg-config pybind11 -c conda-forge --quiet | |
| # Inspect what's actually in the Library directory | |
| echo "Contents of Library/lib:" | |
| ls -la "$CONDA_PREFIX/Library/lib/" | head -20 | |
| echo "Looking for harfbuzz files:" | |
| find "$CONDA_PREFIX/Library/" -name "*harfbuzz*" 2>/dev/null || echo "No harfbuzz files found" | |
| echo "Looking for freetype files:" | |
| find "$CONDA_PREFIX/Library/" -name "*freetype*" 2>/dev/null || echo "No freetype files found" | |
| # Check if the .lib files exist with the exact names pkg-config expects | |
| conda_env_path=$(conda info --base)/envs/build | |
| library_lib_path="$conda_env_path/Library/lib" | |
| echo "Checking for specific .lib files in $library_lib_path:" | |
| ls -la "$library_lib_path/harfbuzz.lib" 2>/dev/null || echo "harfbuzz.lib not found" | |
| ls -la "$library_lib_path/freetype.lib" 2>/dev/null || echo "freetype.lib not found" | |
| ls -la "$library_lib_path/"*harfbuzz* 2>/dev/null || echo "No harfbuzz files in lib" | |
| ls -la "$library_lib_path/"*freetype* 2>/dev/null || echo "No freetype files in lib" | |
| # Verify pkg-config can find FFmpeg | |
| echo "Testing pkg-config for FFmpeg libraries:" | |
| pkg-config --exists libavcodec && echo "libavcodec found" || echo "libavcodec NOT found" | |
| pkg-config --exists libavformat && echo "libavformat found" || echo "libavformat NOT found" | |
| pkg-config --exists libavutil && echo "libavutil found" || echo "libavutil NOT found" | |
| # Show what libraries pkg-config thinks we need | |
| echo "pkg-config --libs libavcodec:" | |
| pkg-config --libs libavcodec || true | |
| echo "pkg-config --libs libavformat:" | |
| pkg-config --libs libavformat || true | |
| echo "pkg-config --libs libavutil:" | |
| pkg-config --libs libavutil || true | |
| echo "pkg-config --libs libswscale:" | |
| pkg-config --libs libswscale|| true | |
| pkg-config --libs libswresample|| true | |
| echo "pkg-config --libs libswresample:" | |
| echo "pkg-config --libs libavfilter:" | |
| pkg-config --libs libavfilter || true | |
| echo "pkg-config --libs libavdevice:" | |
| pkg-config --libs libavdevice || true | |
| - name: Update pip and install PyTorch | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu | |
| - name: Build torchcodec from source | |
| run: | | |
| # Build without BUILD_AGAINST_ALL_FFMPEG_FROM_S3 to use system FFmpeg | |
| echo "Building torchcodec from source using system FFmpeg..." | |
| # On Windows, try to work around the dependency linking issues | |
| # by setting CMAKE_ARGS to use dynamic linking where possible | |
| export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR=ON" | |
| # Try to create symlinks for missing .lib files if the DLLs exist | |
| conda_env_path=$(conda info --base)/envs/build | |
| library_lib_path="$conda_env_path/Library/lib" | |
| library_bin_path="$conda_env_path/Library/bin" | |
| # Check if we can create import libraries from DLLs for missing dependencies | |
| if [ ! -f "$library_lib_path/harfbuzz.lib" ] && [ -f "$library_bin_path/harfbuzz.dll" ]; then | |
| echo "Attempting to create harfbuzz.lib from harfbuzz.dll" | |
| # This is a workaround - we'll try to use lib.exe to create an import library | |
| # lib.exe /def:harfbuzz.def /out:harfbuzz.lib /machine:x64 | |
| # But this requires a .def file which we don't have | |
| echo "harfbuzz.lib missing but harfbuzz.dll exists" | |
| fi | |
| python -m pip install -e . --no-build-isolation -v | |
| - name: Test torchcodec import | |
| run: | | |
| echo "Testing torchcodec import..." | |
| python -c "import torchcodec; print('TorchCodec import successful!')" | |
| python -c "import torchcodec; print('FFmpeg versions:', torchcodec.get_ffmpeg_library_versions())" | |
| - name: Install test dependencies | |
| run: | | |
| python -m pip install numpy pytest pillow | |
| - name: Run Python tests | |
| run: | | |
| pytest test -v |