Upload Install-ComfyUI.ps1
Browse files- scripts/ComfyUI/Install-ComfyUI.ps1 +138 -255
scripts/ComfyUI/Install-ComfyUI.ps1
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
#Requires -RunAsAdministrator
|
2 |
|
3 |
-
# ---
|
4 |
param(
|
5 |
# Définit le chemin d'installation.
|
6 |
# Si le script est lancé sans cet argument, il utilisera son propre dossier par défaut.
|
@@ -9,39 +9,42 @@ param(
|
|
9 |
|
10 |
<#
|
11 |
.SYNOPSIS
|
12 |
-
A
|
13 |
.DESCRIPTION
|
14 |
-
This script
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
.NOTES
|
17 |
-
Author: Code Partner
|
18 |
-
Version:
|
19 |
#>
|
20 |
|
21 |
#===========================================================================
|
22 |
# SECTION 1: SCRIPT CONFIGURATION & HELPER FUNCTIONS
|
23 |
#===========================================================================
|
24 |
-
|
|
|
25 |
$InstallPath = $InstallPath.Trim('"')
|
26 |
-
# --- Force TLS 1.2 for all web requests ---
|
27 |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
28 |
|
29 |
-
#
|
30 |
-
|
31 |
-
$
|
32 |
-
$comfyPath = Join-Path $basePath "ComfyUI"
|
33 |
-
$pythonExecutable = Join-Path $basePath "python_embeded\python.exe"
|
34 |
-
$customNodesPath = Join-Path $comfyPath "custom_nodes"
|
35 |
-
$logPath = Join-Path $InstallPath "scripts\logs"
|
36 |
$logFile = Join-Path $logPath "install_log.txt"
|
37 |
-
$sevenZipPath = "C:\Program Files\7-Zip\7z.exe"
|
|
|
|
|
|
|
38 |
|
39 |
# --- Create Log Directory ---
|
40 |
if (-not (Test-Path $logPath)) {
|
41 |
New-Item -ItemType Directory -Force -Path $logPath | Out-Null
|
42 |
}
|
43 |
|
44 |
-
# --- Helper
|
45 |
function Write-Log {
|
46 |
param([string]$Message, [string]$Color = "White")
|
47 |
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
@@ -50,18 +53,10 @@ function Write-Log {
|
|
50 |
Add-Content -Path $logFile -Value $formattedMessage
|
51 |
}
|
52 |
|
53 |
-
# --- Helper function to execute a command and log its output (VERSION-COMPATIBLE) ---
|
54 |
function Invoke-AndLog {
|
55 |
-
param(
|
56 |
-
[string]$File,
|
57 |
-
[string]$Arguments
|
58 |
-
)
|
59 |
-
# This method is compatible with all PowerShell versions, including 5.1.
|
60 |
-
# It uses cmd.exe to run the command and handle output redirection.
|
61 |
-
# The structure is: cmd /c "full command >> "path/to/log.txt" 2>&1"
|
62 |
$commandToRun = "`"$File`" $Arguments"
|
63 |
$cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
|
64 |
-
|
65 |
try {
|
66 |
Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
|
67 |
} catch {
|
@@ -69,30 +64,40 @@ function Invoke-AndLog {
|
|
69 |
}
|
70 |
}
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
function Install-Aria2-Binary {
|
74 |
Write-Log "--- Starting Aria2 binary installation ---" -Color Magenta
|
75 |
$destFolder = "C:\Tools\aria2"
|
76 |
if (-not (Test-Path $destFolder)) { New-Item -ItemType Directory -Force -Path $destFolder | Out-Null }
|
77 |
-
|
78 |
$aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip"
|
79 |
$zipPath = Join-Path $env:TEMP "aria2_temp.zip"
|
80 |
-
|
81 |
-
Invoke-WebRequest -Uri $aria2Url -OutFile $zipPath
|
82 |
-
|
83 |
Write-Log "Extracting zip file to $destFolder..."
|
84 |
Expand-Archive -Path $zipPath -DestinationPath $destFolder -Force
|
85 |
-
|
86 |
$extractedSubfolder = Join-Path $destFolder "aria2-1.36.0-win-64bit-build1"
|
87 |
if (Test-Path $extractedSubfolder) {
|
88 |
Move-Item -Path (Join-Path $extractedSubfolder "*") -Destination $destFolder -Force
|
89 |
Remove-Item -Path $extractedSubfolder -Recurse -Force
|
90 |
}
|
91 |
-
|
92 |
$configFile = Join-Path $destFolder "aria2.conf"
|
93 |
$configContent = "continue=true`nmax-connection-per-server=16`nsplit=16`nmin-split-size=1M`nfile-allocation=none"
|
94 |
$configContent | Out-File $configFile -Encoding UTF8
|
95 |
-
|
96 |
$envScope = "User"
|
97 |
$oldPath = [System.Environment]::GetEnvironmentVariable("Path", $envScope)
|
98 |
if ($oldPath -notlike "*$destFolder*") {
|
@@ -106,33 +111,12 @@ function Install-Aria2-Binary {
|
|
106 |
}
|
107 |
|
108 |
|
109 |
-
# --- Smart Download Function with fallback ---
|
110 |
-
function Download-File {
|
111 |
-
param(
|
112 |
-
[string]$Uri,
|
113 |
-
[string]$OutFile
|
114 |
-
)
|
115 |
-
# Extrait juste le nom du fichier de l'URL pour un affichage plus propre
|
116 |
-
$fileName = Split-Path -Path $Uri -Leaf
|
117 |
-
|
118 |
-
if (Get-Command 'aria2c' -ErrorAction SilentlyContinue) {
|
119 |
-
Write-Log " - Downloading $fileName"
|
120 |
-
$aria_args = "-c -x 16 -s 16 -k 1M --dir=`"$((Split-Path $OutFile -Parent))`" --out=`"$((Split-Path $OutFile -Leaf))`" `"$Uri`""
|
121 |
-
Invoke-AndLog "aria2c" $aria_args
|
122 |
-
} else {
|
123 |
-
Write-Log "Aria2 not found. Falling back to standard download: $fileName" -Color Yellow
|
124 |
-
Invoke-WebRequest -Uri $Uri -OutFile $OutFile
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
128 |
-
|
129 |
#===========================================================================
|
130 |
# SECTION 2: MAIN SCRIPT EXECUTION
|
131 |
#===========================================================================
|
132 |
|
133 |
Clear-Host
|
134 |
-
# ---
|
135 |
-
# The ASCII art is now embedded directly in the script for simplicity and reliability.
|
136 |
Write-Log "-------------------------------------------------------------------------------"
|
137 |
$asciiBanner = @'
|
138 |
__ __ ___ _ ____ ______
|
@@ -143,93 +127,77 @@ $asciiBanner = @'
|
|
143 |
'@
|
144 |
Write-Host $asciiBanner -ForegroundColor Cyan
|
145 |
Write-Log "-------------------------------------------------------------------------------"
|
146 |
-
Write-Log "
|
147 |
-
Write-Log " Version
|
148 |
Write-Log "-------------------------------------------------------------------------------"
|
149 |
|
150 |
-
# ---
|
151 |
-
Write-Log "Step 1: Checking for
|
152 |
-
|
153 |
-
|
154 |
-
if (
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
Write-Log "
|
170 |
}
|
171 |
|
172 |
-
# Git
|
|
|
|
|
|
|
|
|
|
|
173 |
if (-not (Get-Command git.exe -ErrorAction SilentlyContinue)) {
|
174 |
-
|
175 |
-
$gitInstaller = Join-Path $env:TEMP "Git-Installer.exe"
|
176 |
-
Download-File -Uri "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe" -OutFile $gitInstaller
|
177 |
-
Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT" -Wait
|
178 |
-
Remove-Item $gitInstaller
|
179 |
}
|
180 |
Invoke-AndLog "git" "config --system core.longpaths true"
|
181 |
-
Write-Log "Git is ready." -Color Green
|
182 |
-
Write-Log "Install Visual Studio Build Tools." -Color Green
|
183 |
-
winget install --id Microsoft.VisualStudio.2022.BuildTools -e --source winget --override "--quiet --wait --norestart --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.20348"
|
184 |
-
# --- Step 2: Download and Extract ComfyUI ---
|
185 |
-
Write-Log "`nStep 2: Downloading and setting up ComfyUI..." -Color Yellow
|
186 |
-
if (-not (Test-Path $basePath)) {
|
187 |
-
$comfyArchive = Join-Path $installPath "ComfyUI_windows_portable_nvidia.7z"
|
188 |
-
Download-File -Uri "https://github.com/comfyanonymous/ComfyUI/releases/download/v0.3.43/ComfyUI_windows_portable_nvidia.7z" -OutFile $comfyArchive
|
189 |
-
Write-Log " - Extracting ComfyUI..."
|
190 |
-
Invoke-AndLog "$sevenZipPath" "x `"$comfyArchive`" -o`"$installPath`" -y"
|
191 |
-
Remove-Item $comfyArchive
|
192 |
-
} else {
|
193 |
-
Write-Log "ComfyUI folder already exists. Skipping download." -Color Green
|
194 |
-
}
|
195 |
|
196 |
-
# --- Step 3: Update ComfyUI and Install Custom Nodes ---
|
197 |
-
Write-Log "`nStep 3: Updating ComfyUI and installing custom nodes..." -Color Yellow
|
198 |
-
# Update pip and ComfyUI itself
|
199 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install --upgrade pip"
|
200 |
-
Invoke-AndLog "$pythonExecutable" "`"$basePath\update\update.py`" `"$comfyPath`""
|
201 |
-
Invoke-AndLog "$pythonExecutable" "-s -m pip install -r `"$comfyPath\requirements.txt`""
|
202 |
-
# Install special Python dependencies
|
203 |
-
Write-Log " - Installing special Python dependencies" -Color White
|
204 |
-
Invoke-AndLog "$pythonExecutable" "-s -m pip install ultralytics wheel-stub --no-warn-script-location"
|
205 |
-
$insightfaceWheel = Join-Path $basePath "python_embeded\insightface-0.7.3-cp312-cp312-win_amd64.whl"
|
206 |
-
Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/whl/insightface-0.7.3-cp312-cp312-win_amd64.whl" -OutFile $insightfaceWheel
|
207 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install --use-pep517 facexlib"
|
208 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install git+https://github.com/rodjjo/filterpy.git"
|
209 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install onnxruntime==1.19.2 onnxruntime-gpu==1.17.1"
|
210 |
-
Invoke-AndLog "$pythonExecutable" "-s -m pip install $insightfaceWheel --no-warn-script-location"
|
211 |
-
Write-Log " - Installing Python include/libs for compatibility..." -Color Cyan
|
212 |
-
$pyLibsUrl = "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/others/python_3.12.9_include_libs.zip"
|
213 |
-
$zipPath = Join-Path $installPath "python_libs.zip"
|
214 |
-
$extractPath = Join-Path $basePath "python_embeded"
|
215 |
|
216 |
-
#
|
217 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
} finally {
|
228 |
-
Remove-Item -Path $zipPath -Force
|
229 |
-
}
|
230 |
}
|
231 |
|
232 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
$customNodes = @(
|
234 |
@{Name="ComfyUI-Manager"; Repo="https://github.com/ltdrdata/ComfyUI-Manager.git"; HasRequirements=$false},
|
235 |
@{Name="ComfyUI-Impact-Pack"; Repo="https://github.com/ltdrdata/ComfyUI-Impact-Pack"; HasRequirements=$true},
|
@@ -256,161 +224,76 @@ $customNodes = @(
|
|
256 |
@{Name="ComfyUI-RMBG"; Repo="https://github.com/1038lab/ComfyUI-RMBG"; HasRequirements=$true},
|
257 |
@{Name="ComfyUI-Detail-Daemon"; Repo="https://github.com/Jonseed/ComfyUI-Detail-Daemon"; HasRequirements=$true},
|
258 |
@{Name="ComfyUI-TeaCache"; Repo="https://github.com/welltop-cn/ComfyUI-TeaCache"; HasRequirements=$true},
|
259 |
-
@{Name="ComfyUI-Crystools"; Repo="https://github.com/crystian/ComfyUI-Crystools"; HasRequirements=$true}
|
260 |
-
@{Name="ComfyUI-Upscaler-Tensorrt"; Repo="https://github.com/yuvraj108c/ComfyUI-Upscaler-Tensorrt"; HasRequirements=$true}
|
261 |
)
|
262 |
-
|
263 |
-
# Loop through and install each custom node
|
264 |
foreach ($node in $customNodes) {
|
265 |
$nodePath = if ($node.Subfolder) { Join-Path $customNodesPath $node.Subfolder } else { Join-Path $customNodesPath $node.Name }
|
266 |
-
|
267 |
if (-not (Test-Path $nodePath)) {
|
268 |
Write-Log " - Installing $($node.Name)..."
|
269 |
-
# For sub-repositories, clone into the parent directory
|
270 |
$cloneTargetPath = if ($node.Subfolder) { (Split-Path $nodePath -Parent) } else { $nodePath }
|
271 |
-
|
272 |
-
|
273 |
-
$cloneCommand = "clone $($node.Repo) `"$((Join-Path (Split-Path $cloneTargetPath -Parent) $finalDirName))`""
|
274 |
-
|
275 |
-
Invoke-AndLog "git" "clone $($node.Repo) `"$cloneTargetPath`""
|
276 |
-
|
277 |
if ($node.HasRequirements) {
|
278 |
$requirementsFile = if ($node.RequirementsFile) { $node.RequirementsFile } else { "requirements.txt" }
|
279 |
$reqPath = Join-Path $nodePath $requirementsFile
|
280 |
-
if (Test-Path $reqPath) {
|
281 |
-
Invoke-AndLog "$pythonExecutable" "-s -m pip install -r `"$reqPath`" --no-warn-script-location"
|
282 |
-
}
|
283 |
}
|
284 |
-
} else {
|
285 |
-
Write-Log " - $($node.Name) (already exists, skipping)" -Color Green
|
286 |
-
}
|
287 |
-
}
|
288 |
-
|
289 |
-
# Install supplementary performance modules
|
290 |
-
Write-Log "`nStep 4: Installing supplementary performance modules..." -Color Yellow
|
291 |
-
|
292 |
-
# Triton
|
293 |
-
Write-Log " - Installing Triton..."
|
294 |
-
$tritonWheel = Join-Path $basePath "python_embeded\triton-3.3.0-py3-none-any.whl"
|
295 |
-
Download-File -Uri "https://github.com/woct0rdho/triton-windows/releases/download/empty/triton-3.3.0-py3-none-any.whl" -OutFile $tritonWheel
|
296 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install `"$tritonWheel`""
|
297 |
-
Invoke-AndLog "$pythonExecutable" "-s -m pip install triton-windows"
|
298 |
-
|
299 |
-
# xformers
|
300 |
-
Write-Log " - Installing xformers..."
|
301 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install -U xformers --index-url https://download.pytorch.org/whl/cu128"
|
302 |
-
Write-Log " - Checking xformers files for compatibility (looking for file named 'pyd')..."
|
303 |
-
|
304 |
-
$xformersBaseDir = Join-Path $basePath "python_embeded\Lib\site-packages\xformers"
|
305 |
-
$dirsToProcess = @(
|
306 |
-
$xformersBaseDir,
|
307 |
-
(Join-Path $xformersBaseDir "flash_attn_3")
|
308 |
-
)
|
309 |
-
|
310 |
-
foreach ($dir in $dirsToProcess) {
|
311 |
-
Write-Log " - Checking directory: $dir"
|
312 |
-
if (Test-Path $dir) {
|
313 |
-
# On vérifie l'existence d'un fichier nommé EXACTEMENT "pyd"
|
314 |
-
$exactFilePath = Join-Path $dir "pyd"
|
315 |
-
if (Test-Path $exactFilePath) {
|
316 |
-
# Le fichier existe, on le renomme.
|
317 |
-
Write-Log " - Found file named 'pyd'. Renaming to '_C.pyd'..." -Color Yellow
|
318 |
-
$newName = "_C.pyd"
|
319 |
-
try {
|
320 |
-
Rename-Item -Path $exactFilePath -NewName $newName -Force -ErrorAction Stop
|
321 |
-
Write-Log " - SUCCESS: Renamed 'pyd' to '$newName'" -Color Green
|
322 |
-
} catch {
|
323 |
-
Write-Log " - FAILED to rename. Error: $($_.Exception.Message)" -Color Red
|
324 |
-
}
|
325 |
-
} else {
|
326 |
-
# Le fichier 'pyd' n'a pas été trouvé. On vérifie si '_C.pyd' existe déjà.
|
327 |
-
$finalFilePath = Join-Path $dir "_C.pyd"
|
328 |
-
if (Test-Path $finalFilePath) {
|
329 |
-
Write-Log " - File '_C.pyd' already exists. No action needed." -Color Green
|
330 |
-
} else {
|
331 |
-
Write-Log " - No file named 'pyd' or '_C.pyd' found in this directory." -Color Gray
|
332 |
-
}
|
333 |
-
}
|
334 |
-
} else {
|
335 |
-
# Le répertoire lui-même n'existe pas.
|
336 |
-
Write-Log " - Directory not found. Skipping." -Color Gray
|
337 |
-
}
|
338 |
-
}
|
339 |
-
|
340 |
-
# SageAttention
|
341 |
-
Write-Log " - Installing SageAttention..."
|
342 |
-
$sageWheel = Join-Path $basePath "python_embeded\sageattention-2.1.1+cu128torch2.7.0-cp312-cp312-win_amd64.whl"
|
343 |
-
Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/whl/sageattention-2.1.1+cu128torch2.7.0-cp312-cp312-win_amd64.whl" -OutFile $sageWheel
|
344 |
-
Invoke-AndLog "$pythonExecutable" "-m pip install `"$sageWheel`""
|
345 |
-
|
346 |
-
# --- Step 5: Download Custom Workflows ---
|
347 |
-
Write-Log "`nStep 5: Downloading UmeAiRT Workflows..." -Color Yellow
|
348 |
-
|
349 |
-
$workflowPath = Join-Path $comfyPath "user\default\workflows"
|
350 |
-
$cloneDest = Join-Path $workflowPath "UmeAiRT-Workflow"
|
351 |
-
|
352 |
-
# Create the target directory if it doesn't exist
|
353 |
-
if (-not (Test-Path $workflowPath)) {
|
354 |
-
Write-Log " - Creating workflow directory: $workflowPath"
|
355 |
-
New-Item -Path $workflowPath -ItemType Directory -Force | Out-Null
|
356 |
}
|
357 |
|
358 |
-
#
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
$
|
369 |
-
Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/others/comfy.settings.json" -OutFile $
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
381 |
$scriptsSubFolder = Join-Path $InstallPath "scripts"
|
382 |
-
|
383 |
-
# Boucle pour chaque pack de modèles
|
384 |
foreach ($pack in $modelPacks) {
|
385 |
-
# On construit le chemin complet en utilisant le dossier des scripts
|
386 |
$scriptPath = Join-Path $scriptsSubFolder $pack.ScriptName
|
387 |
-
|
388 |
-
if (-not (Test-Path $scriptPath)) {
|
389 |
-
Write-Log "Model downloader script not found: '$($pack.ScriptName)'. Skipping." -Color Red
|
390 |
-
continue # Passe au pack suivant
|
391 |
-
}
|
392 |
-
|
393 |
$validInput = $false
|
394 |
while (-not $validInput) {
|
395 |
Write-Host "`n[33mWould you like to download $($pack.Name) models? (Y/N)[0m"
|
396 |
$choice = Read-Host
|
397 |
-
|
398 |
if ($choice -eq 'Y' -or $choice -eq 'y') {
|
399 |
Write-Log " - Launching downloader for $($pack.Name) models..." -Color Green
|
400 |
-
# Exécute le script PowerShell de téléchargement
|
401 |
& $scriptPath -InstallPath $InstallPath
|
402 |
$validInput = $true
|
403 |
} elseif ($choice -eq 'N' -or $choice -eq 'n') {
|
404 |
Write-Log " - Skipping download for $($pack.Name) models." -Color Gray
|
405 |
$validInput = $true
|
406 |
-
} else {
|
407 |
-
Write-Host " [31mInvalid choice. Please enter Y or N.[0m"
|
408 |
-
}
|
409 |
}
|
410 |
}
|
411 |
|
412 |
#===========================================================================
|
413 |
-
#
|
414 |
#===========================================================================
|
415 |
Write-Log "-------------------------------------------------------------------------------" -Color Green
|
416 |
-
Write-Log "Installation of ComfyUI and all nodes is complete!" -Color Green
|
|
|
|
1 |
#Requires -RunAsAdministrator
|
2 |
|
3 |
+
# --- Paramètres du script ---
|
4 |
param(
|
5 |
# Définit le chemin d'installation.
|
6 |
# Si le script est lancé sans cet argument, il utilisera son propre dossier par défaut.
|
|
|
9 |
|
10 |
<#
|
11 |
.SYNOPSIS
|
12 |
+
A professional installer for ComfyUI using Git and a Python venv.
|
13 |
.DESCRIPTION
|
14 |
+
This script provides a clean, modern installation of ComfyUI by:
|
15 |
+
1. Checking for and installing Python 3.12 if needed.
|
16 |
+
2. Cloning the official ComfyUI repository.
|
17 |
+
3. Creating a dedicated Python virtual environment (venv).
|
18 |
+
4. Installing all dependencies into the venv.
|
19 |
+
5. Creating a launcher to run the application easily.
|
20 |
.NOTES
|
21 |
+
Author: Code Partner
|
22 |
+
Version: 7.0 (Git + Venv Architecture)
|
23 |
#>
|
24 |
|
25 |
#===========================================================================
|
26 |
# SECTION 1: SCRIPT CONFIGURATION & HELPER FUNCTIONS
|
27 |
#===========================================================================
|
28 |
+
|
29 |
+
# --- Nettoyage et configuration des chemins ---
|
30 |
$InstallPath = $InstallPath.Trim('"')
|
|
|
31 |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
32 |
|
33 |
+
# Le chemin de base est maintenant le dossier d'installation principal.
|
34 |
+
$comfyPath = Join-Path $InstallPath "ComfyUI"
|
35 |
+
$logPath = Join-Path $InstallPath "logs"
|
|
|
|
|
|
|
|
|
36 |
$logFile = Join-Path $logPath "install_log.txt"
|
37 |
+
$sevenZipPath = "C:\Program Files\7-Zip\7z.exe"
|
38 |
+
|
39 |
+
# Variable qui contiendra le chemin vers le python du venv
|
40 |
+
$venvPython = Join-Path $comfyPath "venv\Scripts\python.exe"
|
41 |
|
42 |
# --- Create Log Directory ---
|
43 |
if (-not (Test-Path $logPath)) {
|
44 |
New-Item -ItemType Directory -Force -Path $logPath | Out-Null
|
45 |
}
|
46 |
|
47 |
+
# --- Helper functions ---
|
48 |
function Write-Log {
|
49 |
param([string]$Message, [string]$Color = "White")
|
50 |
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
|
|
|
53 |
Add-Content -Path $logFile -Value $formattedMessage
|
54 |
}
|
55 |
|
|
|
56 |
function Invoke-AndLog {
|
57 |
+
param([string]$File, [string]$Arguments)
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
$commandToRun = "`"$File`" $Arguments"
|
59 |
$cmdArguments = "/C `"$commandToRun >> `"`"$logFile`"`" 2>&1`""
|
|
|
60 |
try {
|
61 |
Start-Process -FilePath "cmd.exe" -ArgumentList $cmdArguments -Wait -WindowStyle Hidden
|
62 |
} catch {
|
|
|
64 |
}
|
65 |
}
|
66 |
|
67 |
+
function Download-File {
|
68 |
+
param([string]$Uri, [string]$OutFile)
|
69 |
+
if (Test-Path $OutFile) {
|
70 |
+
Write-Log "Skipping: $((Split-Path $OutFile -Leaf)) (already exists)." -Color Gray
|
71 |
+
} else {
|
72 |
+
$fileName = Split-Path -Path $Uri -Leaf
|
73 |
+
if (Get-Command 'aria2c' -ErrorAction SilentlyContinue) {
|
74 |
+
Write-Log "Downloading: $fileName"
|
75 |
+
$aria_args = "-c -x 16 -s 16 -k 1M --dir=`"$((Split-Path $OutFile -Parent))`" --out=`"$((Split-Path $OutFile -Leaf))`" `"$Uri`""
|
76 |
+
Invoke-AndLog "aria2c" $aria_args
|
77 |
+
} else {
|
78 |
+
Write-Log "Aria2 not found. Falling back to standard download: $fileName" -Color Yellow
|
79 |
+
Invoke-WebRequest -Uri $Uri -OutFile $OutFile
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
function Install-Aria2-Binary {
|
85 |
Write-Log "--- Starting Aria2 binary installation ---" -Color Magenta
|
86 |
$destFolder = "C:\Tools\aria2"
|
87 |
if (-not (Test-Path $destFolder)) { New-Item -ItemType Directory -Force -Path $destFolder | Out-Null }
|
|
|
88 |
$aria2Url = "https://github.com/aria2/aria2/releases/download/release-1.36.0/aria2-1.36.0-win-64bit-build1.zip"
|
89 |
$zipPath = Join-Path $env:TEMP "aria2_temp.zip"
|
90 |
+
Download-File -Uri $aria2Url -OutFile $zipPath
|
|
|
|
|
91 |
Write-Log "Extracting zip file to $destFolder..."
|
92 |
Expand-Archive -Path $zipPath -DestinationPath $destFolder -Force
|
|
|
93 |
$extractedSubfolder = Join-Path $destFolder "aria2-1.36.0-win-64bit-build1"
|
94 |
if (Test-Path $extractedSubfolder) {
|
95 |
Move-Item -Path (Join-Path $extractedSubfolder "*") -Destination $destFolder -Force
|
96 |
Remove-Item -Path $extractedSubfolder -Recurse -Force
|
97 |
}
|
|
|
98 |
$configFile = Join-Path $destFolder "aria2.conf"
|
99 |
$configContent = "continue=true`nmax-connection-per-server=16`nsplit=16`nmin-split-size=1M`nfile-allocation=none"
|
100 |
$configContent | Out-File $configFile -Encoding UTF8
|
|
|
101 |
$envScope = "User"
|
102 |
$oldPath = [System.Environment]::GetEnvironmentVariable("Path", $envScope)
|
103 |
if ($oldPath -notlike "*$destFolder*") {
|
|
|
111 |
}
|
112 |
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
#===========================================================================
|
115 |
# SECTION 2: MAIN SCRIPT EXECUTION
|
116 |
#===========================================================================
|
117 |
|
118 |
Clear-Host
|
119 |
+
# --- Bannière ---
|
|
|
120 |
Write-Log "-------------------------------------------------------------------------------"
|
121 |
$asciiBanner = @'
|
122 |
__ __ ___ _ ____ ______
|
|
|
127 |
'@
|
128 |
Write-Host $asciiBanner -ForegroundColor Cyan
|
129 |
Write-Log "-------------------------------------------------------------------------------"
|
130 |
+
Write-Log " ComfyUI - Git & Venv Based Installer " -Color Yellow
|
131 |
+
Write-Log " Version 7.0 " -Color White
|
132 |
Write-Log "-------------------------------------------------------------------------------"
|
133 |
|
134 |
+
# --- Étape 1: Vérification et Installation de Python ---
|
135 |
+
Write-Log "Step 1: Checking for Python 3.12..." -Color Yellow
|
136 |
+
$pythonExe = Get-Command python -ErrorAction SilentlyContinue
|
137 |
+
$pythonVersionOK = $false
|
138 |
+
if ($pythonExe) {
|
139 |
+
# Capturer la sortie (va souvent sur le flux d'erreur)
|
140 |
+
$versionString = (python --version 2>&1)
|
141 |
+
Write-Log " - Found Python: $versionString"
|
142 |
+
if ($versionString -like "Python 3.12*") {
|
143 |
+
Write-Log " - Correct version already installed." -Color Green
|
144 |
+
$pythonVersionOK = $true
|
145 |
+
}
|
146 |
}
|
147 |
|
148 |
+
if (-not $pythonVersionOK) {
|
149 |
+
Write-Log " - Python 3.12 not found. Downloading and installing..." -Color Yellow
|
150 |
+
$pythonInstallerPath = Join-Path $env:TEMP "python-3.12-installer.exe"
|
151 |
+
Download-File -Uri "https://www.python.org/ftp/python/3.12.4/python-3.12.4-amd64.exe" -OutFile $pythonInstallerPath
|
152 |
+
Write-Log " - Running Python installer silently... (This may take a moment)"
|
153 |
+
# Installation silencieuse, pour tous les utilisateurs, et ajout au PATH
|
154 |
+
Start-Process -FilePath $pythonInstallerPath -ArgumentList "/quiet InstallAllUsers=1 PrependPath=1" -Wait
|
155 |
+
Remove-Item $pythonInstallerPath
|
156 |
+
Write-Log " - Python 3.12 installation complete." -Color Green
|
157 |
}
|
158 |
|
159 |
+
# --- Étape 2: Installation des dépendances (Aria2, 7-Zip, Git) ---
|
160 |
+
Write-Log "`nStep 2: Checking for required tools..." -Color Yellow
|
161 |
+
if (-not (Get-Command 'aria2c' -ErrorAction SilentlyContinue)) { Install-Aria2-Binary } else { Write-Log " - Aria2 is already installed." -Color Green }
|
162 |
+
if (-not (Test-Path $sevenZipPath)) {
|
163 |
+
$sevenZipInstaller = Join-Path $env:TEMP "7z-installer.exe"; Download-File -Uri "https://www.7-zip.org/a/7z2201-x64.exe" -OutFile $sevenZipInstaller; Start-Process -FilePath $sevenZipInstaller -ArgumentList "/S" -Wait; Remove-Item $sevenZipInstaller
|
164 |
+
} else { Write-Log " - 7-Zip is already installed." -Color Green }
|
165 |
if (-not (Get-Command git.exe -ErrorAction SilentlyContinue)) {
|
166 |
+
$gitInstaller = Join-Path $env:TEMP "Git-Installer.exe"; Download-File -Uri "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/Git-2.41.0.3-64-bit.exe" -OutFile $gitInstaller; Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT" -Wait; Remove-Item $gitInstaller
|
|
|
|
|
|
|
|
|
167 |
}
|
168 |
Invoke-AndLog "git" "config --system core.longpaths true"
|
169 |
+
Write-Log " - Git is ready." -Color Green
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
|
172 |
+
# --- Étape 3: Cloner ComfyUI et créer le Venv ---
|
173 |
+
Write-Log "`nStep 3: Cloning ComfyUI and creating Virtual Environment..." -Color Yellow
|
174 |
+
if (-not (Test-Path $comfyPath)) {
|
175 |
+
Write-Log " - Cloning ComfyUI repository..."
|
176 |
+
Invoke-AndLog "git" "clone https://github.com/comfyanonymous/ComfyUI.git `"$comfyPath`""
|
177 |
+
} else {
|
178 |
+
Write-Log " - ComfyUI directory already exists. Skipping clone." -Color Green
|
179 |
+
}
|
180 |
|
181 |
+
if (-not (Test-Path (Join-Path $comfyPath "venv"))) {
|
182 |
+
Write-Log " - Creating Python virtual environment (venv)..."
|
183 |
+
Push-Location $comfyPath
|
184 |
+
Invoke-AndLog "python" "-m venv venv"
|
185 |
+
Pop-Location
|
186 |
+
Write-Log " - Venv created successfully." -Color Green
|
187 |
+
} else {
|
188 |
+
Write-Log " - Venv already exists. Skipping creation." -Color Green
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
+
# --- Étape 4: Installation des dépendances dans le Venv ---
|
192 |
+
Write-Log "`nStep 4: Installing all Python dependencies into the venv..." -Color Yellow
|
193 |
+
Invoke-AndLog "$venvPython" "-m pip install --upgrade pip wheel"
|
194 |
+
Invoke-AndLog "$venvPython" "-m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121"
|
195 |
+
Invoke-AndLog "$venvPython" "-m pip install -r `"$comfyPath\requirements.txt`""
|
196 |
+
|
197 |
+
# --- Étape 5: Installation des Custom Nodes ---
|
198 |
+
Write-Log "`nStep 5: Installing custom nodes..." -Color Yellow
|
199 |
+
$customNodesPath = Join-Path $comfyPath "custom_nodes" # Définit le chemin pour les noeuds
|
200 |
+
# ... (La liste des noeuds est inchangée)
|
201 |
$customNodes = @(
|
202 |
@{Name="ComfyUI-Manager"; Repo="https://github.com/ltdrdata/ComfyUI-Manager.git"; HasRequirements=$false},
|
203 |
@{Name="ComfyUI-Impact-Pack"; Repo="https://github.com/ltdrdata/ComfyUI-Impact-Pack"; HasRequirements=$true},
|
|
|
224 |
@{Name="ComfyUI-RMBG"; Repo="https://github.com/1038lab/ComfyUI-RMBG"; HasRequirements=$true},
|
225 |
@{Name="ComfyUI-Detail-Daemon"; Repo="https://github.com/Jonseed/ComfyUI-Detail-Daemon"; HasRequirements=$true},
|
226 |
@{Name="ComfyUI-TeaCache"; Repo="https://github.com/welltop-cn/ComfyUI-TeaCache"; HasRequirements=$true},
|
227 |
+
@{Name="ComfyUI-Crystools"; Repo="https://github.com/crystian/ComfyUI-Crystools"; HasRequirements=$true}
|
|
|
228 |
)
|
|
|
|
|
229 |
foreach ($node in $customNodes) {
|
230 |
$nodePath = if ($node.Subfolder) { Join-Path $customNodesPath $node.Subfolder } else { Join-Path $customNodesPath $node.Name }
|
|
|
231 |
if (-not (Test-Path $nodePath)) {
|
232 |
Write-Log " - Installing $($node.Name)..."
|
|
|
233 |
$cloneTargetPath = if ($node.Subfolder) { (Split-Path $nodePath -Parent) } else { $nodePath }
|
234 |
+
if ($node.Name -eq 'ComfyUI-Impact-Subpack') { $clonePath = Join-Path $cloneTargetPath "impact_subpack" } else { $clonePath = $cloneTargetPath }
|
235 |
+
Invoke-AndLog "git" "clone $($node.Repo) `"$clonePath`""
|
|
|
|
|
|
|
|
|
236 |
if ($node.HasRequirements) {
|
237 |
$requirementsFile = if ($node.RequirementsFile) { $node.RequirementsFile } else { "requirements.txt" }
|
238 |
$reqPath = Join-Path $nodePath $requirementsFile
|
239 |
+
if (Test-Path $reqPath) { Invoke-AndLog "$venvPython" "-m pip install -r `"$reqPath`"" }
|
|
|
|
|
240 |
}
|
241 |
+
} else { Write-Log " - $($node.Name) (already exists, skipping)" -Color Green }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
|
244 |
+
# --- Étape 6: Installation des modules Python supplémentaires ---
|
245 |
+
Write-Log "`nStep 6: Installing supplementary Python modules..." -Color Yellow
|
246 |
+
Invoke-AndLog "$venvPython" "-m pip install -U xformers --index-url https://download.pytorch.org/whl/cu121"
|
247 |
+
# ... (Ajoutez ici l'installation de Triton, SageAttention etc. si nécessaire, en utilisant $venvPython) ...
|
248 |
+
|
249 |
+
# --- Étape 7: Téléchargement des Workflows et Settings ---
|
250 |
+
Write-Log "`nStep 7: Downloading Workflows & Settings..." -Color Yellow
|
251 |
+
$userDefaultPath = Join-Path $comfyPath "user\default"; New-Item -Path $userDefaultPath -ItemType Directory -Force | Out-Null
|
252 |
+
$workflowPath = Join-Path $userDefaultPath "workflows"; New-Item -Path $workflowPath -ItemType Directory -Force | Out-Null
|
253 |
+
$workflowCloneDest = Join-Path $workflowPath "UmeAiRT-Workflow"
|
254 |
+
$settingsFilePath = Join-Path $userDefaultPath "comfy.settings.json"
|
255 |
+
Download-File -Uri "https://huggingface.co/UmeAiRT/ComfyUI-Auto_installer/resolve/main/others/comfy.settings.json" -OutFile $settingsFilePath
|
256 |
+
if (-not (Test-Path $workflowCloneDest)) { Invoke-AndLog "git" "clone https://github.com/UmeAiRT/ComfyUI-Workflows `"$workflowCloneDest`"" }
|
257 |
+
|
258 |
+
# --- Étape 8: Création du lanceur final ---
|
259 |
+
Write-Log "`nStep 8: Creating final launcher script..." -Color Yellow
|
260 |
+
$launcherContent = @"
|
261 |
+
@echo off
|
262 |
+
echo Activating ComfyUI virtual environment...
|
263 |
+
call `"%~dp0ComfyUI\venv\Scripts\activate.bat`"
|
264 |
+
echo Starting ComfyUI...
|
265 |
+
cd `"%~dp0ComfyUI`"
|
266 |
+
python main.py --windows-standalone-build
|
267 |
+
pause
|
268 |
+
"@
|
269 |
+
$launcherContent | Set-Content -Path (Join-Path $InstallPath "run_ComfyUI.bat")
|
270 |
+
Write-Log " - Created run_ComfyUI.bat. Use this file to start the application." -Color Green
|
271 |
+
|
272 |
+
# --- Étape 9: Téléchargement optionnel des packs de modèles ---
|
273 |
+
Write-Log "`nStep 9: Optional Model Pack Downloads..." -Color Yellow
|
274 |
+
$modelPacks = @( @{Name="FLUX"; ScriptName="Download-FLUX-Models.ps1"} )
|
275 |
$scriptsSubFolder = Join-Path $InstallPath "scripts"
|
|
|
|
|
276 |
foreach ($pack in $modelPacks) {
|
|
|
277 |
$scriptPath = Join-Path $scriptsSubFolder $pack.ScriptName
|
278 |
+
if (-not (Test-Path $scriptPath)) { Write-Log "Model downloader script not found: '$($pack.ScriptName)'. Skipping." -Color Red; continue }
|
|
|
|
|
|
|
|
|
|
|
279 |
$validInput = $false
|
280 |
while (-not $validInput) {
|
281 |
Write-Host "`n[33mWould you like to download $($pack.Name) models? (Y/N)[0m"
|
282 |
$choice = Read-Host
|
|
|
283 |
if ($choice -eq 'Y' -or $choice -eq 'y') {
|
284 |
Write-Log " - Launching downloader for $($pack.Name) models..." -Color Green
|
|
|
285 |
& $scriptPath -InstallPath $InstallPath
|
286 |
$validInput = $true
|
287 |
} elseif ($choice -eq 'N' -or $choice -eq 'n') {
|
288 |
Write-Log " - Skipping download for $($pack.Name) models." -Color Gray
|
289 |
$validInput = $true
|
290 |
+
} else { Write-Host " [31mInvalid choice. Please enter Y or N.[0m" }
|
|
|
|
|
291 |
}
|
292 |
}
|
293 |
|
294 |
#===========================================================================
|
295 |
+
# FINALIZATION
|
296 |
#===========================================================================
|
297 |
Write-Log "-------------------------------------------------------------------------------" -Color Green
|
298 |
+
Write-Log "Installation of ComfyUI and all nodes is complete!" -Color Green
|
299 |
+
Read-Host "Press Enter to close this window."
|