From 17a9cdfe7bfea135839058cc6536d44a0cb301a5 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Mon, 28 Apr 2025 00:27:11 +0900 Subject: [PATCH] support pip version ComfyUI-Manager modified: Added `comfyui_manager` to requirements instead of cloning ComfyUI-Manager modified: Execute `python -m comfyui_manager.cm_cli` instead of `cm-cli.sh` modified: Removed unnecessary Manager installation code --- comfy_cli/cmdline.py | 21 ---------- comfy_cli/command/custom_nodes/cm_cli_util.py | 10 +---- comfy_cli/command/custom_nodes/command.py | 4 +- comfy_cli/command/install.py | 41 ------------------- comfy_cli/constants.py | 1 - pyproject.toml | 1 + tests/comfy_cli/command/test_command.py | 3 +- 7 files changed, 4 insertions(+), 77 deletions(-) diff --git a/comfy_cli/cmdline.py b/comfy_cli/cmdline.py index 247ba95a..e036e5e1 100644 --- a/comfy_cli/cmdline.py +++ b/comfy_cli/cmdline.py @@ -165,13 +165,6 @@ def install( callback=validate_version, ), ] = "nightly", - manager_url: Annotated[ - str, - typer.Option( - show_default=False, - help="url or local path pointing to the ComfyUI-Manager git repo to be installed. A specific branch can optionally be specified using a setuptools-like syntax, eg https://foo.git@bar", - ), - ] = constants.COMFY_MANAGER_GITHUB_URL, restore: Annotated[ bool, typer.Option( @@ -179,10 +172,6 @@ def install( help="Restore dependencies for installed ComfyUI if not installed", ), ] = False, - skip_manager: Annotated[ - bool, - typer.Option(show_default=False, help="Skip installing the manager component"), - ] = False, skip_torch_or_directml: Annotated[ bool, typer.Option(show_default=False, help="Skip installing PyTorch Or DirectML"), @@ -243,10 +232,6 @@ def install( help="Use new fast dependency installer", ), ] = False, - manager_commit: Annotated[ - Optional[str], - typer.Option(help="Specify commit hash for ComfyUI-Manager"), - ] = None, ): check_for_updates() checker = EnvChecker() @@ -272,10 +257,8 @@ def install( rprint("[bold yellow]Installing for CPU[/bold yellow]") install_inner.execute( url, - manager_url, comfy_path, restore, - skip_manager, commit=commit, version=version, gpu=None, @@ -284,7 +267,6 @@ def install( skip_torch_or_directml=skip_torch_or_directml, skip_requirement=skip_requirement, fast_deps=fast_deps, - manager_commit=manager_commit, ) rprint(f"ComfyUI is installed at: {comfy_path}") return None @@ -340,10 +322,8 @@ def install( install_inner.execute( url, - manager_url, comfy_path, restore, - skip_manager, commit=commit, gpu=gpu, version=version, @@ -352,7 +332,6 @@ def install( skip_torch_or_directml=skip_torch_or_directml, skip_requirement=skip_requirement, fast_deps=fast_deps, - manager_commit=manager_commit, ) rprint(f"ComfyUI is installed at: {comfy_path}") diff --git a/comfy_cli/command/custom_nodes/cm_cli_util.py b/comfy_cli/command/custom_nodes/cm_cli_util.py index 78f3370e..96a25a2b 100644 --- a/comfy_cli/command/custom_nodes/cm_cli_util.py +++ b/comfy_cli/command/custom_nodes/cm_cli_util.py @@ -30,15 +30,7 @@ def execute_cm_cli(args, channel=None, fast_deps=False, mode=None) -> str | None print("\n[bold red]ComfyUI path is not resolved.[/bold red]\n", file=sys.stderr) raise typer.Exit(code=1) - cm_cli_path = os.path.join(workspace_path, "custom_nodes", "ComfyUI-Manager", "cm-cli.py") - if not os.path.exists(cm_cli_path): - print( - f"\n[bold red]ComfyUI-Manager not found: {cm_cli_path}[/bold red]\n", - file=sys.stderr, - ) - raise typer.Exit(code=1) - - cmd = [sys.executable, cm_cli_path] + args + cmd = [sys.executable, '-m', 'comfyui_manager.cm_cli'] + args if channel is not None: cmd += ["--channel", channel] diff --git a/comfy_cli/command/custom_nodes/command.py b/comfy_cli/command/custom_nodes/command.py index f15d6072..6ec9cf60 100644 --- a/comfy_cli/command/custom_nodes/command.py +++ b/comfy_cli/command/custom_nodes/command.py @@ -482,14 +482,12 @@ def update_node_id_cache(): config_manager = ConfigManager() workspace_path = workspace_manager.workspace_path - cm_cli_path = os.path.join(workspace_path, "custom_nodes", "ComfyUI-Manager", "cm-cli.py") - tmp_path = os.path.join(config_manager.get_config_path(), "tmp") if not os.path.exists(tmp_path): os.makedirs(tmp_path) cache_path = os.path.join(tmp_path, "node-cache.list") - cmd = [sys.executable, cm_cli_path, "export-custom-node-ids", cache_path] + cmd = [sys.executable, "-m", "comfyui_manager.cm_cli", "export-custom-node-ids", cache_path] new_env = os.environ.copy() new_env["COMFYUI_PATH"] = workspace_path diff --git a/comfy_cli/command/install.py b/comfy_cli/command/install.py index abb26229..b168a7cd 100755 --- a/comfy_cli/command/install.py +++ b/comfy_cli/command/install.py @@ -12,7 +12,6 @@ from rich.panel import Panel from comfy_cli import constants, ui, utils -from comfy_cli.command.custom_nodes.command import update_node_id_cache from comfy_cli.constants import GPU_OPTION from comfy_cli.git_utils import git_checkout_tag from comfy_cli.uv import DependencyCompiler @@ -162,13 +161,10 @@ def pip_install_manager_dependencies(repo_dir): def execute( url: str, - manager_url: str, comfy_path: str, restore: bool, - skip_manager: bool, version: str, commit: Optional[str] = None, - manager_commit: Optional[str] = None, gpu: constants.GPU_OPTION = None, cuda_version: constants.CUDAVersion = constants.CUDAVersion.v12_6, plat: constants.OS = None, @@ -225,48 +221,11 @@ def execute( rprint("") - # install ComfyUI-Manager - if skip_manager: - rprint("Skipping installation of ComfyUI-Manager. (by --skip-manager)") - else: - manager_repo_dir = os.path.join(repo_dir, "custom_nodes", "ComfyUI-Manager") - - if os.path.exists(manager_repo_dir): - if restore and not fast_deps: - pip_install_manager_dependencies(repo_dir) - else: - rprint( - f"Directory {manager_repo_dir} already exists. Skipping installation of ComfyUI-Manager.\nIf you want to restore dependencies, add the '--restore' option." - ) - else: - rprint("\nInstalling ComfyUI-Manager..") - - if "@" in manager_url: - # clone specific branch - manager_url, manager_branch = manager_url.rsplit("@", 1) - subprocess.run( - ["git", "clone", "-b", manager_branch, manager_url, manager_repo_dir], - check=True, - ) - else: - subprocess.run(["git", "clone", manager_url, manager_repo_dir], check=True) - if manager_commit is not None: - subprocess.run(["git", "checkout", manager_commit], check=True, cwd=manager_repo_dir) - - if not fast_deps: - pip_install_manager_dependencies(repo_dir) - if fast_deps: depComp = DependencyCompiler(cwd=repo_dir, gpu=gpu) depComp.compile_deps() depComp.install_deps() - if not skip_manager: - try: - update_node_id_cache() - except subprocess.CalledProcessError as e: - rprint(f"Failed to update node id cache: {e}") - os.chdir(repo_dir) rprint("") diff --git a/comfy_cli/constants.py b/comfy_cli/constants.py index 37b1a24e..dcaef449 100644 --- a/comfy_cli/constants.py +++ b/comfy_cli/constants.py @@ -14,7 +14,6 @@ class PROC(str, Enum): COMFY_GITHUB_URL = "https://github.com/comfyanonymous/ComfyUI" -COMFY_MANAGER_GITHUB_URL = "https://github.com/ltdrdata/ComfyUI-Manager" DEFAULT_COMFY_MODEL_PATH = "models" DEFAULT_COMFY_WORKSPACE = { diff --git a/pyproject.toml b/pyproject.toml index 328c087c..32f29ee7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ dependencies = [ "ruff", "semver~=3.0.2", "cookiecutter", + "comfyui-manager" ] [project.optional-dependencies] diff --git a/tests/comfy_cli/command/test_command.py b/tests/comfy_cli/command/test_command.py index 7dcbac96..11c3111c 100644 --- a/tests/comfy_cli/command/test_command.py +++ b/tests/comfy_cli/command/test_command.py @@ -44,9 +44,8 @@ def test_install_here(cmd, runner, mock_execute, mock_prompt_select_enum): assert result.exit_code == 0, result.stdout args, _ = mock_execute.call_args - url, manager_url, comfy_path, *_ = args + url, comfy_path, *_ = args assert url == "https://github.com/comfyanonymous/ComfyUI" - assert manager_url == "https://github.com/ltdrdata/ComfyUI-Manager" assert comfy_path == os.path.join(os.getcwd(), "ComfyUI")