Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add pyproject.toml (#6386)

Chenlei Hu9c773a241b44
diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml
new file mode 100644
index 000000000..d9d488974
--- /dev/null
+++ b/.github/workflows/update-version.yml
@@ -0,0 +1,58 @@
+name: Update Version File
+
+on:
+ pull_request:
+ paths:
+ - "pyproject.toml"
+ branches:
+ - master
+
+jobs:
+ update-version:
+ runs-on: ubuntu-latest
+ # Don't run on fork PRs
+ if: github.event.pull_request.head.repo.full_name == github.repository
+ permissions:
+ pull-requests: write
+ contents: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Set up Python
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.11"
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+
+ - name: Update comfyui_version.py
+ run: |
+ # Read version from pyproject.toml and update comfyui_version.py
+ python -c '
+ import tomllib
+
+ # Read version from pyproject.toml
+ with open("pyproject.toml", "rb") as f:
+ config = tomllib.load(f)
+ version = config["project"]["version"]
+
+ # Write version to comfyui_version.py
+ with open("comfyui_version.py", "w") as f:
+ f.write("# This file is automatically generated by the build process when version is\n")
+ f.write("# updated in pyproject.toml.\n")
+ f.write(f"__version__ = \"{version}\"\n")
+ '
+
+ - name: Commit changes
+ run: |
+ git config --local user.name "github-actions"
+ git config --local user.email "[email protected]"
+ git fetch origin ${{ github.head_ref }}
+ git checkout -B ${{ github.head_ref }} origin/${{ github.head_ref }}
+ git add comfyui_version.py
+ git diff --quiet && git diff --staged --quiet || git commit -m "chore: Update comfyui_version.py to match pyproject.toml"
+ git push origin HEAD:${{ github.head_ref }}
diff --git a/comfyui_version.py b/comfyui_version.py
new file mode 100644
index 000000000..7cccc7535
--- /dev/null
+++ b/comfyui_version.py
@@ -0,0 +1,3 @@
+# This file is automatically generated by the build process when version is
+# updated in pyproject.toml.
+__version__ = "0.3.10"
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..1d9d7b3f0
--- /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/server.py b/server.py
index ceb5e83bb..bae898ef5 100644
--- a/server.py
+++ b/server.py
@@ -27,6 +27,7 @@ from comfy.cli_args import args
import comfy.utils
import comfy.model_management
import node_helpers
+from comfyui_version import __version__
from app.frontend_management import FrontendManager
from app.user_manager import UserManager
from app.model_manager import ModelFileManager
@@ -44,21 +45,6 @@ async def send_socket_catch_exception(function, message):
except (aiohttp.ClientError, aiohttp.ClientPayloadError, ConnectionResetError, BrokenPipeError, ConnectionError) as err:
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()
-
@web.middleware
async def cache_control(request: web.Request, handler):
response: web.Response = await handler(request)
@@ -518,7 +504,7 @@ class PromptServer():
"os": os.name,
"ram_total": ram_total,
"ram_free": ram_free,
- "comfyui_version": get_comfyui_version(),
+ "comfyui_version": __version__,
"python_version": sys.version,
"pytorch_version": comfy.model_management.torch_version,
"embedded_python": os.path.split(os.path.split(sys.executable)[0])[1] == "python_embeded",