mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-02-13 22:52:31 +08:00
Merge pull request #2 from Comfy-Org/rh-fix
Add install path to cm-cli.
This commit is contained in:
commit
0f6d0e6ef0
32
cm-cli.py
32
cm-cli.py
@ -54,7 +54,7 @@ def check_comfyui_hash():
|
|||||||
core.comfy_ui_commit_datetime = repo.head.commit.committed_datetime
|
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():
|
def read_downgrade_blacklist():
|
||||||
@ -83,6 +83,10 @@ class Ctx:
|
|||||||
self.mode = 'remote'
|
self.mode = 'remote'
|
||||||
self.processed_install = set()
|
self.processed_install = set()
|
||||||
self.custom_node_map_cache = None
|
self.custom_node_map_cache = None
|
||||||
|
self.no_deps = False
|
||||||
|
|
||||||
|
def set_no_deps(self, no_deps):
|
||||||
|
self.no_deps = no_deps
|
||||||
|
|
||||||
def set_channel_mode(self, channel, mode):
|
def set_channel_mode(self, channel, mode):
|
||||||
if mode is not None:
|
if mode is not None:
|
||||||
@ -202,10 +206,11 @@ class Ctx:
|
|||||||
cm_ctx = 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, no_deps=False):
|
||||||
if core.is_valid_url(node_name):
|
if core.is_valid_url(node_name):
|
||||||
# install via urls
|
# 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:
|
if not res:
|
||||||
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]")
|
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]")
|
||||||
else:
|
else:
|
||||||
@ -219,7 +224,7 @@ def install_node(node_name, is_all=False, cnt_msg=''):
|
|||||||
elif os.path.exists(node_path + '.disabled'):
|
elif os.path.exists(node_path + '.disabled'):
|
||||||
enable_node(node_name)
|
enable_node(node_name)
|
||||||
else:
|
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, no_deps=no_deps)
|
||||||
if not res:
|
if not res:
|
||||||
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]")
|
print(f"[bold red]ERROR: An error occurred while installing '{node_name}'.[/bold red]")
|
||||||
else:
|
else:
|
||||||
@ -469,7 +474,7 @@ def auto_save_snapshot():
|
|||||||
print(f"Current snapshot is saved as `{path}`")
|
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, no_deps=False):
|
||||||
is_all = False
|
is_all = False
|
||||||
if allow_all and 'all' in nodes:
|
if allow_all and 'all' in nodes:
|
||||||
is_all = True
|
is_all = True
|
||||||
@ -481,7 +486,7 @@ def for_each_nodes(nodes, act, allow_all=True):
|
|||||||
i = 1
|
i = 1
|
||||||
for x in nodes:
|
for x in nodes:
|
||||||
try:
|
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, no_deps=no_deps)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"ERROR: {e}")
|
print(f"ERROR: {e}")
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@ -513,9 +518,22 @@ def install(
|
|||||||
None,
|
None,
|
||||||
help="[remote|local|cache]"
|
help="[remote|local|cache]"
|
||||||
),
|
),
|
||||||
|
install_path: str = typer.Option(
|
||||||
|
None,
|
||||||
|
help="Specify the installation path"
|
||||||
|
),
|
||||||
|
no_deps: Annotated[
|
||||||
|
Optional[bool],
|
||||||
|
typer.Option(
|
||||||
|
"--no-deps",
|
||||||
|
show_default=False,
|
||||||
|
help="Skip installing any Python dependencies",
|
||||||
|
),
|
||||||
|
] = False,
|
||||||
):
|
):
|
||||||
cm_ctx.set_channel_mode(channel, mode)
|
cm_ctx.set_channel_mode(channel, mode)
|
||||||
for_each_nodes(nodes, act=install_node)
|
cm_ctx.set_no_deps(no_deps)
|
||||||
|
for_each_nodes(nodes, act=install_node, install_path=install_path, no_deps=no_deps)
|
||||||
|
|
||||||
|
|
||||||
@app.command(help="Reinstall custom nodes")
|
@app.command(help="Reinstall custom nodes")
|
||||||
|
|||||||
@ -420,7 +420,7 @@ def __win_check_git_pull(path):
|
|||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
|
|
||||||
def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=False):
|
def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=False, no_deps=False):
|
||||||
install_script_path = os.path.join(repo_path, "install.py")
|
install_script_path = os.path.join(repo_path, "install.py")
|
||||||
requirements_path = os.path.join(repo_path, "requirements.txt")
|
requirements_path = os.path.join(repo_path, "requirements.txt")
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
|||||||
install_cmd = ["#LAZY-INSTALL-SCRIPT", sys.executable]
|
install_cmd = ["#LAZY-INSTALL-SCRIPT", sys.executable]
|
||||||
try_install_script(url, repo_path, install_cmd)
|
try_install_script(url, repo_path, install_cmd)
|
||||||
else:
|
else:
|
||||||
if os.path.exists(requirements_path):
|
if os.path.exists(requirements_path) and not no_deps:
|
||||||
print("Install: pip packages")
|
print("Install: pip packages")
|
||||||
pip_fixer = PIPFixer(get_installed_packages())
|
pip_fixer = PIPFixer(get_installed_packages())
|
||||||
with open(requirements_path, "r") as requirements_file:
|
with open(requirements_path, "r") as requirements_file:
|
||||||
@ -572,7 +572,7 @@ def is_valid_url(url):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def gitclone_install(files, instant_execution=False, msg_prefix=''):
|
def gitclone_install(files, instant_execution=False, msg_prefix='', install_path=None, no_deps=False):
|
||||||
print(f"{msg_prefix}Install: {files}")
|
print(f"{msg_prefix}Install: {files}")
|
||||||
for url in files:
|
for url in files:
|
||||||
if not is_valid_url(url):
|
if not is_valid_url(url):
|
||||||
@ -582,9 +582,9 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''):
|
|||||||
if url.endswith("/"):
|
if url.endswith("/"):
|
||||||
url = url[:-1]
|
url = url[:-1]
|
||||||
try:
|
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_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
|
# Clone the repository from the remote URL
|
||||||
if not instant_execution and platform.system() == 'Windows':
|
if not instant_execution and platform.system() == 'Windows':
|
||||||
@ -596,7 +596,7 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''):
|
|||||||
repo.git.clear_cache()
|
repo.git.clear_cache()
|
||||||
repo.close()
|
repo.close()
|
||||||
|
|
||||||
if not execute_install_script(url, repo_path, instant_execution=instant_execution):
|
if not execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user