mirror of
https://github.com/Comfy-Org/ComfyUI-Manager.git
synced 2025-12-16 18:02:58 +08:00
fixed: address abnormal encoding of 'requirements.txt'
improved: better error message https://github.com/ltdrdata/ComfyUI-Manager/issues/1513
This commit is contained in:
parent
661586d3b6
commit
60a5e4f261
@ -42,7 +42,7 @@ import manager_downloader
|
|||||||
from node_package import InstalledNodePackage
|
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 '')
|
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")
|
print("Install: pip packages")
|
||||||
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages())
|
pip_fixer = manager_util.PIPFixer(manager_util.get_installed_packages())
|
||||||
res = True
|
res = True
|
||||||
with open(requirements_path, "r") as requirements_file:
|
lines = manager_util.robust_readlines(requirements_path)
|
||||||
for line in requirements_file:
|
for line in lines:
|
||||||
package_name = remap_pip_package(line.strip())
|
package_name = remap_pip_package(line.strip())
|
||||||
if package_name and not package_name.startswith('#') and package_name not in self.processed_install:
|
if package_name and not package_name.startswith('#') and package_name not in self.processed_install:
|
||||||
self.processed_install.add(package_name)
|
self.processed_install.add(package_name)
|
||||||
install_cmd = manager_util.make_pip_cmd(["install", package_name])
|
install_cmd = manager_util.make_pip_cmd(["install", package_name])
|
||||||
if package_name.strip() != "" and not package_name.startswith('#'):
|
if package_name.strip() != "" and not package_name.startswith('#'):
|
||||||
res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
res = res and try_install_script(url, repo_path, install_cmd, instant_execution=instant_execution)
|
||||||
|
|
||||||
pip_fixer.fix_broken()
|
pip_fixer.fix_broken()
|
||||||
return res
|
return res
|
||||||
@ -1252,7 +1252,8 @@ class UnifiedManager:
|
|||||||
return result.fail(f"Failed to execute install script: {url}")
|
return result.fail(f"Failed to execute install script: {url}")
|
||||||
|
|
||||||
except Exception as e:
|
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.")
|
print("Installation was successful.")
|
||||||
return result
|
return result
|
||||||
@ -2048,8 +2049,8 @@ async def gitclone_install(url, instant_execution=False, msg_prefix='', no_deps=
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print(f"Install(git-clone) error: {url} / {e}", file=sys.stderr)
|
print(f"Install(git-clone) error[1]: {url} / {e}", file=sys.stderr)
|
||||||
return result.fail(f"Install(git-clone) error: {url} / {e}")
|
return result.fail(f"Install(git-clone)[1] error: {url} / {e}")
|
||||||
|
|
||||||
|
|
||||||
def git_pull(path):
|
def git_pull(path):
|
||||||
@ -2148,7 +2149,7 @@ def gitclone_fix(files, instant_execution=False, no_deps=False):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
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
|
return False
|
||||||
|
|
||||||
print(f"Attempt to fixing '{files}' is done.")
|
print(f"Attempt to fixing '{files}' is done.")
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
import chardet
|
||||||
|
|
||||||
|
|
||||||
cache_lock = threading.Lock()
|
cache_lock = threading.Lock()
|
||||||
@ -373,3 +374,22 @@ def sanitize(data):
|
|||||||
def sanitize_filename(input_string):
|
def sanitize_filename(input_string):
|
||||||
result_string = re.sub(r'[^a-zA-Z0-9_]', '_', input_string)
|
result_string = re.sub(r'[^a-zA-Z0-9_]', '_', input_string)
|
||||||
return result_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 []
|
||||||
|
|||||||
@ -598,17 +598,18 @@ def execute_lazy_install_script(repo_path, executable):
|
|||||||
|
|
||||||
if os.path.exists(requirements_path):
|
if os.path.exists(requirements_path):
|
||||||
print(f"Install: pip packages for '{repo_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:
|
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')
|
processed_install.add(f'{repo_path}/install.py')
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "comfyui-manager"
|
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."
|
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" }
|
license = { file = "LICENSE.txt" }
|
||||||
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions"]
|
||||||
|
|
||||||
|
|||||||
@ -8,3 +8,4 @@ rich
|
|||||||
typing-extensions
|
typing-extensions
|
||||||
toml
|
toml
|
||||||
uv
|
uv
|
||||||
|
chardet
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user