Skip to content

Commit 1413666

Browse files
committed
????
1 parent af7a98a commit 1413666

File tree

1 file changed

+52
-24
lines changed

1 file changed

+52
-24
lines changed

.github/workflows/windows_source_build.yaml

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ jobs:
8989
# Install pkg-config and pybind11 which are needed for Windows builds
9090
conda install -y pkg-config pybind11 -c conda-forge --quiet
9191
92+
# Try to install missing dependencies that FFmpeg might need
93+
echo "Installing additional dependencies that might be missing..."
94+
conda install -y harfbuzz freetype zlib bzip2 -c conda-forge --quiet || echo "Some dependencies might already be installed"
95+
9296
# Inspect what's actually in the Library directory
9397
echo "Contents of Library/lib:"
9498
ls -la "$CONDA_PREFIX/Library/lib/" | head -20
@@ -124,10 +128,10 @@ jobs:
124128
pkg-config --libs libavutil || true
125129
126130
echo "pkg-config --libs libswscale:"
127-
pkg-config --libs libswscale|| true
131+
pkg-config --libs libswscale || true
128132
129-
pkg-config --libs libswresample|| true
130133
echo "pkg-config --libs libswresample:"
134+
pkg-config --libs libswresample || true
131135
132136
echo "pkg-config --libs libavfilter:"
133137
pkg-config --libs libavfilter || true
@@ -140,35 +144,59 @@ jobs:
140144
python -m pip install --upgrade pip
141145
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
142146
143-
- name: Build torchcodec from source
147+
- name: Create Windows build script
144148
run: |
145-
# Build without BUILD_AGAINST_ALL_FFMPEG_FROM_S3 to use system FFmpeg
146-
echo "Building torchcodec from source using system FFmpeg..."
149+
# Create a build script that sets up the VS environment and runs the build
150+
cat > build_with_vs.bat << 'EOF'
151+
@echo off
147152
148-
# On Windows, try to work around the dependency linking issues
149-
# by setting CMAKE_ARGS to use dynamic linking where possible
150-
conda_env_path=$(conda info --base)/envs/build
151-
library_lib_path="$conda_env_path/Library/lib"
153+
:: Get conda environment info
154+
for /f "tokens=*" %%i in ('conda info --base') do set CONDA_BASE=%%i
155+
set CONDA_ENV_PATH=%CONDA_BASE%\envs\build
156+
set LIBRARY_LIB_PATH=%CONDA_ENV_PATH%\Library\lib
157+
set LIBRARY_BIN_PATH=%CONDA_ENV_PATH%\Library\bin
158+
set LIBRARY_INCLUDE_PATH=%CONDA_ENV_PATH%\Library\include
152159
153-
export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DTORCHCODEC_DISABLE_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_LIBRARY_PATH=$library_lib_path"
160+
:: Add conda Library/bin to PATH for DLL loading
161+
set PATH=%LIBRARY_BIN_PATH%;%PATH%
154162
155-
echo "CMAKE_ARGS: $CMAKE_ARGS"
163+
:: Set PKG_CONFIG_PATH
164+
set PKG_CONFIG_PATH=%CONDA_ENV_PATH%\Library\lib\pkgconfig
156165
157-
# Try to create symlinks for missing .lib files if the DLLs exist
158-
conda_env_path=$(conda info --base)/envs/build
159-
library_lib_path="$conda_env_path/Library/lib"
160-
library_bin_path="$conda_env_path/Library/bin"
166+
:: Set additional paths for the linker
167+
set LIB=%LIBRARY_LIB_PATH%;%LIB%
168+
set LIBPATH=%LIBRARY_LIB_PATH%;%LIBPATH%
169+
set INCLUDE=%LIBRARY_INCLUDE_PATH%;%INCLUDE%
161170
162-
# Check if we can create import libraries from DLLs for missing dependencies
163-
if [ ! -f "$library_lib_path/harfbuzz.lib" ] && [ -f "$library_bin_path/harfbuzz.dll" ]; then
164-
echo "Attempting to create harfbuzz.lib from harfbuzz.dll"
165-
# This is a workaround - we'll try to use lib.exe to create an import library
166-
# lib.exe /def:harfbuzz.def /out:harfbuzz.lib /machine:x64
167-
# But this requires a .def file which we don't have
168-
echo "harfbuzz.lib missing but harfbuzz.dll exists"
169-
fi
171+
:: Set CMAKE_ARGS with more comprehensive settings
172+
set 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
173+
174+
echo Building with CMAKE_ARGS: %CMAKE_ARGS%
175+
echo LIB path: %LIB%
176+
echo PKG_CONFIG_PATH: %PKG_CONFIG_PATH%
177+
echo PATH (first few entries):
178+
echo %PATH% | cut -d; -f1-3
179+
180+
:: Debug: Show what libraries are available
181+
echo Available .lib files in conda lib directory:
182+
dir "%LIBRARY_LIB_PATH%\*.lib" 2>nul || echo No .lib files found
183+
184+
:: Debug: Test pkg-config within the script
185+
echo Testing pkg-config from within build script:
186+
pkg-config --exists libavcodec && echo libavcodec found || echo libavcodec NOT found
187+
188+
:: Use vc_env_helper.bat to set up VS environment and build
189+
call packaging\vc_env_helper.bat python -m pip install -e . --no-build-isolation -v
190+
EOF
191+
192+
- name: Verify Visual Studio environment and build
193+
shell: cmd
194+
run: |
195+
echo Checking Visual Studio installation...
196+
call packaging\vc_env_helper.bat echo Visual Studio environment setup complete
170197
171-
python -m pip install -e . --no-build-isolation -v
198+
echo Running build with Visual Studio environment...
199+
call build_with_vs.bat
172200
173201
- name: Test torchcodec import
174202
run: |

0 commit comments

Comments
 (0)