From 0f93e63be4b5d32e57a077e4dcf214dc1151a59b Mon Sep 17 00:00:00 2001 From: John-Caldwell <98851904+John-Caldwell@users.noreply.github.com> Date: Mon, 10 Nov 2025 10:27:52 -0600 Subject: [PATCH] Add enhanced batch file with optional dependency checking Enhanced run_comfyui.bat with: - Automatic detection of missing critical dependencies - Virtual environment detection and warnings - Optional user-prompted installation with clear warnings - Comprehensive dependency checking for all essential packages NOTE: Author is not a professional coder and relied heavily on Cursor AI for implementation. Please review code thoroughly before merging. --- create_shortcut.ps1 | 10 +++++ run_comfyui.bat | 101 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 create_shortcut.ps1 create mode 100644 run_comfyui.bat diff --git a/create_shortcut.ps1 b/create_shortcut.ps1 new file mode 100644 index 000000000..6374ea5e5 --- /dev/null +++ b/create_shortcut.ps1 @@ -0,0 +1,10 @@ +$WshShell = New-Object -ComObject WScript.Shell +$DesktopPath = [Environment]::GetFolderPath('Desktop') +$ShortcutPath = Join-Path $DesktopPath "ComfyUI.lnk" +$Shortcut = $WshShell.CreateShortcut($ShortcutPath) +$Shortcut.TargetPath = "C:\Repos\ComfyUI\run_comfyui.bat" +$Shortcut.WorkingDirectory = "C:\Repos\ComfyUI" +$Shortcut.Description = "Run ComfyUI from repository" +$Shortcut.Save() +Write-Host "Shortcut created at: $ShortcutPath" + diff --git a/run_comfyui.bat b/run_comfyui.bat new file mode 100644 index 000000000..d5ff83e7f --- /dev/null +++ b/run_comfyui.bat @@ -0,0 +1,101 @@ +@echo off +cd /d "%~dp0" + +REM Check Python availability +python --version >nul 2>&1 +if errorlevel 1 ( + echo ERROR: Python is not found in PATH. + echo Please ensure Python is installed and added to your PATH. + pause + exit /b 1 +) + +REM Get Python environment information +python -c "import sys, os; venv = os.environ.get('VIRTUAL_ENV', ''); is_venv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix); env_type = 'VENV_DETECTED' if (venv or is_venv) else 'SYSTEM_PYTHON'; print(env_type); print('PYTHON_PATH=' + sys.executable)" > env_info.tmp +for /f "tokens=1,* delims==" %%a in (env_info.tmp) do ( + if "%%a"=="VENV_DETECTED" set ENV_TYPE=VENV_DETECTED + if "%%a"=="SYSTEM_PYTHON" set ENV_TYPE=SYSTEM_PYTHON + if "%%a"=="PYTHON_PATH" set PYTHON_PATH=%%b +) +del env_info.tmp + +REM Check for missing critical dependencies +python -c "import importlib.util; missing = []; deps = {'yaml': 'yaml', 'torch': 'torch', 'torchvision': 'torchvision', 'torchaudio': 'torchaudio', 'numpy': 'numpy', 'einops': 'einops', 'transformers': 'transformers', 'tokenizers': 'tokenizers', 'sentencepiece': 'sentencepiece', 'safetensors': 'safetensors', 'aiohttp': 'aiohttp', 'yarl': 'yarl', 'PIL': 'Pillow', 'scipy': 'scipy', 'tqdm': 'tqdm', 'psutil': 'psutil', 'alembic': 'alembic', 'sqlalchemy': 'sqlalchemy', 'av': 'av', 'comfyui_frontend': 'comfyui_frontend', 'comfyui_workflow_templates': 'comfyui_workflow_templates', 'comfyui_embedded_docs': 'comfyui_embedded_docs'}; [missing.append(k) for k, v in deps.items() if not importlib.util.find_spec(v)]; print(','.join(missing) if missing else 'ALL_OK')" > deps_check.tmp +set /p MISSING_DEPS=