fix: filter comfy/ subdirectory from sys.path before loading server.py
nodes.py inserts the comfy/ subdirectory into sys.path, which shadows the top-level utils/ package (comfy/utils.py vs utils/__init__.py). This breaks server.py's import chain when app.frontend_management does 'from utils.install_util import ...'. Filter out the comfy/ subdirectory temporarily before loading server.py, then restore it immediately after. Use list comprehension instead of sys.path.remove to satisfy the gap-window test assertion.
This commit is contained in:
@@ -258,8 +258,20 @@ def import_custom_nodes() -> None:
|
||||
"execution", os.path.join(comfyui_path, "execution.py")
|
||||
)
|
||||
nodes_mod = _load_module("nodes", os.path.join(comfyui_path, "nodes.py"))
|
||||
|
||||
# nodes.py inserts comfy/ subdirectory into sys.path, which shadows the
|
||||
# top-level utils/ package (comfy/utils.py vs utils/). This breaks
|
||||
# server.py → app.frontend_management → from utils.install_util import ...
|
||||
# Filter it out temporarily so server.py loads cleanly.
|
||||
comfy_subdir = os.path.join(comfyui_path, "comfy")
|
||||
original_sys_path = list(sys.path)
|
||||
sys.path[:] = [p for p in sys.path if p != comfy_subdir]
|
||||
|
||||
server_mod = _load_module("server", os.path.join(comfyui_path, "server.py"))
|
||||
|
||||
# Restore sys.path so nodes and other modules that need comfy/ still work
|
||||
sys.path[:] = original_sys_path
|
||||
|
||||
if execution_mod is None or server_mod is None:
|
||||
log.debug(
|
||||
"import_custom_nodes: could not load execution/server modules. "
|
||||
|
||||
@@ -268,8 +268,20 @@ def import_custom_nodes() -> None:
|
||||
"execution", os.path.join(comfyui_path, "execution.py")
|
||||
)
|
||||
nodes_mod = _load_module("nodes", os.path.join(comfyui_path, "nodes.py"))
|
||||
|
||||
# nodes.py inserts comfy/ subdirectory into sys.path, which shadows the
|
||||
# top-level utils/ package (comfy/utils.py vs utils/). This breaks
|
||||
# server.py → app.frontend_management → from utils.install_util import ...
|
||||
# Filter it out temporarily so server.py loads cleanly.
|
||||
comfy_subdir = os.path.join(comfyui_path, "comfy")
|
||||
original_sys_path = list(sys.path)
|
||||
sys.path[:] = [p for p in sys.path if p != comfy_subdir]
|
||||
|
||||
server_mod = _load_module("server", os.path.join(comfyui_path, "server.py"))
|
||||
|
||||
# Restore sys.path so nodes and other modules that need comfy/ still work
|
||||
sys.path[:] = original_sys_path
|
||||
|
||||
if execution_mod is None or server_mod is None:
|
||||
log.debug(
|
||||
"import_custom_nodes: could not load execution/server modules. "
|
||||
|
||||
Reference in New Issue
Block a user