mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-10 06:34:24 +08:00
implement package installation based on prestartup_script
This commit is contained in:
parent
2cf4a1e5a9
commit
3bda3f99f0
76
__init__.py
76
__init__.py
@ -16,7 +16,9 @@ sys.path.append('../..')
|
|||||||
from torchvision.datasets.utils import download_url
|
from torchvision.datasets.utils import download_url
|
||||||
|
|
||||||
# ensure .js
|
# ensure .js
|
||||||
print("### Loading: ComfyUI-Manager (V0.11.1)")
|
print("### Loading: ComfyUI-Manager (V0.12)")
|
||||||
|
|
||||||
|
comfy_ui_revision = "Unknown"
|
||||||
|
|
||||||
comfy_path = os.path.dirname(folder_paths.__file__)
|
comfy_path = os.path.dirname(folder_paths.__file__)
|
||||||
custom_nodes_path = os.path.join(comfy_path, 'custom_nodes')
|
custom_nodes_path = os.path.join(comfy_path, 'custom_nodes')
|
||||||
@ -29,19 +31,56 @@ local_db_custom_node_list = os.path.join(comfyui_manager_path, "custom-node-list
|
|||||||
local_db_extension_node_mappings = os.path.join(comfyui_manager_path, "extension-node-map.json")
|
local_db_extension_node_mappings = os.path.join(comfyui_manager_path, "extension-node-map.json")
|
||||||
git_script_path = os.path.join(os.path.dirname(__file__), "git_helper.py")
|
git_script_path = os.path.join(os.path.dirname(__file__), "git_helper.py")
|
||||||
|
|
||||||
|
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
||||||
|
|
||||||
|
|
||||||
|
def try_install_script(url, repo_path, install_cmd):
|
||||||
|
if platform.system() == "Windows" and comfy_ui_revision >= 1152:
|
||||||
|
if not os.path.exists(startup_script_path):
|
||||||
|
os.makedirs(startup_script_path)
|
||||||
|
|
||||||
|
script_path = os.path.join(startup_script_path, "install-scripts.txt")
|
||||||
|
with open(script_path, "a") as file:
|
||||||
|
obj = [repo_path] + install_cmd
|
||||||
|
file.write(f"{obj}\n")
|
||||||
|
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
code = subprocess.run(install_cmd, cwd=repo_path)
|
||||||
|
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
try:
|
||||||
|
if int(comfy_ui_revision) < 1152:
|
||||||
|
print("\n\n###################################################################")
|
||||||
|
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version ({comfy_ui_revision}) is too old. Please update to the latest version.")
|
||||||
|
print(f"[WARN] The extension installation feature may not work properly in the current installed ComfyUI version on Windows environment.")
|
||||||
|
print("###################################################################\n\n")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if code.returncode != 0:
|
||||||
|
print(f"install script failed: {url}")
|
||||||
|
return False
|
||||||
|
|
||||||
def print_comfyui_version():
|
def print_comfyui_version():
|
||||||
|
global comfy_ui_revision
|
||||||
try:
|
try:
|
||||||
repo = git.Repo(os.path.dirname(folder_paths.__file__))
|
repo = git.Repo(os.path.dirname(folder_paths.__file__))
|
||||||
|
|
||||||
revision_count = len(list(repo.iter_commits('HEAD')))
|
comfy_ui_revision = len(list(repo.iter_commits('HEAD')))
|
||||||
current_branch = repo.active_branch.name
|
current_branch = repo.active_branch.name
|
||||||
git_hash = repo.head.commit.hexsha
|
git_hash = repo.head.commit.hexsha
|
||||||
|
|
||||||
|
try:
|
||||||
|
if int(comfy_ui_revision) < 1148:
|
||||||
|
print(f"\n\n## [WARN] ComfyUI-Manager: Your ComfyUI version ({comfy_ui_revision}) is too old. Please update to the latest version. ##\n\n")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
if current_branch == "master":
|
if current_branch == "master":
|
||||||
print(f"### ComfyUI Revision: {revision_count} [{git_hash[:8]}]")
|
print(f"### ComfyUI Revision: {comfy_ui_revision} [{git_hash[:8]}]")
|
||||||
else:
|
else:
|
||||||
print(f"### ComfyUI Revision: {revision_count} on '{current_branch}' [{git_hash[:8]}]")
|
print(f"### ComfyUI Revision: {comfy_ui_revision} on '{current_branch}' [{git_hash[:8]}]")
|
||||||
except:
|
except:
|
||||||
print("### ComfyUI Revision: UNKNOWN (The currently installed ComfyUI is not a Git repository)")
|
print("### ComfyUI Revision: UNKNOWN (The currently installed ComfyUI is not a Git repository)")
|
||||||
|
|
||||||
@ -84,6 +123,10 @@ def git_repo_has_updates(path, do_fetch=False):
|
|||||||
else:
|
else:
|
||||||
# Fetch the latest commits from the remote repository
|
# Fetch the latest commits from the remote repository
|
||||||
repo = git.Repo(path)
|
repo = git.Repo(path)
|
||||||
|
|
||||||
|
current_branch = repo.active_branch
|
||||||
|
branch_name = current_branch.name
|
||||||
|
|
||||||
remote_name = 'origin'
|
remote_name = 'origin'
|
||||||
remote = repo.remote(name=remote_name)
|
remote = repo.remote(name=remote_name)
|
||||||
|
|
||||||
@ -92,13 +135,13 @@ def git_repo_has_updates(path, do_fetch=False):
|
|||||||
|
|
||||||
# Get the current commit hash and the commit hash of the remote branch
|
# Get the current commit hash and the commit hash of the remote branch
|
||||||
commit_hash = repo.head.commit.hexsha
|
commit_hash = repo.head.commit.hexsha
|
||||||
remote_commit_hash = repo.refs[f'{remote_name}/HEAD'].object.hexsha
|
remote_commit_hash = repo.refs[f'{remote_name}/{branch_name}'].object.hexsha
|
||||||
|
|
||||||
# Compare the commit hashes to determine if the local repository is behind the remote repository
|
# Compare the commit hashes to determine if the local repository is behind the remote repository
|
||||||
if commit_hash != remote_commit_hash:
|
if commit_hash != remote_commit_hash:
|
||||||
# Get the commit dates
|
# Get the commit dates
|
||||||
commit_date = repo.head.commit.committed_datetime
|
commit_date = repo.head.commit.committed_datetime
|
||||||
remote_commit_date = repo.refs[f'{remote_name}/HEAD'].object.committed_datetime
|
remote_commit_date = repo.refs[f'{remote_name}/{branch_name}'].object.committed_datetime
|
||||||
|
|
||||||
# Compare the commit dates to determine if the local repository is behind the remote repository
|
# Compare the commit dates to determine if the local repository is behind the remote repository
|
||||||
if commit_date < remote_commit_date:
|
if commit_date < remote_commit_date:
|
||||||
@ -153,9 +196,9 @@ def setup_js():
|
|||||||
js_src_path = os.path.join(comfyui_manager_path, "js", "comfyui-manager.js")
|
js_src_path = os.path.join(comfyui_manager_path, "js", "comfyui-manager.js")
|
||||||
shutil.copy(js_src_path, js_dest_path)
|
shutil.copy(js_src_path, js_dest_path)
|
||||||
|
|
||||||
|
|
||||||
setup_js()
|
setup_js()
|
||||||
|
|
||||||
|
|
||||||
# Expand Server api
|
# Expand Server api
|
||||||
|
|
||||||
import server
|
import server
|
||||||
@ -461,20 +504,12 @@ def execute_install_script(url, repo_path):
|
|||||||
if os.path.exists(requirements_path):
|
if os.path.exists(requirements_path):
|
||||||
print(f"Install: pip packages")
|
print(f"Install: pip packages")
|
||||||
install_cmd = [sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]
|
install_cmd = [sys.executable, "-m", "pip", "install", "-r", "requirements.txt"]
|
||||||
code = subprocess.run(install_cmd, cwd=repo_path)
|
try_install_script(url, repo_path, install_cmd)
|
||||||
|
|
||||||
if code.returncode != 0:
|
|
||||||
print(f"install script failed: {url}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
if os.path.exists(install_script_path):
|
if os.path.exists(install_script_path):
|
||||||
print(f"Install: install script")
|
print(f"Install: install script")
|
||||||
install_cmd = [sys.executable, "install.py"]
|
install_cmd = [sys.executable, "install.py"]
|
||||||
code = subprocess.run(install_cmd, cwd=repo_path)
|
try_install_script(url, repo_path, install_cmd)
|
||||||
|
|
||||||
if code.returncode != 0:
|
|
||||||
print(f"install script failed: {url}")
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -711,14 +746,17 @@ async def install_custom_node(request):
|
|||||||
|
|
||||||
# version check
|
# version check
|
||||||
repo = git.Repo(repo_path)
|
repo = git.Repo(repo_path)
|
||||||
|
|
||||||
|
current_branch = repo.active_branch
|
||||||
|
branch_name = current_branch.name
|
||||||
|
|
||||||
remote_name = 'origin'
|
remote_name = 'origin'
|
||||||
remote = repo.remote(name=remote_name)
|
remote = repo.remote(name=remote_name)
|
||||||
remote.fetch()
|
remote.fetch()
|
||||||
|
|
||||||
commit_hash = repo.head.commit.hexsha
|
commit_hash = repo.head.commit.hexsha
|
||||||
remote_commit_hash = repo.refs[f'{remote_name}/HEAD'].object.hexsha
|
remote_commit_hash = repo.refs[f'{remote_name}/{branch_name}'].object.hexsha
|
||||||
|
|
||||||
print(f"{commit_hash} != {remote_commit_hash}")
|
|
||||||
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)
|
execute_install_script("ComfyUI", repo_path)
|
||||||
|
|||||||
@ -627,6 +627,16 @@
|
|||||||
"install_type": "git-clone",
|
"install_type": "git-clone",
|
||||||
"description": "NODES: CLIP Text Encode++. Achieve identical embeddings from stable-diffusion-webui for ComfyUI."
|
"description": "NODES: CLIP Text Encode++. Achieve identical embeddings from stable-diffusion-webui for ComfyUI."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"author": "ZaneA",
|
||||||
|
"title": "ImageReward",
|
||||||
|
"reference": "https://github.com/ZaneA/ComfyUI-ImageReward",
|
||||||
|
"files": [
|
||||||
|
"https://github.com/ZaneA/ComfyUI-ImageReward"
|
||||||
|
],
|
||||||
|
"install_type": "git-clone",
|
||||||
|
"description": "NODES: ImageRewardLoader, ImageRewardScore"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"author": "taabata",
|
"author": "taabata",
|
||||||
"title": "Syrian Falcon Nodes",
|
"title": "Syrian Falcon Nodes",
|
||||||
|
|||||||
@ -4,6 +4,8 @@
|
|||||||
"Change Channel Count",
|
"Change Channel Count",
|
||||||
"Combine Masks",
|
"Combine Masks",
|
||||||
"Constant Mask",
|
"Constant Mask",
|
||||||
|
"Convert Color Space",
|
||||||
|
"Create QR Code",
|
||||||
"Create Rect Mask",
|
"Create Rect Mask",
|
||||||
"Cut By Mask",
|
"Cut By Mask",
|
||||||
"Get Image Size",
|
"Get Image Size",
|
||||||
@ -12,16 +14,20 @@
|
|||||||
"Mask By Text",
|
"Mask By Text",
|
||||||
"Mask Morphology",
|
"Mask Morphology",
|
||||||
"Mask To Region",
|
"Mask To Region",
|
||||||
|
"MasqueradeIncrementer",
|
||||||
"Mix Color By Mask",
|
"Mix Color By Mask",
|
||||||
"Mix Images By Mask",
|
"Mix Images By Mask",
|
||||||
"Paste By Mask",
|
"Paste By Mask",
|
||||||
"Prune By Mask",
|
"Prune By Mask",
|
||||||
"Separate Mask Components",
|
"Separate Mask Components",
|
||||||
|
"Unary Image Op",
|
||||||
"Unary Mask Op"
|
"Unary Mask Op"
|
||||||
],
|
],
|
||||||
"https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb": [
|
"https://github.com/BlenderNeko/ComfyUI_ADV_CLIP_emb": [
|
||||||
|
"BNK_AddCLIPSDXLParams",
|
||||||
|
"BNK_AddCLIPSDXLRParams",
|
||||||
"BNK_CLIPTextEncodeAdvanced",
|
"BNK_CLIPTextEncodeAdvanced",
|
||||||
"BNK_MixCLIPEmbeddings"
|
"BNK_CLIPTextEncodeSDXLAdvanced"
|
||||||
],
|
],
|
||||||
"https://github.com/BlenderNeko/ComfyUI_Cutoff": [
|
"https://github.com/BlenderNeko/ComfyUI_Cutoff": [
|
||||||
"BNK_CutoffBasePrompt",
|
"BNK_CutoffBasePrompt",
|
||||||
@ -507,6 +513,7 @@
|
|||||||
"Logic Boolean",
|
"Logic Boolean",
|
||||||
"Lora Loader",
|
"Lora Loader",
|
||||||
"Mask Arbitrary Region",
|
"Mask Arbitrary Region",
|
||||||
|
"Mask Batch",
|
||||||
"Mask Batch to Mask",
|
"Mask Batch to Mask",
|
||||||
"Mask Ceiling Region",
|
"Mask Ceiling Region",
|
||||||
"Mask Crop Dominant Region",
|
"Mask Crop Dominant Region",
|
||||||
@ -588,6 +595,10 @@
|
|||||||
"https://github.com/YinBailiang/MergeBlockWeighted_fo_ComfyUI": [
|
"https://github.com/YinBailiang/MergeBlockWeighted_fo_ComfyUI": [
|
||||||
"MergeBlockWeighted"
|
"MergeBlockWeighted"
|
||||||
],
|
],
|
||||||
|
"https://github.com/ZaneA/ComfyUI-ImageReward": [
|
||||||
|
"ImageRewardLoader",
|
||||||
|
"ImageRewardScore"
|
||||||
|
],
|
||||||
"https://github.com/biegert/ComfyUI-CLIPSeg/raw/main/custom_nodes/clipseg.py": [
|
"https://github.com/biegert/ComfyUI-CLIPSeg/raw/main/custom_nodes/clipseg.py": [
|
||||||
"CLIPSeg",
|
"CLIPSeg",
|
||||||
"CombineSegMasks"
|
"CombineSegMasks"
|
||||||
@ -900,6 +911,7 @@
|
|||||||
"https://github.com/taabata/Comfy_Syrian_Falcon_Nodes/raw/main/SyrianFalconNodes.py": [
|
"https://github.com/taabata/Comfy_Syrian_Falcon_Nodes/raw/main/SyrianFalconNodes.py": [
|
||||||
"CompositeImage",
|
"CompositeImage",
|
||||||
"KSamplerAdvancedCustom",
|
"KSamplerAdvancedCustom",
|
||||||
|
"LoopBack",
|
||||||
"QRGenerate",
|
"QRGenerate",
|
||||||
"WordAsImage"
|
"WordAsImage"
|
||||||
],
|
],
|
||||||
|
|||||||
@ -14,6 +14,10 @@ def gitclone(custom_nodes_path, url):
|
|||||||
def gitcheck(path, do_fetch=False):
|
def gitcheck(path, do_fetch=False):
|
||||||
# Fetch the latest commits from the remote repository
|
# Fetch the latest commits from the remote repository
|
||||||
repo = git.Repo(path)
|
repo = git.Repo(path)
|
||||||
|
|
||||||
|
current_branch = repo.active_branch
|
||||||
|
branch_name = current_branch.name
|
||||||
|
|
||||||
remote_name = 'origin'
|
remote_name = 'origin'
|
||||||
remote = repo.remote(name=remote_name)
|
remote = repo.remote(name=remote_name)
|
||||||
|
|
||||||
@ -22,13 +26,13 @@ def gitcheck(path, do_fetch=False):
|
|||||||
|
|
||||||
# Get the current commit hash and the commit hash of the remote branch
|
# Get the current commit hash and the commit hash of the remote branch
|
||||||
commit_hash = repo.head.commit.hexsha
|
commit_hash = repo.head.commit.hexsha
|
||||||
remote_commit_hash = repo.refs[f'{remote_name}/HEAD'].object.hexsha
|
remote_commit_hash = repo.refs[f'{remote_name}/{branch_name}'].object.hexsha
|
||||||
|
|
||||||
# Compare the commit hashes to determine if the local repository is behind the remote repository
|
# Compare the commit hashes to determine if the local repository is behind the remote repository
|
||||||
if commit_hash != remote_commit_hash:
|
if commit_hash != remote_commit_hash:
|
||||||
# Get the commit dates
|
# Get the commit dates
|
||||||
commit_date = repo.head.commit.committed_datetime
|
commit_date = repo.head.commit.committed_datetime
|
||||||
remote_commit_date = repo.refs[f'{remote_name}/HEAD'].object.committed_datetime
|
remote_commit_date = repo.refs[f'{remote_name}/{branch_name}'].object.committed_datetime
|
||||||
|
|
||||||
# Compare the commit dates to determine if the local repository is behind the remote repository
|
# Compare the commit dates to determine if the local repository is behind the remote repository
|
||||||
if commit_date < remote_commit_date:
|
if commit_date < remote_commit_date:
|
||||||
|
|||||||
37
prestartup_script.py
Normal file
37
prestartup_script.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
script_list_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "startup-scripts", "install-scripts.txt")
|
||||||
|
|
||||||
|
# Check if script_list_path exists
|
||||||
|
if os.path.exists(script_list_path):
|
||||||
|
print("\n#######################################################################")
|
||||||
|
print("[ComfyUI-Manager] Starting dependency installation for the extension\n")
|
||||||
|
|
||||||
|
executed = set()
|
||||||
|
# Read each line from the file and convert it to a list using eval
|
||||||
|
with open(script_list_path, 'r') as file:
|
||||||
|
for line in file:
|
||||||
|
if line in executed:
|
||||||
|
continue
|
||||||
|
|
||||||
|
executed.add(line)
|
||||||
|
|
||||||
|
try:
|
||||||
|
script = eval(line)
|
||||||
|
print(f"\n## Install dependency for '{script[0]}'")
|
||||||
|
code = subprocess.run(script[1:], cwd=script[0])
|
||||||
|
|
||||||
|
if code.returncode != 0:
|
||||||
|
print(f"install script failed: {script[0]}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[ERROR] Failed to install: {line} / {e}")
|
||||||
|
|
||||||
|
|
||||||
|
# Remove the script_list_path file
|
||||||
|
if os.path.exists(script_list_path):
|
||||||
|
os.remove(script_list_path)
|
||||||
|
|
||||||
|
print("\n[ComfyUI-Manager] Dependency installation completed.")
|
||||||
|
print("#######################################################################\n")
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user