From 28b33a3f1caea5c2056403a64517fb5eee664618 Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 7 Jan 2025 16:56:37 -0500 Subject: [PATCH 1/2] Add pyproject.toml --- pyproject.toml | 11 +++++++++++ requirements.txt | 1 + server.py | 17 ++++------------- 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..1d9d7b3f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,11 @@ +[project] +name = "ComfyUI" +version = "0.3.10" +readme = "README.md" +license = { file = "LICENSE" } +requires-python = ">=3.9" + +[project.urls] +homepage = "https://www.comfy.org/" +repository = "https://github.com/comfyanonymous/ComfyUI" +documentation = "https://docs.comfy.org/" diff --git a/requirements.txt b/requirements.txt index 4c2c0b2b..d8745105 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,6 +13,7 @@ Pillow scipy tqdm psutil +toml #non essential dependencies: kornia>=0.7.1 diff --git a/server.py b/server.py index ceb5e83b..14cd7ddc 100644 --- a/server.py +++ b/server.py @@ -20,6 +20,7 @@ from io import BytesIO import aiohttp from aiohttp import web +import toml import logging import mimetypes @@ -45,19 +46,9 @@ async def send_socket_catch_exception(function, message): logging.warning("send error: {}".format(err)) def get_comfyui_version(): - comfyui_version = "unknown" - repo_path = os.path.dirname(os.path.realpath(__file__)) - try: - import pygit2 - repo = pygit2.Repository(repo_path) - comfyui_version = repo.describe(describe_strategy=pygit2.GIT_DESCRIBE_TAGS) - except Exception: - try: - import subprocess - comfyui_version = subprocess.check_output(["git", "describe", "--tags"], cwd=repo_path).decode('utf-8') - except Exception as e: - logging.warning(f"Failed to get ComfyUI version: {e}") - return comfyui_version.strip() + """ Get the version of ComfyUI from the pyproject.toml file. """ + with open("pyproject.toml", "r", encoding="utf-8") as f: + return toml.load(f)["project"]["version"] @web.middleware async def cache_control(request: web.Request, handler): From 672200e087d0b9e3c41b61762e661acb538e0fff Mon Sep 17 00:00:00 2001 From: huchenlei Date: Tue, 7 Jan 2025 21:56:33 -0500 Subject: [PATCH 2/2] doc --- server.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 14cd7ddc..ccbea28d 100644 --- a/server.py +++ b/server.py @@ -46,7 +46,11 @@ async def send_socket_catch_exception(function, message): logging.warning("send error: {}".format(err)) def get_comfyui_version(): - """ Get the version of ComfyUI from the pyproject.toml file. """ + """ Get the version of ComfyUI from the pyproject.toml file. + + Note: + Use Python's built-in `tomllib` from Python 3.11 or later when available. + """ with open("pyproject.toml", "r", encoding="utf-8") as f: return toml.load(f)["project"]["version"]