fixed: invalid config.ini path

fixed: invalid environment setup for git_helper.py
fixed: default pip overrides doesn't work
modified: git_helper.py - use GIT_EXE_PATH env instead of config.ini
improved: print user_directory and ComfyUI-Manager config path on startup
This commit is contained in:
Dr.Lt.Data 2025-01-09 22:47:02 +09:00
parent ac8804ca6a
commit fd164862f3
6 changed files with 34 additions and 34 deletions

View File

@ -71,9 +71,8 @@ core.check_invalid_nodes()
def read_downgrade_blacklist():
try:
import configparser
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
config = configparser.ConfigParser()
config.read(config_path)
config.read(core.manager_config.path)
default_conf = config['default']
if 'downgrade_blacklist' in default_conf:
@ -136,9 +135,9 @@ class Ctx:
core.update_user_directory(user_directory)
if os.path.exists(core.manager_pip_overrides_path):
cm_global.pip_overrides = {'numpy': 'numpy<2'}
with open(core.manager_pip_overrides_path, 'r', encoding="UTF-8", errors="ignore") as json_file:
cm_global.pip_overrides = json.load(json_file)
cm_global.pip_overrides = {'numpy': 'numpy<2'}
@staticmethod
def get_startup_scripts_path():

View File

@ -4,7 +4,6 @@ import os
import traceback
import git
import configparser
import json
import yaml
import requests
@ -13,13 +12,13 @@ from git.remote import RemoteProgress
comfy_path = os.environ.get('COMFYUI_PATH')
git_exe_path = os.environ.get('GIT_EXE_PATH')
if comfy_path is None:
print("\n[bold yellow]WARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.[/bold yellow]", file=sys.stderr)
print("\nWARN: The `COMFYUI_PATH` environment variable is not set. Assuming `custom_nodes/ComfyUI-Manager/../../` as the ComfyUI path.", file=sys.stderr)
comfy_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))
def download_url(url, dest_folder, filename=None):
# Ensure the destination folder exists
if not os.path.exists(dest_folder):
@ -43,7 +42,6 @@ def download_url(url, dest_folder, filename=None):
print(f"Failed to download file from {url}")
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
nodelist_path = os.path.join(os.path.dirname(__file__), "custom-node-list.json")
working_directory = os.getcwd()
@ -440,10 +438,8 @@ def restore_pip_snapshot(pips, options):
def setup_environment():
config = configparser.ConfigParser()
config.read(config_path)
if 'default' in config and 'git_exe' in config['default'] and config['default']['git_exe'] != '':
git.Git().update_environment(GIT_PYTHON_GIT_EXECUTABLE=config['default']['git_exe'])
if git_exe_path is not None:
git.Git().update_environment(GIT_PYTHON_GIT_EXECUTABLE=git_exe_path)
setup_environment()

View File

@ -41,7 +41,7 @@ import manager_downloader
from node_package import InstalledNodePackage
version_code = [3, 4]
version_code = [3, 5]
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
@ -50,6 +50,7 @@ DEFAULT_CHANNEL = "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/ma
default_custom_nodes_path = None
def get_default_custom_nodes_path():
global default_custom_nodes_path
if default_custom_nodes_path is None:
@ -79,6 +80,16 @@ def get_comfyui_tag():
return None
def get_script_env():
copied = os.environ.copy()
git_exe = get_config().get('git_exe')
if git_exe is not None:
copied['GIT_EXE_PATH'] = git_exe
copied['COMFYUI_PATH'] = comfy_path
return copied
invalid_nodes = {}
@ -1480,9 +1491,7 @@ class ManagerFuncs:
print(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
return 0
new_env = os.environ.copy()
new_env["COMFYUI_PATH"] = comfy_path
subprocess.check_call(cmd, cwd=cwd, env=new_env)
subprocess.check_call(cmd, cwd=cwd, env=get_script_env())
return 0
@ -1639,9 +1648,8 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
else:
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=get_default_custom_nodes_path())
new_env = get_script_env()
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=get_default_custom_nodes_path(), env=new_env)
output, _ = process.communicate()
output = output.decode('utf-8').strip()
@ -1692,10 +1700,8 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
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]
process = subprocess.Popen(command, env=new_env, cwd=get_default_custom_nodes_path())
process = subprocess.Popen(command, env=get_script_env(), cwd=get_default_custom_nodes_path())
process.wait()

View File

@ -108,7 +108,7 @@ class ManagerFuncsInComfyUI(core.ManagerFuncs):
logging.error(f"[ComfyUI-Manager] Unexpected behavior: `{cmd}`")
return 0
process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1)
process = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1, env=core.get_script_env())
stdout_thread = threading.Thread(target=handle_stream, args=(process.stdout, ""))
stderr_thread = threading.Thread(target=handle_stream, args=(process.stderr, "[!]"))

View File

@ -50,9 +50,8 @@ def check_file_logging():
global enable_file_logging
try:
import configparser
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
config = configparser.ConfigParser()
config.read(config_path)
config.read(manager_config_path)
default_conf = config['default']
if 'file_logging' in default_conf and default_conf['file_logging'].lower() == 'false':
@ -79,12 +78,12 @@ custom_nodes_base_path = folder_paths.get_folder_paths('custom_nodes')[0]
manager_files_path = os.path.abspath(os.path.join(folder_paths.get_user_directory(), 'default', 'ComfyUI-Manager'))
manager_pip_overrides_path = os.path.join(manager_files_path, "pip_overrides.json")
restore_snapshot_path = os.path.join(manager_files_path, "startup-scripts", "restore-snapshot.json")
manager_config_path = os.path.join(manager_files_path, 'config.ini')
git_script_path = os.path.join(comfyui_manager_path, "git_helper.py")
cm_cli_path = os.path.join(comfyui_manager_path, "cm-cli.py")
cm_global.pip_overrides = {}
cm_global.pip_overrides = {'numpy': 'numpy<2', 'ultralytics': 'ultralytics==8.3.40'}
if os.path.exists(manager_pip_overrides_path):
with open(manager_pip_overrides_path, 'r', encoding="UTF-8", errors="ignore") as json_file:
cm_global.pip_overrides = json.load(json_file)
@ -345,6 +344,9 @@ print("** Platform:", platform.system())
print("** Python version:", sys.version)
print("** Python executable:", sys.executable)
print("** ComfyUI Path:", comfy_path)
print("** User directory:", folder_paths.user_directory)
print("** ComfyUI-Manager config path:", manager_config_path)
if log_path_base is not None:
print("** Log path:", os.path.abspath(f'{log_path_base}.log'))
@ -355,9 +357,8 @@ else:
def read_downgrade_blacklist():
try:
import configparser
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
config = configparser.ConfigParser()
config.read(config_path)
config.read(manager_config_path)
default_conf = config['default']
if 'downgrade_blacklist' in default_conf:
@ -376,13 +377,12 @@ def check_bypass_ssl():
try:
import configparser
import ssl
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
config = configparser.ConfigParser()
config.read(config_path)
config.read(manager_config_path)
default_conf = config['default']
if 'bypass_ssl' in default_conf and default_conf['bypass_ssl'].lower() == 'true':
print("[ComfyUI-Manager] WARN: Unsafe - SSL verification bypass option is Enabled. (see ComfyUI-Manager/config.ini)")
print(f"[ComfyUI-Manager] WARN: Unsafe - SSL verification bypass option is Enabled. (see {manager_config_path})")
ssl._create_default_https_context = ssl._create_unverified_context # SSL certificate error fix.
except Exception:
pass
@ -648,9 +648,8 @@ manager_util.clear_pip_cache()
def check_windows_event_loop_policy():
try:
import configparser
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
config = configparser.ConfigParser()
config.read(config_path)
config.read(manager_config_path)
default_conf = config['default']
if 'windows_selector_event_loop_policy' in default_conf and default_conf['windows_selector_event_loop_policy'].lower() == 'true':

View File

@ -1,7 +1,7 @@
[project]
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."
version = "3.4"
version = "3.5"
license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]