Compare commits

...

4 Commits
3.26 ... 3.27

6 changed files with 66 additions and 8 deletions

View File

@@ -152,6 +152,11 @@ class Ctx:
if y != '': if y != '':
cm_global.pip_blacklist.add(y) cm_global.pip_blacklist.add(y)
def update_custom_nodes_dir(self, target_dir):
import folder_paths
a, b = folder_paths.folder_names_and_paths['custom_nodes']
folder_paths.folder_names_and_paths['custom_nodes'] = [os.path.abspath(target_dir)], set()
@staticmethod @staticmethod
def get_startup_scripts_path(): def get_startup_scripts_path():
return os.path.join(core.manager_startup_script_path, "install-scripts.txt") return os.path.join(core.manager_startup_script_path, "install-scripts.txt")
@@ -1075,10 +1080,17 @@ def restore_snapshot(
user_directory: str = typer.Option( user_directory: str = typer.Option(
None, None,
help="user directory" help="user directory"
),
restore_to: Optional[str] = typer.Option(
None,
help="Manually specify the installation path for the custom node. Ignore user directory."
) )
): ):
cmd_ctx.set_user_directory(user_directory) cmd_ctx.set_user_directory(user_directory)
if restore_to:
cmd_ctx.update_custom_nodes_dir(restore_to)
extras = [] extras = []
if pip_non_url: if pip_non_url:
extras.append('--pip-non-url') extras.append('--pip-non-url')

View File

@@ -42,7 +42,7 @@ import manager_downloader
from node_package import InstalledNodePackage from node_package import InstalledNodePackage
version_code = [3, 26] version_code = [3, 27]
version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '')
@@ -997,7 +997,7 @@ class UnifiedManager:
return result return result
def unified_enable(self, node_id, version_spec=None): def unified_enable(self, node_id: str, version_spec=None):
""" """
priority if version_spec == None priority if version_spec == None
1. CNR latest in disk 1. CNR latest in disk
@@ -1009,6 +1009,9 @@ class UnifiedManager:
result = ManagedResult('enable') result = ManagedResult('enable')
if 'comfyui-manager' in node_id.lower():
return result.fail(f"ignored: enabling '{node_id}'")
if version_spec is None: if version_spec is None:
version_spec = self.resolve_unspecified_version(node_id, guess_mode='inactive') version_spec = self.resolve_unspecified_version(node_id, guess_mode='inactive')
if version is None: if version is None:
@@ -1074,9 +1077,12 @@ class UnifiedManager:
self.active_nodes[node_id] = version_spec, to_path self.active_nodes[node_id] = version_spec, to_path
return result.with_target(to_path) return result.with_target(to_path)
def unified_disable(self, node_id, is_unknown): def unified_disable(self, node_id: str, is_unknown):
result = ManagedResult('disable') result = ManagedResult('disable')
if 'comfyui-manager' in node_id.lower():
return result.fail(f"ignored: disabling '{node_id}'")
if is_unknown: if is_unknown:
version_spec = 'unknown' version_spec = 'unknown'
else: else:
@@ -1132,6 +1138,9 @@ class UnifiedManager:
""" """
result = ManagedResult('uninstall') result = ManagedResult('uninstall')
if 'comfyui-manager' in node_id.lower():
return result.fail(f"ignored: uninstalling '{node_id}'")
if is_unknown: if is_unknown:
# remove from actives # remove from actives
repo_and_path = self.unknown_active_nodes.get(node_id) repo_and_path = self.unknown_active_nodes.get(node_id)
@@ -1188,9 +1197,12 @@ class UnifiedManager:
return result return result
def cnr_install(self, node_id, version_spec=None, instant_execution=False, no_deps=False, return_postinstall=False): def cnr_install(self, node_id: str, version_spec=None, instant_execution=False, no_deps=False, return_postinstall=False):
result = ManagedResult('install-cnr') result = ManagedResult('install-cnr')
if 'comfyui-manager' in node_id.lower():
return result.fail(f"ignored: installing '{node_id}'")
node_info = cnr_utils.install_node(node_id, version_spec) node_info = cnr_utils.install_node(node_id, version_spec)
if node_info is None or not node_info.download_url: if node_info is None or not node_info.download_url:
return result.fail(f'not available node: {node_id}@{version_spec}') return result.fail(f'not available node: {node_id}@{version_spec}')
@@ -1235,10 +1247,13 @@ class UnifiedManager:
return result return result
def repo_install(self, url, repo_path, instant_execution=False, no_deps=False, return_postinstall=False): def repo_install(self, url: str, repo_path: str, instant_execution=False, no_deps=False, return_postinstall=False):
result = ManagedResult('install-git') result = ManagedResult('install-git')
result.append(url) result.append(url)
if 'comfyui-manager' in url.lower():
return result.fail(f"ignored: installing '{url}'")
if not is_valid_url(url): if not is_valid_url(url):
return result.fail(f"Invalid git url: {url}") return result.fail(f"Invalid git url: {url}")
@@ -1359,7 +1374,7 @@ class UnifiedManager:
else: else:
return self.cnr_switch_version(node_id, instant_execution=instant_execution, no_deps=no_deps, return_postinstall=return_postinstall).with_ver('cnr') return self.cnr_switch_version(node_id, instant_execution=instant_execution, no_deps=no_deps, return_postinstall=return_postinstall).with_ver('cnr')
async def install_by_id(self, node_id, version_spec=None, channel=None, mode=None, instant_execution=False, no_deps=False, return_postinstall=False): async def install_by_id(self, node_id: str, version_spec=None, channel=None, mode=None, instant_execution=False, no_deps=False, return_postinstall=False):
""" """
priority if version_spec == None priority if version_spec == None
1. CNR latest 1. CNR latest
@@ -1368,6 +1383,9 @@ class UnifiedManager:
remark: latest version_spec is not allowed. Must be resolved before call. remark: latest version_spec is not allowed. Must be resolved before call.
""" """
if 'comfyui-manager' in node_id.lower():
return ManagedResult('skip').fail(f"ignored: installing '{node_id}'")
repo_url = None repo_url = None
if version_spec is None: if version_spec is None:
if self.is_enabled(node_id): if self.is_enabled(node_id):
@@ -3039,6 +3057,10 @@ async def restore_snapshot(snapshot_path, git_helper_extras=None):
# normalize github repo # normalize github repo
for k, v in _git_info.items(): for k, v in _git_info.items():
# robust filter out comfyui-manager while restoring snapshot
if 'comfyui-manager' in k.lower():
continue
norm_k = git_utils.normalize_url(k) norm_k = git_utils.normalize_url(k)
git_info[norm_k] = v git_info[norm_k] = v

View File

@@ -1195,7 +1195,15 @@ async def install_custom_node(request):
git_url = None git_url = None
if json_data['version'] != 'unknown': if json_data['version'] != 'unknown':
selected_version = json_data.get('selected_version', 'latest') selected_version = json_data.get('selected_version')
if skip_post_install:
if cnr_id in core.unified_manager.nightly_inactive_nodes or cnr_id in core.unified_manager.cnr_inactive_nodes:
core.unified_manager.unified_enable(cnr_id)
return web.Response(status=200)
else:
selected_version = 'latest'
if selected_version != 'nightly': if selected_version != 'nightly':
risky_level = 'low' risky_level = 'low'
node_spec_str = f"{cnr_id}@{selected_version}" node_spec_str = f"{cnr_id}@{selected_version}"
@@ -1578,6 +1586,9 @@ def restart(self):
if sys.platform.startswith('win32'): if sys.platform.startswith('win32'):
cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:] cmds = ['"' + sys.executable + '"', '"' + sys_argv[0] + '"'] + sys_argv[1:]
elif sys_argv[0].endswith("__main__.py"): # this is a python module
module_name = os.path.basename(os.path.dirname(sys_argv[0]))
cmds = [sys.executable, '-m', module_name] + sys_argv[1:]
else: else:
cmds = [sys.executable] + sys_argv cmds = [sys.executable] + sys_argv

View File

@@ -12,6 +12,7 @@ import subprocess
import sys import sys
import re import re
import logging import logging
import platform
cache_lock = threading.Lock() cache_lock = threading.Lock()
@@ -21,6 +22,16 @@ cache_dir = os.path.join(comfyui_manager_path, '.cache') # This path is also up
use_uv = False use_uv = False
def add_python_path_to_env():
if platform.system() != "Windows":
sep = ':'
else:
sep = ';'
os.environ['PATH'] = os.path.dirname(sys.executable)+sep+os.environ['PATH']
def make_pip_cmd(cmd): def make_pip_cmd(cmd):
if use_uv: if use_uv:
return [sys.executable, '-m', 'uv', 'pip'] + cmd return [sys.executable, '-m', 'uv', 'pip'] + cmd

View File

@@ -34,6 +34,8 @@ else:
security_check.security_check() security_check.security_check()
manager_util.add_python_path_to_env()
cm_global.pip_blacklist = {'torch', 'torchsde', 'torchvision'} cm_global.pip_blacklist = {'torch', 'torchsde', 'torchvision'}
cm_global.pip_downgrade_blacklist = ['torch', 'torchsde', 'torchvision', 'transformers', 'safetensors', 'kornia'] cm_global.pip_downgrade_blacklist = ['torch', 'torchsde', 'torchvision', 'transformers', 'safetensors', 'kornia']

View File

@@ -1,7 +1,7 @@
[project] [project]
name = "comfyui-manager" name = "comfyui-manager"
description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI." description = "ComfyUI-Manager provides features to install and manage custom nodes for ComfyUI, as well as various functionalities to assist with ComfyUI."
version = "3.26" version = "3.27"
license = { file = "LICENSE.txt" } license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"] dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"]