Build Windows CPU wheel #21
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 wheel | |
| 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: write | |
| defaults: | |
| run: | |
| shell: bash -l -eo pipefail {0} | |
| jobs: | |
| generate-matrix: | |
| uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main | |
| with: | |
| package-type: wheel | |
| os: windows | |
| test-infra-repository: pytorch/test-infra | |
| test-infra-ref: main | |
| with-xpu: disable | |
| with-rocm: disable | |
| with-cuda: disable | |
| build-python-only: "disable" | |
| build: | |
| needs: generate-matrix | |
| strategy: | |
| fail-fast: false | |
| name: Build and Upload Windows wheel | |
| # TODO | |
| # We shouldn't use this, but this is needed for now. Note that this is where we are setting the BUILD_AGAINST_ALL_FFMPEG_FROM_S3 variable currently, we'll have to find a way around that. | |
| uses: nicolashug/test-infra/.github/workflows/build_wheels_windows.yml@build-platform-windows | |
| with: | |
| repository: pytorch/torchcodec | |
| ref: "" | |
| test-infra-repository: nicolashug/test-infra | |
| test-infra-ref: build-platform-windows | |
| build-matrix: ${{ needs.generate-matrix.outputs.matrix }} | |
| pre-script: packaging/pre_build_script.sh | |
| # post-script: packaging/post_build_script.sh # TODO enable post-build checks? | |
| env-script: packaging/vc_env_helper.bat | |
| smoke-test-script: packaging/fake_smoke_test.py | |
| package-name: torchcodec | |
| trigger-event: ${{ github.event_name }} | |
| build-platform: "python-build-package" | |
| # build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation" | |
| # TODO see comment above | |
| build-command: "python -m build --wheel -vvv --no-isolation" | |
| install-and-test: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ['3.9'] | |
| ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1'] | |
| needs: build | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_x64 | |
| path: pytorch/torchcodec/dist/ | |
| - name: Setup conda env | |
| uses: conda-incubator/setup-miniconda@v2 | |
| with: | |
| auto-update-conda: true | |
| miniconda-version: "latest" | |
| activate-environment: test | |
| python-version: ${{ matrix.python-version }} | |
| - name: Update pip | |
| run: python -m pip install --upgrade pip | |
| - name: Install PyTorch | |
| run: | | |
| python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu | |
| - name: Install torchcodec from the wheel | |
| run: | | |
| wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"` | |
| echo Installing $wheel_path | |
| python -m pip install $wheel_path -vvv | |
| - name: Check out repo | |
| uses: actions/checkout@v3 | |
| - name: Install ffmpeg, post build | |
| run: | | |
| # Ideally we would have checked for that before installing the wheel, | |
| # but we need to checkout the repo to access this file, and we don't | |
| # want to checkout the repo before installing the wheel to avoid any | |
| # side-effect. It's OK. | |
| source packaging/helpers.sh | |
| assert_ffmpeg_not_installed | |
| conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge | |
| ffmpeg -version | |
| # On Windows, ensure the conda Library/bin directory is in PATH | |
| # This is needed for Windows DLL loading to find FFmpeg DLLs | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| conda_env_path=$(conda info --base)/envs/test | |
| library_bin_path="$conda_env_path/Library/bin" | |
| echo "Adding conda Library/bin to PATH: $library_bin_path" | |
| echo "$library_bin_path" >> $GITHUB_PATH | |
| # 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" | |
| fi | |
| - name: Test torchcodec import after FFmpeg installation | |
| run: | | |
| echo "Testing torchcodec import after FFmpeg is installed and PATH is updated..." | |
| python -c "import torchcodec; print('TorchCodec import successful!')" | |
| - name: Install test dependencies | |
| run: | | |
| # Ideally we would find a way to get those dependencies from pyproject.toml | |
| python -m pip install numpy pytest pillow | |
| - name: Delete the src/ folder just for fun | |
| run: | | |
| # The only reason we checked-out the repo is to get access to the | |
| # tests. We don't care about the rest. Out of precaution, we delete | |
| # the src/ folder to be extra sure that we're running the code from | |
| # the installed wheel rather than from the source. | |
| # This is just to be extra cautious and very overkill because a) | |
| # there's no way the `torchcodec` package from src/ can be found from | |
| # the PythonPath: the main point of `src/` is precisely to protect | |
| # against that and b) if we ever were to execute code from | |
| # `src/torchcodec`, it would fail loudly because the built .so files | |
| # aren't present there. | |
| rm -r src/ | |
| ls | |
| - name: Run Python tests | |
| run: | | |
| pytest test -vvv |