From 8c27c735704ef8d839e48fef3ad4556a7766a341 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 27 Aug 2025 02:56:14 +0300 Subject: [PATCH] Dynamically include FFmpeg binaries in setup script Refactored setup-ffmpeg.py to dynamically check for the existence of FFmpeg binaries before including them in the build. This improves robustness by warning if any binaries are missing and avoids hardcoding file paths in the include_files list. --- build/windows/setup-ffmpeg.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/build/windows/setup-ffmpeg.py b/build/windows/setup-ffmpeg.py index 23e0b07..137566c 100644 --- a/build/windows/setup-ffmpeg.py +++ b/build/windows/setup-ffmpeg.py @@ -11,6 +11,24 @@ import os # Get FFmpeg path from environment variable or use default FFMPEG_PATH = os.environ.get('FFMPEG_PATH', r'C:\Users\atela\AppData\Local\ffmpeg\ffmpeg-7.1.1-full_build\bin') +# Prepare include files list +include_files = [ + ("src/", "src/"), # Include entire src directory + ("assets/Icon/icon.png", "assets/Icon/icon.png"), + ("assets/sound/notification.mp3", "assets/sound/notification.mp3"), + ("assets/branding/icons/YTSage.ico", "YTSage.ico"), +] + +# Add FFmpeg binaries if they exist +ffmpeg_binaries = ["ffmpeg.exe", "ffprobe.exe", "ffplay.exe"] +for binary in ffmpeg_binaries: + ffmpeg_file = os.path.join(FFMPEG_PATH, binary) + if os.path.exists(ffmpeg_file): + include_files.append((ffmpeg_file, binary)) + print(f"Including FFmpeg binary: {binary}") + else: + print(f"Warning: FFmpeg binary not found: {ffmpeg_file}") + # Build options for executable build_exe_options = { # Let cx_Freeze auto-discover packages from main.py instead of explicit listing @@ -57,16 +75,7 @@ build_exe_options = { ], # Include files (assets + FFmpeg binaries + source code) - "include_files": [ - ("src/", "src/"), # Include entire src directory - ("assets/Icon/icon.png", "assets/Icon/icon.png"), - ("assets/sound/notification.mp3", "assets/sound/notification.mp3"), - ("assets/branding/icons/YTSage.ico", "YTSage.ico"), - # FFmpeg binaries - (os.path.join(FFMPEG_PATH, "ffmpeg.exe"), "ffmpeg.exe"), - (os.path.join(FFMPEG_PATH, "ffprobe.exe"), "ffprobe.exe"), - (os.path.join(FFMPEG_PATH, "ffplay.exe"), "ffplay.exe"), - ], + "include_files": include_files, # Zip includes (can help reduce file count) "zip_include_packages": "*",