Skip to content

Commit

Permalink
fix: invalid version handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ltdrdata committed Aug 13, 2024
1 parent 74bf39a commit d95b974
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 66 deletions.
4 changes: 2 additions & 2 deletions glob/manager_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import cm_global
from manager_util import *

version = [2, 48, 6]
version = [2, 48, 7]
version_str = f"V{version[0]}.{version[1]}" + (f'.{version[2]}' if len(version) > 2 else '')


Expand Down Expand Up @@ -123,7 +123,7 @@ def is_installed(name):
if name.startswith('#'):
return True

pattern = r'([^<>!=]+)([<>!=]=?)([^ ]*)'
pattern = r'([^<>!=]+)([<>!=]=?)([0-9.a-zA-Z]*)'
match = re.search(pattern, name)

if match:
Expand Down
125 changes: 63 additions & 62 deletions glob/manager_util.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
try:
from distutils.version import StrictVersion
except:
print(f"[ComfyUI-Manager] 'distutils' package not found. Activating fallback mode for compatibility.")
class StrictVersion:
def __init__(self, version_string):
self.version_string = version_string
self.major = 0
self.minor = 0
self.patch = 0
self.pre_release = None
self.parse_version_string()

def parse_version_string(self):
parts = self.version_string.split('.')
if not parts:
raise ValueError("Version string must not be empty")

self.major = int(parts[0])
self.minor = int(parts[1]) if len(parts) > 1 else 0
self.patch = int(parts[2]) if len(parts) > 2 else 0

# Handling pre-release versions if present
if len(parts) > 3:
self.pre_release = parts[3]

def __str__(self):
version = f"{self.major}.{self.minor}.{self.patch}"
if self.pre_release:
version += f"-{self.pre_release}"
return version

def __eq__(self, other):
return (self.major, self.minor, self.patch, self.pre_release) == \
(other.major, other.minor, other.patch, other.pre_release)

def __lt__(self, other):
if (self.major, self.minor, self.patch) == (other.major, other.minor, other.patch):
return self.pre_release_compare(self.pre_release, other.pre_release) < 0
return (self.major, self.minor, self.patch) < (other.major, other.minor, other.patch)

@staticmethod
def pre_release_compare(pre1, pre2):
if pre1 == pre2:
return 0
if pre1 is None:
return 1
if pre2 is None:
return -1
return -1 if pre1 < pre2 else 1

def __le__(self, other):
return self == other or self < other

def __gt__(self, other):
return not self <= other

def __ge__(self, other):
return not self < other

def __ne__(self, other):
return not self == other
# DON'T USE StrictVersion - cannot handle pre_release version
# try:
# from distutils.version import StrictVersion
# except:
print(f"[ComfyUI-Manager] 'distutils' package not found. Activating fallback mode for compatibility.")
class StrictVersion:
def __init__(self, version_string):
self.version_string = version_string
self.major = 0
self.minor = 0
self.patch = 0
self.pre_release = None
self.parse_version_string()

def parse_version_string(self):
parts = self.version_string.split('.')
if not parts:
raise ValueError("Version string must not be empty")

self.major = int(parts[0])
self.minor = int(parts[1]) if len(parts) > 1 else 0
self.patch = int(parts[2]) if len(parts) > 2 else 0

# Handling pre-release versions if present
if len(parts) > 3:
self.pre_release = parts[3]

def __str__(self):
version = f"{self.major}.{self.minor}.{self.patch}"
if self.pre_release:
version += f"-{self.pre_release}"
return version

def __eq__(self, other):
return (self.major, self.minor, self.patch, self.pre_release) == \
(other.major, other.minor, other.patch, other.pre_release)

def __lt__(self, other):
if (self.major, self.minor, self.patch) == (other.major, other.minor, other.patch):
return self.pre_release_compare(self.pre_release, other.pre_release) < 0
return (self.major, self.minor, self.patch) < (other.major, other.minor, other.patch)

@staticmethod
def pre_release_compare(pre1, pre2):
if pre1 == pre2:
return 0
if pre1 is None:
return 1
if pre2 is None:
return -1
return -1 if pre1 < pre2 else 1

def __le__(self, other):
return self == other or self < other

def __gt__(self, other):
return not self <= other

def __ge__(self, other):
return not self < other

def __ne__(self, other):
return not self == other

2 changes: 1 addition & 1 deletion prestartup_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def is_installed(name):
if name.startswith('#'):
return True

pattern = r'([^<>!=]+)([<>!=]=?)([^ ]*)'
pattern = r'([^<>!=]+)([<>!=]=?)([0-9.a-zA-Z]*)'
match = re.search(pattern, name)

if match:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
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."
version = "2.48.6"
version = "2.48.7"
license = { file = "LICENSE.txt" }
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]

Expand Down

0 comments on commit d95b974

Please sign in to comment.