diff --git a/glob/manager_core.py b/glob/manager_core.py index d38f5e0f..a4293cd0 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -42,7 +42,7 @@ import manager_downloader from node_package import InstalledNodePackage -version_code = [3, 21, 3] +version_code = [3, 21, 4] version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') @@ -815,14 +815,14 @@ class UnifiedManager: print("Install: pip packages") pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages()) res = True - with open(requirements_path, "r") as requirements_file: - for line in requirements_file: - package_name = remap_pip_package(line.strip()) - if package_name and not package_name.startswith('#') and package_name not in self.processed_install: - self.processed_install.add(package_name) - install_cmd = manager_util.make_pip_cmd(["install", package_name]) - if package_name.strip() != "" and not package_name.startswith('#'): - res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution) + lines = manager_util.robust_readlines(requirements_path) + for line in lines: + package_name = remap_pip_package(line.strip()) + if package_name and not package_name.startswith('#') and package_name not in self.processed_install: + self.processed_install.add(package_name) + install_cmd = manager_util.make_pip_cmd(["install", package_name]) + if package_name.strip() != "" and not package_name.startswith('#'): + res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution) pip_fixer.fix_broken() return res @@ -1252,7 +1252,8 @@ class UnifiedManager: return result.fail(f"Failed to execute install script: {url}") except Exception as e: - return result.fail(f"Install(git-clone) error: {url} / {e}") + traceback.print_exc() + return result.fail(f"Install(git-clone) error[2]: {url} / {e}") print("Installation was successful.") return result @@ -2048,8 +2049,8 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps= except Exception as e: traceback.print_exc() - print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr) - return result.fail(f"Install(git-clone) error: {url} / {e}") + print(f"Install(git-clone) error[1]: {url} / {e}", file=sys.stderr) + return result.fail(f"Install(git-clone)[1] error: {url} / {e}") def git_pull(path): @@ -2148,7 +2149,7 @@ def gitclone_fix(files, instant_execution=False, no_deps=False): return False except Exception as e: - print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr) + print(f"Fix(git-clone) error: {url} / {e}", file=sys.stderr) return False print(f"Attempt to fixing '{files}' is done.") diff --git a/glob/manager_util.py b/glob/manager_util.py index b613dfad..beb5a292 100644 --- a/glob/manager_util.py +++ b/glob/manager_util.py @@ -12,6 +12,7 @@ import subprocess import sys import re import logging +import chardet cache_lock = threading.Lock() @@ -373,3 +374,22 @@ def sanitize(data): def sanitize_filename(input_string): result_string = re.sub(r'[^a-zA-Z0-9_]', '_', input_string) return result_string + + +def robust_readlines(fullpath): + try: + with open(fullpath, "r") as f: + return f.readlines() + except: + encoding = None + with open(fullpath, "rb") as f: + raw_data = f.read() + result = chardet.detect(raw_data) + encoding = result['encoding'] + + if encoding is not None: + with open(fullpath, "r", encoding=encoding) as f: + return f.readlines() + + print(f"[ComfyUI-Manager] Failed to recognize encoding for: {fullpath}") + return [] diff --git a/prestartup_script.py b/prestartup_script.py index 41a1c085..6748559c 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -598,17 +598,18 @@ def execute_lazy_install_script(repo_path, executable): if os.path.exists(requirements_path): print(f"Install: pip packages for '{repo_path}'") - with open(requirements_path, "r") as requirements_file: - for line in requirements_file: - package_name = remap_pip_package(line.strip()) - if package_name and not is_installed(package_name): - if '--index-url' in package_name: - s = package_name.split('--index-url') - install_cmd = manager_util.make_pip_cmd(["install", s[0].strip(), '--index-url', s[1].strip()]) - else: - install_cmd = manager_util.make_pip_cmd(["install", package_name]) - process_wrap(install_cmd, repo_path) + lines = manager_util.robust_readlines(requirements_path) + for line in lines: + package_name = remap_pip_package(line.strip()) + if package_name and not is_installed(package_name): + if '--index-url' in package_name: + s = package_name.split('--index-url') + install_cmd = manager_util.make_pip_cmd(["install", s[0].strip(), '--index-url', s[1].strip()]) + else: + install_cmd = manager_util.make_pip_cmd(["install", package_name]) + + process_wrap(install_cmd, repo_path) if os.path.exists(install_script_path) and f'{repo_path}/install.py' not in processed_install: processed_install.add(f'{repo_path}/install.py') diff --git a/pyproject.toml b/pyproject.toml index 2811db5f..1fb1507f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = "3.21.3" +version = "3.21.4" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"] diff --git a/requirements.txt b/requirements.txt index 6a6fcf92..38724e16 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ rich typing-extensions toml uv +chardet