From 5cf38505b9eb96a3cdeac3bc4d1ed4df37143d98 Mon Sep 17 00:00:00 2001 From: Zhitao Yu Date: Tue, 3 Mar 2026 16:34:44 -0800 Subject: [PATCH 1/4] Fix Windows CI: ninja PATH and SSL certificate issues - Add Python Scripts dir to PATH in vc_env_helper.bat for ninja access - Set SSL_CERT_FILE on Windows to fix urllib certificate verification --- .github/scripts/unittest.sh | 5 +++++ packaging/windows/internal/vc_env_helper.bat | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/.github/scripts/unittest.sh b/.github/scripts/unittest.sh index 43968762a8b..eecb3afb8e2 100755 --- a/.github/scripts/unittest.sh +++ b/.github/scripts/unittest.sh @@ -7,6 +7,11 @@ set -euo pipefail # Activate conda environment eval "$($(which conda) shell.bash hook)" && conda deactivate && conda activate ci +# Fix SSL certificate verification on Windows by using certifi's CA bundle +if [[ "$(uname)" == MSYS* ]]; then + export SSL_CERT_FILE=$(python -c "import certifi; print(certifi.where())") +fi + echo '::group::Install testing utilities' # TODO: remove the <8 constraint on pytest when https://github.com/pytorch/vision/issues/8238 is closed pip install --progress-bar=off "pytest<8" pytest-mock pytest-cov expecttest!=0.2.0 requests diff --git a/packaging/windows/internal/vc_env_helper.bat b/packaging/windows/internal/vc_env_helper.bat index 1f50b1b05b5..857f13530c0 100644 --- a/packaging/windows/internal/vc_env_helper.bat +++ b/packaging/windows/internal/vc_env_helper.bat @@ -24,6 +24,10 @@ if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat set DISTUTILS_USE_SDK=1 +REM Ensure pip-installed tools (like ninja) are accessible +for /f "delims=" %%i in ('python -c "import sys; print(sys.prefix + r'\Scripts')"') do set PYTHON_SCRIPTS=%%i +if exist "%PYTHON_SCRIPTS%\ninja.exe" set PATH=%PYTHON_SCRIPTS%;%PATH% + set args=%1 shift :start From 4c0c80a0fee2b4e6fd1c3a06977879ab0cf050e8 Mon Sep 17 00:00:00 2001 From: Zhitao Yu Date: Tue, 3 Mar 2026 18:07:00 -0800 Subject: [PATCH 2/4] use conda ninja instead of pip ninja --- packaging/pre_build_script.sh | 10 +++++++++- packaging/windows/internal/vc_env_helper.bat | 4 ---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packaging/pre_build_script.sh b/packaging/pre_build_script.sh index b9046aa81c5..7f9e5c85c7c 100644 --- a/packaging/pre_build_script.sh +++ b/packaging/pre_build_script.sh @@ -38,5 +38,13 @@ else pip install "auditwheel<6.3.0" fi -pip install numpy pyyaml future ninja +pip install numpy pyyaml future pip install --upgrade setuptools==72.1.0 + +# Use conda ninja on Windows to avoid "ReadFile: The handle is invalid" errors +# with pip-installed ninja. On other platforms, pip ninja works fine. +if [[ "$OSTYPE" == "msys" ]]; then + conda install -y ninja +else + pip install ninja +fi diff --git a/packaging/windows/internal/vc_env_helper.bat b/packaging/windows/internal/vc_env_helper.bat index 857f13530c0..1f50b1b05b5 100644 --- a/packaging/windows/internal/vc_env_helper.bat +++ b/packaging/windows/internal/vc_env_helper.bat @@ -24,10 +24,6 @@ if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat set DISTUTILS_USE_SDK=1 -REM Ensure pip-installed tools (like ninja) are accessible -for /f "delims=" %%i in ('python -c "import sys; print(sys.prefix + r'\Scripts')"') do set PYTHON_SCRIPTS=%%i -if exist "%PYTHON_SCRIPTS%\ninja.exe" set PATH=%PYTHON_SCRIPTS%;%PATH% - set args=%1 shift :start From 9348745b9bfaaaf2ad8c2786d5f91b53d404664c Mon Sep 17 00:00:00 2001 From: Zhitao Yu Date: Tue, 3 Mar 2026 20:40:15 -0800 Subject: [PATCH 3/4] Fix Windows ninja crash by limiting parallel jobs --- packaging/windows/internal/vc_env_helper.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/windows/internal/vc_env_helper.bat b/packaging/windows/internal/vc_env_helper.bat index 1f50b1b05b5..ca4a14e5d4a 100644 --- a/packaging/windows/internal/vc_env_helper.bat +++ b/packaging/windows/internal/vc_env_helper.bat @@ -24,6 +24,8 @@ if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat set DISTUTILS_USE_SDK=1 +set MAX_JOBS=4 + set args=%1 shift :start From 4739fef8988ef21ce2a83df37951a221fbdf42aa Mon Sep 17 00:00:00 2001 From: Zhitao Yu Date: Tue, 3 Mar 2026 23:22:59 -0800 Subject: [PATCH 4/4] Reduce MAX_JOBS from 4 to 1 to fix ninja crash --- packaging/windows/internal/vc_env_helper.bat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packaging/windows/internal/vc_env_helper.bat b/packaging/windows/internal/vc_env_helper.bat index ca4a14e5d4a..09e8ebe7be8 100644 --- a/packaging/windows/internal/vc_env_helper.bat +++ b/packaging/windows/internal/vc_env_helper.bat @@ -24,7 +24,9 @@ if "%CU_VERSION%" == "xpu" call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat set DISTUTILS_USE_SDK=1 -set MAX_JOBS=4 +REM Limit parallel jobs to avoid ninja "ReadFile: The handle is invalid" errors +REM See: https://github.com/pytorch/pytorch/issues/22450 +set MAX_JOBS=1 set args=%1 shift