Merge branch 'main' into feat/cnr
This commit is contained in:
@@ -40,6 +40,36 @@ DEFAULT_CHANNEL = "https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/ma
|
||||
|
||||
custom_nodes_path = os.path.abspath(os.path.join(comfyui_manager_path, '..'))
|
||||
|
||||
default_custom_nodes_path = None
|
||||
|
||||
def get_default_custom_nodes_path():
|
||||
global default_custom_nodes_path
|
||||
if default_custom_nodes_path is None:
|
||||
try:
|
||||
import folder_paths
|
||||
default_custom_nodes_path = folder_paths.get_folder_paths("custom_nodes")[0]
|
||||
except:
|
||||
default_custom_nodes_path = custom_nodes_path
|
||||
|
||||
return default_custom_nodes_path
|
||||
|
||||
|
||||
def get_custom_nodes_paths():
|
||||
try:
|
||||
import folder_paths
|
||||
return folder_paths.get_folder_paths("custom_nodes")
|
||||
except:
|
||||
return [custom_nodes_path]
|
||||
|
||||
|
||||
def get_comfyui_tag():
|
||||
repo = git.Repo(comfy_path)
|
||||
try:
|
||||
return repo.git.describe('--tags')
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
invalid_nodes = {}
|
||||
|
||||
|
||||
@@ -92,7 +122,11 @@ def check_invalid_nodes():
|
||||
|
||||
comfy_path = os.environ.get('COMFYUI_PATH')
|
||||
if comfy_path is None:
|
||||
comfy_path = os.path.abspath(os.path.join(custom_nodes_path, '..'))
|
||||
try:
|
||||
import folder_paths
|
||||
comfy_path = os.path.join(os.path.dirname(folder_paths.__file__))
|
||||
except:
|
||||
comfy_path = os.path.abspath(os.path.join(custom_nodes_path, '..'))
|
||||
|
||||
channel_list_path = os.path.join(comfyui_manager_path, 'channels.list')
|
||||
config_path = os.path.join(comfyui_manager_path, "config.ini")
|
||||
@@ -1548,7 +1582,7 @@ def __win_check_git_update(path, do_fetch=False, do_update=False):
|
||||
|
||||
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=get_default_custom_nodes_path())
|
||||
output, _ = process.communicate()
|
||||
output = output.decode('utf-8').strip()
|
||||
|
||||
@@ -1602,7 +1636,7 @@ 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=custom_nodes_path)
|
||||
process = subprocess.Popen(command, env=new_env, cwd=get_default_custom_nodes_path())
|
||||
process.wait()
|
||||
|
||||
|
||||
@@ -1617,6 +1651,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
else:
|
||||
if os.path.exists(requirements_path) and not no_deps:
|
||||
print("Install: pip packages")
|
||||
pip_fixer = PIPFixer(get_installed_packages())
|
||||
with open(requirements_path, "r") as requirements_file:
|
||||
for line in requirements_file:
|
||||
#handle comments
|
||||
@@ -1639,6 +1674,8 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
||||
if package_name.strip() != "" and not package_name.startswith('#'):
|
||||
try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||
|
||||
pip_fixer.fix_broken()
|
||||
|
||||
if os.path.exists(install_script_path):
|
||||
print(f"Install: install script")
|
||||
install_cmd = [sys.executable, "install.py"]
|
||||
@@ -1809,9 +1846,10 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
# node_dir = f"{repo_name}@unknown"
|
||||
node_dir = repo_name
|
||||
|
||||
repo_path = os.path.join(custom_nodes_path, node_dir)
|
||||
disabled_repo_path1 = os.path.join(custom_nodes_path, '.disabled', node_dir)
|
||||
disabled_repo_path2 = os.path.join(custom_nodes_path, repo_name+'.disabled') # old style
|
||||
custom_nodes_base = get_default_custom_nodes_path()
|
||||
repo_path = os.path.join(custom_nodes_base, node_dir)
|
||||
disabled_repo_path1 = os.path.join(custom_nodes_base, '.disabled', node_dir)
|
||||
disabled_repo_path2 = os.path.join(custom_nodes_base, repo_name+'.disabled') # old style
|
||||
|
||||
if os.path.exists(repo_path):
|
||||
return result.fail(f"Already exists: '{repo_path}'")
|
||||
@@ -1826,7 +1864,7 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
||||
|
||||
# Clone the repository from the remote URL
|
||||
if not instant_execution and platform.system() == 'Windows':
|
||||
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", custom_nodes_path, url, repo_path], cwd=custom_nodes_path)
|
||||
res = manager_funcs.run_script([sys.executable, git_script_path, "--clone", custom_nodes_base, url, repo_path], cwd=custom_nodes_base)
|
||||
if res != 0:
|
||||
return result.fail(f"Failed to clone '{url}' into '{repo_path}'")
|
||||
else:
|
||||
@@ -1912,6 +1950,23 @@ async def get_data_by_mode(mode, filename, channel_url=None):
|
||||
return json_obj
|
||||
|
||||
|
||||
def lookup_installed_custom_nodes(repo_name):
|
||||
try:
|
||||
import folder_paths
|
||||
base_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||
except:
|
||||
base_paths = [custom_nodes_path]
|
||||
|
||||
for base_path in base_paths:
|
||||
repo_path = os.path.join(base_path, repo_name)
|
||||
if os.path.exists(repo_path):
|
||||
return True, repo_path
|
||||
elif os.path.exists(repo_path+'.disabled'):
|
||||
return False, repo_path
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def gitclone_fix(files, instant_execution=False, no_deps=False):
|
||||
print(f"Try fixing: {files}")
|
||||
for url in files:
|
||||
@@ -1923,13 +1978,15 @@ def gitclone_fix(files, instant_execution=False, no_deps=False):
|
||||
url = url[:-1]
|
||||
try:
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0]
|
||||
repo_path = os.path.join(custom_nodes_path, repo_name)
|
||||
repo_path = lookup_installed_custom_nodes(repo_name)
|
||||
|
||||
if os.path.exists(repo_path+'.disabled'):
|
||||
repo_path = repo_path+'.disabled'
|
||||
if repo_path is not None:
|
||||
repo_path = repo_path[1]
|
||||
|
||||
if not execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps):
|
||||
return False
|
||||
if not execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps):
|
||||
return False
|
||||
else:
|
||||
print(f"Custom node not found: {repo_name}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr)
|
||||
@@ -1976,12 +2033,12 @@ def gitclone_uninstall(files):
|
||||
url = url[:-1]
|
||||
try:
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_path, dir_name)
|
||||
repo_path = lookup_installed_custom_nodes(dir_name)
|
||||
|
||||
# safety check
|
||||
if dir_path == '/' or dir_path[1:] == ":/" or dir_path == '':
|
||||
print(f"Uninstall(git-clone) error: invalid path '{dir_path}' for '{url}'")
|
||||
return False
|
||||
if repo_path is None:
|
||||
continue
|
||||
|
||||
dir_path = repo_path[1]
|
||||
|
||||
install_script_path = os.path.join(dir_path, "uninstall.py")
|
||||
disable_script_path = os.path.join(dir_path, "disable.py")
|
||||
@@ -1997,10 +2054,7 @@ def gitclone_uninstall(files):
|
||||
if code != 0:
|
||||
print(f"An error occurred during the execution of the disable.py script. Only the '{dir_path}' will be deleted.")
|
||||
|
||||
if os.path.exists(dir_path):
|
||||
rmtree(dir_path)
|
||||
elif os.path.exists(dir_path + ".disabled"):
|
||||
rmtree(dir_path + ".disabled")
|
||||
rmtree(dir_path)
|
||||
except Exception as e:
|
||||
print(f"Uninstall(git-clone) error: {url} / {e}", file=sys.stderr)
|
||||
return False
|
||||
@@ -2023,12 +2077,12 @@ def gitclone_set_active(files, is_disable):
|
||||
url = url[:-1]
|
||||
try:
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_path, dir_name)
|
||||
repo_path = lookup_installed_custom_nodes(dir_name)
|
||||
|
||||
# safety check
|
||||
if dir_path == '/' or dir_path[1:] == ":/" or dir_path == '':
|
||||
print(f"{action_name}(git-clone) error: invalid path '{dir_path}' for '{url}'")
|
||||
return False
|
||||
if repo_path is None:
|
||||
continue
|
||||
|
||||
dir_path = repo_path[1]
|
||||
|
||||
if is_disable:
|
||||
current_path = dir_path
|
||||
@@ -2065,10 +2119,12 @@ def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefi
|
||||
url = url[:-1]
|
||||
try:
|
||||
repo_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
repo_path = os.path.join(custom_nodes_path, repo_name)
|
||||
repo_path = lookup_installed_custom_nodes(repo_name)
|
||||
|
||||
if os.path.exists(repo_path+'.disabled'):
|
||||
repo_path = repo_path+'.disabled'
|
||||
if repo_path is None:
|
||||
continue
|
||||
|
||||
repo_path = repo_path[1]
|
||||
|
||||
git_pull(repo_path)
|
||||
|
||||
@@ -2139,10 +2195,14 @@ def lookup_customnode_by_url(data, target):
|
||||
for x in data['custom_nodes']:
|
||||
if target in x['files']:
|
||||
dir_name = os.path.splitext(os.path.basename(target))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_path, dir_name)
|
||||
if os.path.exists(dir_path):
|
||||
repo_path = lookup_installed_custom_nodes(dir_name)
|
||||
|
||||
if repo_path is None:
|
||||
continue
|
||||
|
||||
if repo_path[0]:
|
||||
x['installed'] = 'True'
|
||||
elif os.path.exists(dir_path + ".disabled"):
|
||||
else:
|
||||
x['installed'] = 'Disabled'
|
||||
return x
|
||||
|
||||
@@ -2151,13 +2211,15 @@ def lookup_customnode_by_url(data, target):
|
||||
|
||||
def simple_check_custom_node(url):
|
||||
dir_name = os.path.splitext(os.path.basename(url))[0].replace(".git", "")
|
||||
dir_path = os.path.join(custom_nodes_path, dir_name)
|
||||
if os.path.exists(dir_path):
|
||||
return 'installed'
|
||||
elif os.path.exists(dir_path+'.disabled'):
|
||||
return 'disabled'
|
||||
repo_path = lookup_installed_custom_nodes(dir_name)
|
||||
|
||||
return 'not-installed'
|
||||
if repo_path is None:
|
||||
return 'not-installed'
|
||||
|
||||
if repo_path[0]:
|
||||
return 'installed'
|
||||
else:
|
||||
return 'disabled'
|
||||
|
||||
|
||||
def check_state_of_git_node_pack_single(item, do_fetch=False, do_update_check=True, do_update=False):
|
||||
|
||||
Reference in New Issue
Block a user