Bypass ComfyUI version check when in electron env (#1303)

* Hacky: hide the features we do not want to ship with electron app

* Backup

* Take install path for cm-cli.

* Remove unused.

* Add no deps.

* Add no deps.

* Bypass ComfyUI version check when in electron env

* Fix exception when comfyui is not repo

* Fix version reporting always skipped

* Log unhandled errors

---------

Co-authored-by: Yoland Y <4950057+yoland68@users.noreply.github.com>
Co-authored-by: Robin Huang <robin.j.huang@gmail.com>
This commit is contained in:
filtered
2024-12-11 05:02:58 +11:00
committed by GitHub
parent 7f63e753d4
commit 6f1bfae957
4 changed files with 51 additions and 255 deletions

View File

@@ -53,8 +53,8 @@ def get_custom_nodes_paths():
def get_comfyui_tag():
repo = git.Repo(comfy_path)
try:
repo = git.Repo(comfy_path)
return repo.git.describe('--tags')
except:
return None
@@ -82,6 +82,7 @@ comfy_ui_required_commit_datetime = datetime(2024, 1, 24, 0, 0, 0)
comfy_ui_revision = "Unknown"
comfy_ui_commit_datetime = datetime(1900, 1, 1, 0, 0, 0)
is_electron = os.environ.get("ORIGINAL_XDG_CURRENT_DESKTOP") != None
cache_lock = threading.Lock()
@@ -432,7 +433,7 @@ def __win_check_git_pull(path):
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")
requirements_path = os.path.join(repo_path, "requirements.txt")
@@ -440,7 +441,7 @@ def execute_install_script(url, repo_path, lazy_mode=False, instant_execution=Fa
install_cmd = ["#LAZY-INSTALL-SCRIPT", sys.executable]
try_install_script(url, repo_path, install_cmd)
else:
if os.path.exists(requirements_path):
if os.path.exists(requirements_path) and not no_deps:
print("Install: pip packages")
pip_fixer = PIPFixer(get_installed_packages())
with open(requirements_path, "r") as requirements_file:
@@ -584,7 +585,7 @@ def is_valid_url(url):
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}")
for url in files:
if not is_valid_url(url):
@@ -594,9 +595,9 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''):
if url.endswith("/"):
url = url[:-1]
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_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
if not instant_execution and platform.system() == 'Windows':
@@ -608,7 +609,7 @@ def gitclone_install(files, instant_execution=False, msg_prefix=''):
repo.git.clear_cache()
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
except Exception as e:

View File

@@ -11,6 +11,8 @@ import threading
import re
import shutil
import git
import datetime
import logging
from server import PromptServer
import manager_core as core
@@ -1219,12 +1221,14 @@ async def get_notice(request):
markdown_content = add_target_blank(markdown_content)
try:
if core.comfy_ui_commit_datetime == datetime(1900, 1, 1, 0, 0, 0):
if core.is_electron:
pass
elif core.comfy_ui_commit_datetime == datetime.datetime(1900, 1, 1, 0, 0, 0):
markdown_content = f'<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI isn\'t git repo.</P>' + markdown_content
elif core.comfy_ui_required_commit_datetime.date() > core.comfy_ui_commit_datetime.date():
markdown_content = f'<P style="text-align: center; color:red; background-color:white; font-weight:bold">Your ComfyUI is too OUTDATED!!!</P>' + markdown_content
except:
pass
except Exception as error:
logging.warning("Unexpected error when checking ComfyUI version via git.")
return web.Response(text=markdown_content, status=200)
else: