Build Windows CPU wheel #7
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 | |
| # Try to install missing dependencies that FFmpeg might need | |
| echo "Installing additional dependencies that might be missing..." | |
| conda install -y harfbuzz freetype zlib bzip2 -c conda-forge --quiet || echo "Some dependencies might already be installed" | |
| # 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 | |
| echo "pkg-config --libs libswresample:" | |
| pkg-config --libs libswresample || true | |
| 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: Setup Visual Studio environment | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - 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..." | |
| # Verify that torch is available | |
| python -c "import torch; print('PyTorch found:', torch.__version__)" | |
| # Set up environment variables for the build | |
| conda_env_path=$(conda info --base)/envs/build | |
| library_lib_path="$conda_env_path/Library/lib" | |
| library_bin_path="$conda_env_path/Library/bin" | |
| library_include_path="$conda_env_path/Library/include" | |
| # Set CMAKE_ARGS with proper library paths | |
| export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_LIBRARY_PATH=$library_lib_path -DCMAKE_INCLUDE_PATH=$library_include_path -DCMAKE_PREFIX_PATH=$library_lib_path;$library_include_path -DCMAKE_VERBOSE_MAKEFILE=ON" | |
| echo "CMAKE_ARGS: $CMAKE_ARGS" | |
| echo "Python executable: $(which python)" | |
| echo "Conda environment: $CONDA_PREFIX" | |
| # Debug: Show what libraries are available | |
| echo "Available .lib files in conda lib directory:" | |
| ls -la "$library_lib_path"/*.lib 2>/dev/null || echo "No .lib files found" | |
| # Debug: Test that torch is still available | |
| echo "Testing PyTorch availability:" | |
| python -c "import torch; print('PyTorch version:', torch.__version__)" | |
| # Build using pip install with the current conda environment | |
| 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 |