mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-03-12 22:02:14 +00:00
feat/startup-script: Feature to avoid package installation errors when installing custom nodes. (#856)
* support startup script for installation without locking on windows * modified: Instead of executing scripts from the startup-scripts directory, I will change it to execute the prestartup_script.py for each custom node.
This commit is contained in:
parent
606a537090
commit
99abcbef41
3
.gitignore
vendored
3
.gitignore
vendored
@ -13,4 +13,5 @@ extra_model_paths.yaml
|
|||||||
venv/
|
venv/
|
||||||
web/extensions/*
|
web/extensions/*
|
||||||
!web/extensions/logging.js.example
|
!web/extensions/logging.js.example
|
||||||
!web/extensions/core/
|
!web/extensions/core/
|
||||||
|
startup-scripts/
|
35
main.py
35
main.py
@ -1,6 +1,38 @@
|
|||||||
|
import os
|
||||||
|
import importlib.util
|
||||||
|
import folder_paths
|
||||||
|
|
||||||
|
|
||||||
|
def execute_prestartup_script():
|
||||||
|
def execute_script(script_path):
|
||||||
|
if os.path.exists(script_path):
|
||||||
|
module_name = os.path.splitext(script_path)[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_path} / {e}")
|
||||||
|
|
||||||
|
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||||
|
for custom_node_path in node_paths:
|
||||||
|
possible_modules = os.listdir(custom_node_path)
|
||||||
|
|
||||||
|
for possible_module in possible_modules:
|
||||||
|
module_path = os.path.join(custom_node_path, possible_module)
|
||||||
|
if os.path.isfile(module_path) or module_path.endswith(".disabled") or module_path == "__pycache__":
|
||||||
|
continue
|
||||||
|
|
||||||
|
script_path = os.path.join(module_path, "prestartup_script.py")
|
||||||
|
execute_script(script_path)
|
||||||
|
|
||||||
|
|
||||||
|
execute_prestartup_script()
|
||||||
|
|
||||||
|
|
||||||
|
# Main code
|
||||||
import asyncio
|
import asyncio
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
import gc
|
import gc
|
||||||
@ -22,7 +54,6 @@ if __name__ == "__main__":
|
|||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import execution
|
import execution
|
||||||
import folder_paths
|
|
||||||
import server
|
import server
|
||||||
from server import BinaryEventTypes
|
from server import BinaryEventTypes
|
||||||
from nodes import init_custom_nodes
|
from nodes import init_custom_nodes
|
||||||
|
Loading…
Reference in New Issue
Block a user