mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2026-02-09 12:42:33 +08:00
added support for --no-deps option to node install and reinstall
This commit is contained in:
parent
b3be556837
commit
af331778c8
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,8 @@
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.history/
|
||||||
|
*.code-workspace
|
||||||
.tmp
|
.tmp
|
||||||
.cache
|
.cache
|
||||||
config.ini
|
config.ini
|
||||||
@ -12,4 +14,4 @@ matrix_auth
|
|||||||
channels.list
|
channels.list
|
||||||
comfyworkflows_sharekey
|
comfyworkflows_sharekey
|
||||||
github-stats-cache.json
|
github-stats-cache.json
|
||||||
pip_overrides.json
|
pip_overrides.json
|
||||||
|
|||||||
30
cm-cli.py
30
cm-cli.py
@ -80,6 +80,7 @@ read_downgrade_blacklist() # This is a preparation step for manager_core
|
|||||||
class Ctx:
|
class Ctx:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.channel = 'default'
|
self.channel = 'default'
|
||||||
|
self.no_deps = False
|
||||||
self.mode = 'cache'
|
self.mode = 'cache'
|
||||||
|
|
||||||
def set_channel_mode(self, channel, mode):
|
def set_channel_mode(self, channel, mode):
|
||||||
@ -100,6 +101,9 @@ class Ctx:
|
|||||||
asyncio.run(unified_manager.reload(cache_mode=self.mode == 'cache'))
|
asyncio.run(unified_manager.reload(cache_mode=self.mode == 'cache'))
|
||||||
asyncio.run(unified_manager.load_nightly(self.channel, self.mode))
|
asyncio.run(unified_manager.load_nightly(self.channel, self.mode))
|
||||||
|
|
||||||
|
def set_no_deps(self, no_deps):
|
||||||
|
self.no_deps = no_deps
|
||||||
|
|
||||||
|
|
||||||
channel_ctx = Ctx()
|
channel_ctx = Ctx()
|
||||||
|
|
||||||
@ -107,7 +111,7 @@ channel_ctx = Ctx()
|
|||||||
def install_node(node_spec_str, is_all=False, cnt_msg=''):
|
def install_node(node_spec_str, is_all=False, cnt_msg=''):
|
||||||
if core.is_valid_url(node_spec_str):
|
if core.is_valid_url(node_spec_str):
|
||||||
# install via urls
|
# install via urls
|
||||||
res = asyncio.run(core.gitclone_install(node_spec_str))
|
res = asyncio.run(core.gitclone_install(node_spec_str, no_deps=channel_ctx.no_deps))
|
||||||
if not res.result:
|
if not res.result:
|
||||||
print(res.msg)
|
print(res.msg)
|
||||||
print(f"[bold red]ERROR: An error occurred while installing '{node_spec_str}'.[/bold red]")
|
print(f"[bold red]ERROR: An error occurred while installing '{node_spec_str}'.[/bold red]")
|
||||||
@ -125,7 +129,7 @@ def install_node(node_spec_str, is_all=False, cnt_msg=''):
|
|||||||
if not is_specified:
|
if not is_specified:
|
||||||
version_spec = None
|
version_spec = None
|
||||||
|
|
||||||
res = asyncio.run(unified_manager.install_by_id(node_name, version_spec, channel_ctx.channel, channel_ctx.mode, instant_execution=True))
|
res = asyncio.run(unified_manager.install_by_id(node_name, version_spec, channel_ctx.channel, channel_ctx.mode, instant_execution=True, no_deps=channel_ctx.no_deps))
|
||||||
|
|
||||||
if res.action == 'skip':
|
if res.action == 'skip':
|
||||||
print(f"{cnt_msg} [ SKIP ] {node_name:50} => Already installed")
|
print(f"{cnt_msg} [ SKIP ] {node_name:50} => Already installed")
|
||||||
@ -171,7 +175,7 @@ def fix_node(node_spec_str, is_all=False, cnt_msg=''):
|
|||||||
node_name, version_spec, _ = node_spec
|
node_name, version_spec, _ = node_spec
|
||||||
|
|
||||||
print(f"{cnt_msg} [ FIXING ]: {node_name:50}[{version_spec}]")
|
print(f"{cnt_msg} [ FIXING ]: {node_name:50}[{version_spec}]")
|
||||||
res = unified_manager.unified_fix(node_name, version_spec)
|
res = unified_manager.unified_fix(node_name, version_spec, no_deps=channel_ctx.no_deps)
|
||||||
|
|
||||||
if not res.result:
|
if not res.result:
|
||||||
print(f"ERROR: f{res.msg}")
|
print(f"ERROR: f{res.msg}")
|
||||||
@ -211,7 +215,7 @@ def update_node(node_spec_str, is_all=False, cnt_msg=''):
|
|||||||
|
|
||||||
node_name, version_spec, _ = node_spec
|
node_name, version_spec, _ = node_spec
|
||||||
|
|
||||||
res = unified_manager.unified_update(node_name, version_spec, return_postinstall=True)
|
res = unified_manager.unified_update(node_name, version_spec, no_deps=channel_ctx.no_deps, return_postinstall=True)
|
||||||
|
|
||||||
if not res.result:
|
if not res.result:
|
||||||
print(f"ERROR: An error occurred while updating '{node_name}'.")
|
print(f"ERROR: An error occurred while updating '{node_name}'.")
|
||||||
@ -549,9 +553,17 @@ def install(
|
|||||||
mode: str = typer.Option(
|
mode: str = typer.Option(
|
||||||
None,
|
None,
|
||||||
help="[remote|local|cache]"
|
help="[remote|local|cache]"
|
||||||
)
|
),
|
||||||
|
no_deps: Annotated[
|
||||||
|
Optional[bool],
|
||||||
|
typer.Option(
|
||||||
|
show_default=False,
|
||||||
|
help="Use new fast dependency installer",
|
||||||
|
),
|
||||||
|
] = False,
|
||||||
):
|
):
|
||||||
channel_ctx.set_channel_mode(channel, mode)
|
channel_ctx.set_channel_mode(channel, mode)
|
||||||
|
channel_ctx.set_no_deps(no_deps)
|
||||||
for_each_nodes(nodes, act=install_node)
|
for_each_nodes(nodes, act=install_node)
|
||||||
|
|
||||||
|
|
||||||
@ -571,8 +583,16 @@ def reinstall(
|
|||||||
None,
|
None,
|
||||||
help="[remote|local|cache]"
|
help="[remote|local|cache]"
|
||||||
),
|
),
|
||||||
|
no_deps: Annotated[
|
||||||
|
Optional[bool],
|
||||||
|
typer.Option(
|
||||||
|
show_default=False,
|
||||||
|
help="Use new fast dependency installer",
|
||||||
|
),
|
||||||
|
] = False,
|
||||||
):
|
):
|
||||||
channel_ctx.set_channel_mode(channel, mode)
|
channel_ctx.set_channel_mode(channel, mode)
|
||||||
|
channel_ctx.set_no_deps(no_deps)
|
||||||
for_each_nodes(nodes, act=reinstall_node)
|
for_each_nodes(nodes, act=reinstall_node)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1521,7 +1521,8 @@ 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):
|
||||||
|
# import ipdb; ipdb.set_trace()
|
||||||
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")
|
||||||
|
|
||||||
@ -1529,7 +1530,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")
|
||||||
with open(requirements_path, "r") as requirements_file:
|
with open(requirements_path, "r") as requirements_file:
|
||||||
for line in requirements_file:
|
for line in requirements_file:
|
||||||
@ -1547,7 +1548,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def git_repo_update_check_with(path, do_fetch=False, do_update=False):
|
def git_repo_update_check_with(path, do_fetch=False, do_update=False, no_deps=False):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
perform update check for git custom node
|
perform update check for git custom node
|
||||||
@ -1570,7 +1571,7 @@ def git_repo_update_check_with(path, do_fetch=False, do_update=False):
|
|||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
updated, success = __win_check_git_update(path, do_fetch, do_update)
|
updated, success = __win_check_git_update(path, do_fetch, do_update)
|
||||||
if updated and success:
|
if updated and success:
|
||||||
execute_install_script(None, path, lazy_mode=True)
|
execute_install_script(None, path, lazy_mode=True, no_deps=no_deps)
|
||||||
return updated, success
|
return updated, success
|
||||||
else:
|
else:
|
||||||
# Fetch the latest commits from the remote repository
|
# Fetch the latest commits from the remote repository
|
||||||
@ -1618,7 +1619,7 @@ def git_repo_update_check_with(path, do_fetch=False, do_update=False):
|
|||||||
new_commit_hash = repo.head.commit.hexsha
|
new_commit_hash = repo.head.commit.hexsha
|
||||||
|
|
||||||
if commit_hash != new_commit_hash:
|
if commit_hash != new_commit_hash:
|
||||||
execute_install_script(None, path)
|
execute_install_script(None, path, no_deps=no_deps)
|
||||||
print(f"\nUpdated: {path}")
|
print(f"\nUpdated: {path}")
|
||||||
return True, True
|
return True, True
|
||||||
else:
|
else:
|
||||||
@ -1683,7 +1684,7 @@ def is_valid_url(url):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
async def gitclone_install(url, instant_execution=False, msg_prefix=''):
|
async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=False):
|
||||||
await unified_manager.reload('cache')
|
await unified_manager.reload('cache')
|
||||||
await unified_manager.get_custom_nodes('default', 'cache')
|
await unified_manager.get_custom_nodes('default', 'cache')
|
||||||
|
|
||||||
@ -1729,7 +1730,7 @@ async def gitclone_install(url, instant_execution=False, msg_prefix=''):
|
|||||||
repo.git.clear_cache()
|
repo.git.clear_cache()
|
||||||
repo.close()
|
repo.close()
|
||||||
|
|
||||||
execute_install_script(url, repo_path, instant_execution=instant_execution)
|
execute_install_script(url, repo_path, instant_execution=instant_execution, no_deps=no_deps)
|
||||||
print("Installation was successful.")
|
print("Installation was successful.")
|
||||||
return result.with_target(repo_path)
|
return result.with_target(repo_path)
|
||||||
|
|
||||||
@ -1806,7 +1807,7 @@ async def get_data_by_mode(mode, filename, channel_url=None):
|
|||||||
return json_obj
|
return json_obj
|
||||||
|
|
||||||
|
|
||||||
def gitclone_fix(files, instant_execution=False):
|
def gitclone_fix(files, instant_execution=False, no_deps=False):
|
||||||
print(f"Try fixing: {files}")
|
print(f"Try fixing: {files}")
|
||||||
for url in files:
|
for url in files:
|
||||||
if not is_valid_url(url):
|
if not is_valid_url(url):
|
||||||
@ -1822,7 +1823,7 @@ def gitclone_fix(files, instant_execution=False):
|
|||||||
if os.path.exists(repo_path+'.disabled'):
|
if os.path.exists(repo_path+'.disabled'):
|
||||||
repo_path = repo_path+'.disabled'
|
repo_path = repo_path+'.disabled'
|
||||||
|
|
||||||
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:
|
||||||
@ -1950,7 +1951,7 @@ def gitclone_set_active(files, is_disable):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefix=""):
|
def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefix="", no_deps=False):
|
||||||
import os
|
import os
|
||||||
|
|
||||||
print(f"{msg_prefix}Update: {files}")
|
print(f"{msg_prefix}Update: {files}")
|
||||||
@ -1968,10 +1969,10 @@ def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefi
|
|||||||
|
|
||||||
if not skip_script:
|
if not skip_script:
|
||||||
if instant_execution:
|
if instant_execution:
|
||||||
if not execute_install_script(url, repo_path, lazy_mode=False, instant_execution=True):
|
if not execute_install_script(url, repo_path, lazy_mode=False, instant_execution=True, no_deps=no_deps):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
if not execute_install_script(url, repo_path, lazy_mode=True):
|
if not execute_install_script(url, repo_path, lazy_mode=True, no_deps=no_deps):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -1983,7 +1984,7 @@ def gitclone_update(files, instant_execution=False, skip_script=False, msg_prefi
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def update_path(repo_path, instant_execution=False):
|
def update_path(repo_path, instant_execution=False, no_deps=False):
|
||||||
if not os.path.exists(os.path.join(repo_path, '.git')):
|
if not os.path.exists(os.path.join(repo_path, '.git')):
|
||||||
return "fail"
|
return "fail"
|
||||||
|
|
||||||
@ -2023,7 +2024,7 @@ def update_path(repo_path, instant_execution=False):
|
|||||||
|
|
||||||
if commit_hash != remote_commit_hash:
|
if commit_hash != remote_commit_hash:
|
||||||
git_pull(repo_path)
|
git_pull(repo_path)
|
||||||
execute_install_script("ComfyUI", repo_path, instant_execution=instant_execution)
|
execute_install_script("ComfyUI", repo_path, instant_execution=instant_execution, no_deps=no_deps)
|
||||||
return "updated"
|
return "updated"
|
||||||
else:
|
else:
|
||||||
return "skipped"
|
return "skipped"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user