From e4ba360f342137e6449c6b0cbacfd2b106d8b474 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Tue, 18 Jun 2024 21:08:03 +0900 Subject: [PATCH] fix: Fix for the issue of pip version not upgrading https://github.com/ltdrdata/ComfyUI-Manager/issues/772 --- prestartup_script.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/prestartup_script.py b/prestartup_script.py index 2be36c80..22a0d082 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -429,7 +429,20 @@ def is_installed(name): print(f"[ComfyUI-Manager] skip black listed pip installation: '{name}'") return True - return name.lower() in get_installed_packages() + pkg = get_installed_packages().get(name.lower()) + if pkg is None: + return False # update if not installed + + if match is None: + return True # don't update if version is not specified + + if match.group(2) in ['>', '>=']: + if StrictVersion(pkg) < StrictVersion(match.group(3)): + return False + elif StrictVersion(pkg) > StrictVersion(match.group(3)): + print(f"[SKIP] Downgrading pip package isn't allowed: {name.lower()} (cur={pkg})") + + return True # prevent downgrade if os.path.exists(restore_snapshot_path):