mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-17 02:12:58 +08:00
improve: pip handling
- prevent downgrade `torch, torchsde, torchvision, transformers, safetensors, kornia`
This commit is contained in:
parent
0dfa84b368
commit
d829220973
33
__init__.py
33
__init__.py
@ -29,7 +29,7 @@ except:
|
|||||||
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
|
print(f"[WARN] ComfyUI-Manager: Your ComfyUI version is outdated. Please update to the latest version.")
|
||||||
|
|
||||||
|
|
||||||
version = [2, 9]
|
version = [2, 10]
|
||||||
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')
|
||||||
print(f"### Loading: ComfyUI-Manager ({version_str})")
|
print(f"### Loading: ComfyUI-Manager ({version_str})")
|
||||||
|
|
||||||
@ -39,6 +39,22 @@ comfy_ui_hash = "-"
|
|||||||
cache_lock = threading.Lock()
|
cache_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
def is_blacklisted(name):
|
||||||
|
name = name.strip()
|
||||||
|
|
||||||
|
pattern = r'([^<>!=]+)([<>!=]=?)'
|
||||||
|
match = re.search(pattern, name)
|
||||||
|
|
||||||
|
if match:
|
||||||
|
name = match.group(1)
|
||||||
|
|
||||||
|
if name in cm_global.pip_downgrade_blacklist:
|
||||||
|
if match is None or match.group(2) in ['<=', '==', '<']:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def handle_stream(stream, prefix):
|
def handle_stream(stream, prefix):
|
||||||
stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace')
|
stream.reconfigure(encoding=locale.getpreferredencoding(), errors='replace')
|
||||||
for msg in stream:
|
for msg in stream:
|
||||||
@ -286,6 +302,12 @@ def try_install_script(url, repo_path, install_cmd):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
if len(install_cmd) == 5 and install_cmd[2:4] == ['pip', 'install']:
|
||||||
|
if is_blacklisted(install_cmd[4]):
|
||||||
|
print(f"[ComfyUI-Manager] skip black listed pip installation: '{install_cmd[4]}'")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
print(f"\n## ComfyUI-Manager: EXECUTE => {install_cmd}")
|
print(f"\n## ComfyUI-Manager: EXECUTE => {install_cmd}")
|
||||||
code = run_script(install_cmd, cwd=repo_path)
|
code = run_script(install_cmd, cwd=repo_path)
|
||||||
|
|
||||||
@ -525,16 +547,17 @@ def git_pull(path):
|
|||||||
else:
|
else:
|
||||||
repo = git.Repo(path)
|
repo = git.Repo(path)
|
||||||
|
|
||||||
print(f"path={path} / repo.is_dirty: {repo.is_dirty()}")
|
|
||||||
|
|
||||||
if repo.is_dirty():
|
if repo.is_dirty():
|
||||||
repo.git.stash()
|
repo.git.stash()
|
||||||
|
|
||||||
if repo.head.is_detached:
|
if repo.head.is_detached:
|
||||||
switch_to_default_branch(repo)
|
switch_to_default_branch(repo)
|
||||||
|
|
||||||
origin = repo.remote(name='origin')
|
current_branch = repo.active_branch
|
||||||
origin.pull()
|
remote_name = current_branch.tracking_branch().remote_name
|
||||||
|
remote = repo.remote(name=remote_name)
|
||||||
|
|
||||||
|
remote.pull()
|
||||||
repo.git.submodule('update', '--init', '--recursive')
|
repo.git.submodule('update', '--init', '--recursive')
|
||||||
|
|
||||||
repo.close()
|
repo.close()
|
||||||
|
|||||||
@ -15,6 +15,9 @@ sys.path.append(glob_path)
|
|||||||
import cm_global
|
import cm_global
|
||||||
|
|
||||||
|
|
||||||
|
cm_global.pip_downgrade_blacklist = ['torch', 'torchsde', 'torchvision', 'transformers', 'safetensors', 'kornia']
|
||||||
|
|
||||||
|
|
||||||
def skip_pip_spam(x):
|
def skip_pip_spam(x):
|
||||||
return 'Requirement already satisfied:' in x
|
return 'Requirement already satisfied:' in x
|
||||||
|
|
||||||
@ -350,7 +353,12 @@ def is_installed(name):
|
|||||||
|
|
||||||
if match:
|
if match:
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
|
|
||||||
|
if name in cm_global.pip_downgrade_blacklist:
|
||||||
|
if match is None or match.group(2) in ['<=', '==', '<']:
|
||||||
|
print(f"[ComfyUI-Manager] skip black listed pip installation: '{name}'")
|
||||||
|
return True
|
||||||
|
|
||||||
return name.lower() in get_installed_packages()
|
return name.lower() in get_installed_packages()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user