|
| 1 | +@echo off |
| 2 | +setlocal |
| 3 | + |
| 4 | +REM ============================== |
| 5 | +REM ComfyUI Desktop Build Script |
| 6 | +REM ============================== |
| 7 | + |
| 8 | +REM Use environment variables if set, otherwise use defaults |
| 9 | +if not defined TORCH_VERSION set TORCH_VERSION=2.7 |
| 10 | +if not defined NUNCHAKU_VERSION set NUNCHAKU_VERSION=1.0.0 |
| 11 | + |
| 12 | +echo Using TORCH_VERSION=%TORCH_VERSION% |
| 13 | +echo Using NUNCHAKU_VERSION=%NUNCHAKU_VERSION% |
| 14 | + |
| 15 | +REM Set version-specific defaults, which is the desktop Python version |
| 16 | +set PYTHON_VERSION=3.12 |
| 17 | +REM Node.js version must be complete version string instead of 20 or 20.19 |
| 18 | +set NODE_VERSION=20.18.0 |
| 19 | +set YARN_VERSION=4.5.0 |
| 20 | +set CUDA_PIP_INDEX=cu128 |
| 21 | + |
| 22 | +REM Set torchaudio and torchvision versions based on TORCH_VERSION |
| 23 | +if "%TORCH_VERSION%"=="2.7" ( |
| 24 | + set TORCHAUDIO_VERSION=2.7 |
| 25 | + set TORCHVISION_VERSION=0.22 |
| 26 | +) else if "%TORCH_VERSION%"=="2.8" ( |
| 27 | + set TORCHAUDIO_VERSION=2.8 |
| 28 | + set TORCHVISION_VERSION=0.23 |
| 29 | +) else if "%TORCH_VERSION%"=="2.9" ( |
| 30 | + set TORCHAUDIO_VERSION=2.9 |
| 31 | + set TORCHVISION_VERSION=0.24 |
| 32 | +) else ( |
| 33 | + echo Warning: Unknown TORCH_VERSION=%TORCH_VERSION%, using default versions |
| 34 | + set TORCHAUDIO_VERSION=%TORCH_VERSION% |
| 35 | + set TORCHVISION_VERSION=0.22 |
| 36 | +) |
| 37 | + |
| 38 | +set PYTHON_VERSION_STR=%PYTHON_VERSION:.=% |
| 39 | + |
| 40 | +REM 1. Install uv package |
| 41 | +echo Installing uv package... |
| 42 | +python -m pip install --upgrade pip || ( |
| 43 | + echo ERROR: Failed to upgrade pip |
| 44 | + exit /b 1 |
| 45 | +) |
| 46 | +python -m pip install uv || ( |
| 47 | + echo ERROR: Failed to install uv |
| 48 | + exit /b 1 |
| 49 | +) |
| 50 | + |
| 51 | +REM 2. Clone ComfyUI desktop repo |
| 52 | +echo Cloning ComfyUI Desktop... |
| 53 | +git clone https://github.com/nunchaku-tech/desktop.git || ( |
| 54 | + echo ERROR: Failed to clone desktop repository |
| 55 | + exit /b 1 |
| 56 | +) |
| 57 | +cd desktop || ( |
| 58 | + echo ERROR: Failed to enter desktop directory |
| 59 | + exit /b 1 |
| 60 | +) |
| 61 | +git checkout ComfyUI-nunchaku-1.0.2 || ( |
| 62 | + echo ERROR: Failed to checkout dev branch |
| 63 | + exit /b 1 |
| 64 | +) |
| 65 | +git log -1 --oneline |
| 66 | + |
| 67 | +REM 3. Install Yarn using corepack |
| 68 | +echo Installing yarn... |
| 69 | +call corepack enable || ( |
| 70 | + echo ERROR: Failed to enable corepack |
| 71 | + exit /b 1 |
| 72 | +) |
| 73 | +call corepack prepare yarn@%YARN_VERSION% --activate || ( |
| 74 | + echo ERROR: Failed to prepare yarn |
| 75 | + exit /b 1 |
| 76 | +) |
| 77 | + |
| 78 | +REM 4. Install node modules and rebuild electron |
| 79 | +echo Rebuilding native modules... |
| 80 | +call yarn install || ( |
| 81 | + echo ERROR: Failed to run yarn install |
| 82 | + exit /b 1 |
| 83 | +) |
| 84 | +call npx --yes electron-rebuild || ( |
| 85 | + echo ERROR: Failed to rebuild electron |
| 86 | + exit /b 1 |
| 87 | +) |
| 88 | +call yarn make:assets || ( |
| 89 | + echo ERROR: Failed to make assets |
| 90 | + exit /b 1 |
| 91 | +) |
| 92 | + |
| 93 | +REM 5. Overwrite override.txt with torch version + custom nunchaku wheel |
| 94 | +echo Writing override.txt... |
| 95 | + |
| 96 | +xcopy /E /I /Y /H ..\ComfyUI-nunchaku assets\ComfyUI\custom_nodes\ComfyUI-nunchaku || ( |
| 97 | + echo ERROR: Failed to copy ComfyUI-nunchaku to assets |
| 98 | + exit /b 1 |
| 99 | +) |
| 100 | + |
| 101 | +set NUNCHAKU_URL=https://github.com/nunchaku-tech/nunchaku/releases/download/v%NUNCHAKU_VERSION%/nunchaku-%NUNCHAKU_VERSION%+torch%TORCH_VERSION%-cp%PYTHON_VERSION_STR%-cp%PYTHON_VERSION_STR%-win_amd64.whl |
| 102 | + |
| 103 | +( |
| 104 | +echo torch==%TORCH_VERSION%+%CUDA_PIP_INDEX% |
| 105 | +echo torchaudio==%TORCHAUDIO_VERSION%+%CUDA_PIP_INDEX% |
| 106 | +echo torchvision==%TORCHVISION_VERSION%+%CUDA_PIP_INDEX% |
| 107 | +echo nunchaku @ %NUNCHAKU_URL% |
| 108 | +) > assets\override.txt |
| 109 | +echo nunchaku >> assets\ComfyUI\requirements.txt |
| 110 | + |
| 111 | +REM 6. Build compiled requirements with uv |
| 112 | +echo Rebuilding requirements (windows_nvidia.compiled)... |
| 113 | +assets\uv\win\uv.exe pip compile assets\ComfyUI\requirements.txt ^ |
| 114 | +assets\ComfyUI\custom_nodes\ComfyUI-Manager\requirements.txt ^ |
| 115 | +assets\ComfyUI\custom_nodes\ComfyUI-nunchaku\requirements.txt ^ |
| 116 | +--emit-index-annotation --emit-index-url --index-strategy unsafe-best-match ^ |
| 117 | +-o assets\requirements\windows_nvidia.compiled ^ |
| 118 | +--override assets\override.txt ^ |
| 119 | +--index-url https://pypi.org/simple ^ |
| 120 | +--extra-index-url https://download.pytorch.org/whl/%CUDA_PIP_INDEX% || ( |
| 121 | + echo ERROR: Failed to compile requirements with uv |
| 122 | + exit /b 1 |
| 123 | +) |
| 124 | + |
| 125 | +REM 7. Build for NVIDIA users on Windows |
| 126 | +echo Building ComfyUI for NVIDIA... |
| 127 | +call yarn make:nvidia || ( |
| 128 | + echo ERROR: Failed to build ComfyUI for NVIDIA |
| 129 | + exit /b 1 |
| 130 | +) |
| 131 | + |
| 132 | +echo ======================================== |
| 133 | +echo ✅ Build process completed successfully! |
| 134 | +echo ======================================== |
| 135 | + |
| 136 | +endlocal |
0 commit comments