diff --git a/cm-cli.py b/cm-cli.py index cb0e7c98..365b5931 100644 --- a/cm-cli.py +++ b/cm-cli.py @@ -54,7 +54,7 @@ def check_comfyui_hash(): core.comfy_ui_commit_datetime = repo.head.commit.committed_datetime -check_comfyui_hash() # This is a preparation step for manager_core +# check_comfyui_hash() # This is a preparation step for manager_core def read_downgrade_blacklist(): @@ -202,10 +202,11 @@ class Ctx: cm_ctx = Ctx() -def install_node(node_name, is_all=False, cnt_msg=''): +def install_node(node_name, is_all=False, cnt_msg='', install_path=None): if core.is_valid_url(node_name): # install via urls - res = core.gitclone_install([node_name]) + print(f"Installing {node_name} to {install_path}") + res = core.gitclone_install([node_name], install_path=install_path) if not res: print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]") else: @@ -219,7 +220,7 @@ def install_node(node_name, is_all=False, cnt_msg=''): elif os.path.exists(node_path + '.disabled'): enable_node(node_name) else: - res = core.gitclone_install(node_item['files'], instant_execution=True, msg_prefix=f"[{cnt_msg}] ") + res = core.gitclone_install(node_item['files'], instant_execution=True, msg_prefix=f"[{cnt_msg}] ", install_path=install_path) if not res: print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]") else: @@ -469,7 +470,7 @@ def auto_save_snapshot(): print(f"Current snapshot is saved as `{path}`") -def for_each_nodes(nodes, act, allow_all=True): +def for_each_nodes(nodes, act, allow_all=True, install_path=None): is_all = False if allow_all and 'all' in nodes: is_all = True @@ -481,7 +482,7 @@ def for_each_nodes(nodes, act, allow_all=True): i = 1 for x in nodes: try: - act(x, is_all=is_all, cnt_msg=f'{i}/{total}') + act(x, is_all=is_all, cnt_msg=f'{i}/{total}', install_path=install_path) except Exception as e: print(f"ERROR: {e}") traceback.print_exc() @@ -513,9 +514,13 @@ def install( None, help="[remote|local|cache]" ), + install_path: str = typer.Option( + None, + help="Specify the installation path" + ), ): cm_ctx.set_channel_mode(channel, mode) - for_each_nodes(nodes, act=install_node) + for_each_nodes(nodes, act=install_node, install_path=install_path) @app.command(help="Reinstall custom nodes") diff --git a/glob/manager_core.py b/glob/manager_core.py index 8ea3572c..4db9fcc8 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -572,7 +572,7 @@ def is_valid_url(url): return False -def gitclone_install(files, instant_execution=False, msg_prefix=''): +def gitclone_install(files, instant_execution=False, msg_prefix='', install_path=None): print(f"{msg_prefix}Install: {files}") for url in files: if not is_valid_url(url): @@ -582,9 +582,9 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''): if url.endswith("/"): url = url[:-1] try: - print(f"Download: git clone '{url}'") + print(f"Download: git clone '{url}' to {install_path}") repo_name = os.path.splitext(os.path.basename(url))[0] - repo_path = os.path.join(get_default_custom_nodes_path(), repo_name) + repo_path = os.path.join(install_path or get_default_custom_nodes_path(), repo_name) # Clone the repository from the remote URL if not instant_execution and platform.system() == 'Windows':