From 166debfabbec0605b15ed671f5851e8369d98972 Mon Sep 17 00:00:00 2001 From: "Dr.Lt.Data" Date: Mon, 19 May 2025 05:13:40 +0900 Subject: [PATCH] modified: In Python 3.13, the functionality to forcibly downgrade the `numpy` version below 3.13 is disabled. - Starting from Python 3.13, prebuilt wheels for `numpy` 1.26.4 are no longer provided. https://github.com/comfyanonymous/ComfyUI/discussions/8187 --- cm-cli.py | 10 ++++++++-- glob/manager_core.py | 2 +- glob/manager_util.py | 30 +++++++++++++++++------------- prestartup_script.py | 10 ++++++++-- pyproject.toml | 2 +- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/cm-cli.py b/cm-cli.py index 11d1f868..116f99ed 100644 --- a/cm-cli.py +++ b/cm-cli.py @@ -45,7 +45,11 @@ comfyui_manager_path = os.path.abspath(os.path.dirname(__file__)) cm_global.pip_blacklist = {'torch', 'torchaudio', 'torchsde', 'torchvision'} cm_global.pip_downgrade_blacklist = ['torch', 'torchaudio', 'torchsde', 'torchvision', 'transformers', 'safetensors', 'kornia'] -cm_global.pip_overrides = {'numpy': 'numpy<2'} + +if sys.version_info < (3, 13): + cm_global.pip_overrides = {'numpy': 'numpy<2'} +else: + cm_global.pip_overrides = {} if os.path.exists(os.path.join(manager_util.comfyui_manager_path, "pip_overrides.json")): with open(os.path.join(manager_util.comfyui_manager_path, "pip_overrides.json"), 'r', encoding="UTF-8", errors="ignore") as json_file: @@ -147,7 +151,9 @@ class Ctx: if os.path.exists(core.manager_pip_overrides_path): with open(core.manager_pip_overrides_path, 'r', encoding="UTF-8", errors="ignore") as json_file: cm_global.pip_overrides = json.load(json_file) - cm_global.pip_overrides = {'numpy': 'numpy<2'} + + if sys.version_info < (3, 13): + cm_global.pip_overrides = {'numpy': 'numpy<2'} if os.path.exists(core.manager_pip_blacklist_path): with open(core.manager_pip_blacklist_path, 'r', encoding="UTF-8", errors="ignore") as f: diff --git a/glob/manager_core.py b/glob/manager_core.py index 41906a6f..f436fd0e 100644 --- a/glob/manager_core.py +++ b/glob/manager_core.py @@ -43,7 +43,7 @@ import manager_downloader from node_package import InstalledNodePackage -version_code = [3, 32, 2] +version_code = [3, 32, 3] version_str = f"V{version_code[0]}.{version_code[1]}" + (f'.{version_code[2]}' if len(version_code) > 2 else '') diff --git a/glob/manager_util.py b/glob/manager_util.py index 2cc13bac..3c0754b0 100644 --- a/glob/manager_util.py +++ b/glob/manager_util.py @@ -412,8 +412,9 @@ class PIPFixer: if len(targets) > 0: for x in targets: - cmd = make_pip_cmd(['install', f"{x}=={versions[0].version_string}", "numpy<2"]) - subprocess.check_output(cmd, universal_newlines=True) + if sys.version_info < (3, 13): + cmd = make_pip_cmd(['install', f"{x}=={versions[0].version_string}", "numpy<2"]) + subprocess.check_output(cmd, universal_newlines=True) logging.info(f"[ComfyUI-Manager] 'opencv' dependencies were fixed: {targets}") except Exception as e: @@ -421,18 +422,21 @@ class PIPFixer: logging.error(e) # fix numpy - try: - np = new_pip_versions.get('numpy') - if cm_global.pip_overrides.get('numpy') == 'numpy<2': - if np is not None: - if StrictVersion(np) >= StrictVersion('2'): - cmd = make_pip_cmd(['install', "numpy<2"]) - subprocess.check_output(cmd , universal_newlines=True) + if sys.version_info >= (3, 13): + logging.info("[ComfyUI-Manager] In Python 3.13 and above, PIP Fixer does not downgrade `numpy` below version 2.0. If you need to force a downgrade of `numpy`, please use `pip_auto_fix.list`.") + else: + try: + np = new_pip_versions.get('numpy') + if cm_global.pip_overrides.get('numpy') == 'numpy<2': + if np is not None: + if StrictVersion(np) >= StrictVersion('2'): + cmd = make_pip_cmd(['install', "numpy<2"]) + subprocess.check_output(cmd , universal_newlines=True) - logging.info("[ComfyUI-Manager] 'numpy' dependency were fixed") - except Exception as e: - logging.error("[ComfyUI-Manager] Failed to restore numpy") - logging.error(e) + logging.info("[ComfyUI-Manager] 'numpy' dependency were fixed") + except Exception as e: + logging.error("[ComfyUI-Manager] Failed to restore numpy") + logging.error(e) # fix missing frontend try: diff --git a/prestartup_script.py b/prestartup_script.py index c03d3ac1..08eb6e13 100644 --- a/prestartup_script.py +++ b/prestartup_script.py @@ -121,11 +121,17 @@ read_config() read_uv_mode() check_file_logging() -cm_global.pip_overrides = {'numpy': 'numpy<2'} +if sys.version_info < (3, 13): + cm_global.pip_overrides = {'numpy': 'numpy<2'} +else: + cm_global.pip_overrides = {} + if os.path.exists(manager_pip_overrides_path): with open(manager_pip_overrides_path, 'r', encoding="UTF-8", errors="ignore") as json_file: cm_global.pip_overrides = json.load(json_file) - cm_global.pip_overrides['numpy'] = 'numpy<2' + + if sys.version_info < (3, 13): + cm_global.pip_overrides['numpy'] = 'numpy<2' if os.path.exists(manager_pip_blacklist_path): diff --git a/pyproject.toml b/pyproject.toml index 62ad9037..f871ab43 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.32.2" +version = "3.32.3" license = { file = "LICENSE.txt" } dependencies = ["GitPython", "PyGithub", "matrix-client==0.4.0", "transformers", "huggingface-hub>0.20", "typer", "rich", "typing-extensions", "toml", "uv", "chardet"]