mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-05-07 15:52:32 +08:00
support startup script for installation without locking on windows
This commit is contained in:
parent
febea8c101
commit
fd3470c328
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,3 +14,4 @@ venv/
|
|||||||
web/extensions/*
|
web/extensions/*
|
||||||
!web/extensions/logging.js.example
|
!web/extensions/logging.js.example
|
||||||
!web/extensions/core/
|
!web/extensions/core/
|
||||||
|
startup-scripts/
|
||||||
27
main.py
27
main.py
@ -1,6 +1,31 @@
|
|||||||
|
import os
|
||||||
|
import glob
|
||||||
|
import importlib.util
|
||||||
|
|
||||||
|
# When the startup script is executed, it should ensure that it has minimal dependencies.
|
||||||
|
# This startup script can be executed while minimizing the impact of package locking caused by imports in Windows, especially during dependency installation processes.
|
||||||
|
startup_scripts_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), "startup-scripts")
|
||||||
|
script_files = glob.glob(os.path.join(startup_scripts_path, "*.py"))
|
||||||
|
|
||||||
|
if os.path.exists(startup_scripts_path):
|
||||||
|
script_files = os.listdir(startup_scripts_path)
|
||||||
|
|
||||||
|
# Import each script file to execute
|
||||||
|
for script_file in script_files:
|
||||||
|
if script_file.endswith(".py"):
|
||||||
|
script_path = os.path.join(startup_scripts_path, script_file)
|
||||||
|
module_name = os.path.splitext(script_file)[0]
|
||||||
|
try:
|
||||||
|
spec = importlib.util.spec_from_file_location(module_name, script_path)
|
||||||
|
module = importlib.util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(module)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Failed to execute startup-script: {script_file} / {e}")
|
||||||
|
|
||||||
|
|
||||||
|
# Main code
|
||||||
import asyncio
|
import asyncio
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import gc
|
import gc
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user