mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-16 18:02:58 +08:00
provide COMFYUI_PATH environment variable when executing install.py
This commit is contained in:
parent
53159fe8d4
commit
67655985bd
@ -23,12 +23,17 @@ sys.path.append(glob_path)
|
|||||||
import cm_global
|
import cm_global
|
||||||
from manager_util import *
|
from manager_util import *
|
||||||
|
|
||||||
version = [2, 42]
|
version = [2, 43]
|
||||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||||
|
|
||||||
|
|
||||||
comfyui_manager_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
comfyui_manager_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
custom_nodes_path = os.path.abspath(os.path.join(comfyui_manager_path, '..'))
|
custom_nodes_path = os.path.abspath(os.path.join(comfyui_manager_path, '..'))
|
||||||
comfy_path = os.path.abspath(os.path.join(custom_nodes_path, '..'))
|
|
||||||
|
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||||
|
if comfy_path is None:
|
||||||
|
comfy_path = os.path.abspath(os.path.join(custom_nodes_path, '..'))
|
||||||
|
|
||||||
channel_list_path = os.path.join(comfyui_manager_path, 'channels.list')
|
channel_list_path = os.path.join(comfyui_manager_path, 'channels.list')
|
||||||
config_path = os.path.join(comfyui_manager_path, "config.ini")
|
config_path = os.path.join(comfyui_manager_path, "config.ini")
|
||||||
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
||||||
@ -181,7 +186,9 @@ class ManagerFuncs:
|
|||||||
print(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
|
print(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
subprocess.check_call(cmd, cwd=cwd)
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
|
subprocess.check_call(cmd, cwd=cwd, env=new_env)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -325,6 +332,8 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
|
|||||||
else:
|
else:
|
||||||
command = [sys.executable, git_script_path, "--check", path]
|
command = [sys.executable, git_script_path, "--check", path]
|
||||||
|
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=custom_nodes_path)
|
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=custom_nodes_path)
|
||||||
output, _ = process.communicate()
|
output, _ = process.communicate()
|
||||||
output = output.decode('utf-8').strip()
|
output = output.decode('utf-8').strip()
|
||||||
@ -334,10 +343,10 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
|
|||||||
safedir_path = path.replace('\\', '/')
|
safedir_path = path.replace('\\', '/')
|
||||||
try:
|
try:
|
||||||
print(f"[ComfyUI-Manager] Try fixing 'dubious repository' error on '{safedir_path}' repo")
|
print(f"[ComfyUI-Manager] Try fixing 'dubious repository' error on '{safedir_path}' repo")
|
||||||
process = subprocess.Popen(['git', 'config', '--global', '--add', 'safe.directory', safedir_path], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(['git', 'config', '--global', '--add', 'safe.directory', safedir_path], env=new_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
output, _ = process.communicate()
|
output, _ = process.communicate()
|
||||||
|
|
||||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
process = subprocess.Popen(command, env=new_env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
output, _ = process.communicate()
|
output, _ = process.communicate()
|
||||||
output = output.decode('utf-8').strip()
|
output = output.decode('utf-8').strip()
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -376,8 +385,10 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
|
|||||||
|
|
||||||
|
|
||||||
def __win_check_git_pull(path):
|
def __win_check_git_pull(path):
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
command = [sys.executable, git_script_path, "--pull", path]
|
command = [sys.executable, git_script_path, "--pull", path]
|
||||||
process = subprocess.Popen(command, cwd=custom_nodes_path)
|
process = subprocess.Popen(command, env=new_env, cwd=custom_nodes_path)
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import platform
|
|||||||
import json
|
import json
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
|
|
||||||
glob_path = os.path.join(os.path.dirname(__file__), "glob")
|
glob_path = os.path.join(os.path.dirname(__file__), "glob")
|
||||||
sys.path.append(glob_path)
|
sys.path.append(glob_path)
|
||||||
|
|
||||||
@ -59,6 +60,9 @@ def check_file_logging():
|
|||||||
|
|
||||||
check_file_logging()
|
check_file_logging()
|
||||||
|
|
||||||
|
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||||
|
if comfy_path is None:
|
||||||
|
comfy_path = os.path.abspath(sys.modules['__main__'].__file__)
|
||||||
|
|
||||||
sys.__comfyui_manager_register_message_collapse = register_message_collapse
|
sys.__comfyui_manager_register_message_collapse = register_message_collapse
|
||||||
sys.__comfyui_manager_is_import_failed_extension = is_import_failed_extension
|
sys.__comfyui_manager_is_import_failed_extension = is_import_failed_extension
|
||||||
@ -137,8 +141,8 @@ def handle_stream(stream, prefix):
|
|||||||
print(prefix, msg, end="")
|
print(prefix, msg, end="")
|
||||||
|
|
||||||
|
|
||||||
def process_wrap(cmd_str, cwd_path, handler=None):
|
def process_wrap(cmd_str, cwd_path, handler=None, env=None):
|
||||||
process = subprocess.Popen(cmd_str, cwd=cwd_path, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
|
process = subprocess.Popen(cmd_str, cwd=cwd_path, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
|
||||||
|
|
||||||
if handler is None:
|
if handler is None:
|
||||||
handler = handle_stream
|
handler = handle_stream
|
||||||
@ -333,6 +337,7 @@ print("** ComfyUI startup time:", datetime.datetime.now())
|
|||||||
print("** Platform:", platform.system())
|
print("** Platform:", platform.system())
|
||||||
print("** Python version:", sys.version)
|
print("** Python version:", sys.version)
|
||||||
print("** Python executable:", sys.executable)
|
print("** Python executable:", sys.executable)
|
||||||
|
print("** ComfyUI Path:", comfy_path)
|
||||||
|
|
||||||
if enable_file_logging:
|
if enable_file_logging:
|
||||||
print("** Log path:", os.path.abspath('comfyui.log'))
|
print("** Log path:", os.path.abspath('comfyui.log'))
|
||||||
@ -475,7 +480,10 @@ if os.path.exists(restore_snapshot_path):
|
|||||||
|
|
||||||
print(f"[ComfyUI-Manager] Restore snapshot.")
|
print(f"[ComfyUI-Manager] Restore snapshot.")
|
||||||
cmd_str = [sys.executable, git_script_path, '--apply-snapshot', restore_snapshot_path]
|
cmd_str = [sys.executable, git_script_path, '--apply-snapshot', restore_snapshot_path]
|
||||||
exit_code = process_wrap(cmd_str, custom_nodes_path, handler=msg_capture)
|
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
|
exit_code = process_wrap(cmd_str, custom_nodes_path, handler=msg_capture, env=new_env)
|
||||||
|
|
||||||
repository_name = ''
|
repository_name = ''
|
||||||
for url in cloned_repos:
|
for url in cloned_repos:
|
||||||
@ -502,7 +510,10 @@ if os.path.exists(restore_snapshot_path):
|
|||||||
processed_install.add(f'{repo_path}/install.py')
|
processed_install.add(f'{repo_path}/install.py')
|
||||||
install_cmd = [sys.executable, install_script_path]
|
install_cmd = [sys.executable, install_script_path]
|
||||||
print(f">>> {install_cmd} / {repo_path}")
|
print(f">>> {install_cmd} / {repo_path}")
|
||||||
this_exit_code += process_wrap(install_cmd, repo_path)
|
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
|
this_exit_code += process_wrap(install_cmd, repo_path, env=new_env)
|
||||||
|
|
||||||
if this_exit_code != 0:
|
if this_exit_code != 0:
|
||||||
print(f"[ComfyUI-Manager] Restoring '{repository_name}' is failed.")
|
print(f"[ComfyUI-Manager] Restoring '{repository_name}' is failed.")
|
||||||
@ -542,7 +553,10 @@ def execute_lazy_install_script(repo_path, executable):
|
|||||||
processed_install.add(f'{repo_path}/install.py')
|
processed_install.add(f'{repo_path}/install.py')
|
||||||
print(f"Install: install script for '{repo_path}'")
|
print(f"Install: install script for '{repo_path}'")
|
||||||
install_cmd = [executable, "install.py"]
|
install_cmd = [executable, "install.py"]
|
||||||
process_wrap(install_cmd, repo_path)
|
|
||||||
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
|
process_wrap(install_cmd, repo_path, env=new_env)
|
||||||
|
|
||||||
|
|
||||||
# Check if script_list_path exists
|
# Check if script_list_path exists
|
||||||
@ -576,7 +590,9 @@ if os.path.exists(script_list_path):
|
|||||||
print(f"\n## ComfyUI-Manager: EXECUTE => {script[1:]}")
|
print(f"\n## ComfyUI-Manager: EXECUTE => {script[1:]}")
|
||||||
print(f"\n## Execute install/(de)activation script for '{script[0]}'")
|
print(f"\n## Execute install/(de)activation script for '{script[0]}'")
|
||||||
|
|
||||||
exit_code = process_wrap(script[1:], script[0])
|
new_env = os.environ.copy()
|
||||||
|
new_env["COMFYUI_PATH"] = comfy_path
|
||||||
|
exit_code = process_wrap(script[1:], script[0], env=new_env)
|
||||||
|
|
||||||
if exit_code != 0:
|
if exit_code != 0:
|
||||||
print(f"install/(de)activation script failed: {script[0]}")
|
print(f"install/(de)activation script failed: {script[0]}")
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "comfyui-manager"
|
name = "comfyui-manager"
|
||||||
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
|
||||||
version = "2.42"
|
version = "2.43"
|
||||||
license = "LICENSE"
|
license = "LICENSE"
|
||||||
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user