From 1ce26583d5349829aa590622a420557371cc5c45 Mon Sep 17 00:00:00 2001 From: DavidMoserAI Date: Sun, 22 Feb 2026 12:43:04 +0100 Subject: [PATCH] Fix __version__ to read from package metadata instead of hardcoded string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `comfy_kitchen.__version__` has been reporting "0.1.0" since the first release, regardless of the actual installed version. This is because the version string was hardcoded in two places: - `comfy_kitchen/__init__.py` (line 19): `__version__ = "0.1.0"` - `dlpack_bindings.cpp` (line 557): `m.attr("__version__") = "0.1.0";` Neither was ever updated during version bumps — every bump commit (0.2.0 through 0.2.7) only modified `pyproject.toml`. This causes real confusion in production environments. For example, when debugging CUDA backend issues, runtime version checks like `comfy_kitchen.__version__` report "0.1.0" even though pip metadata correctly shows 0.2.7, making it appear that an old/broken version is installed. Fix: - Replace the hardcoded `__version__` in `__init__.py` with `importlib.metadata.version("comfy-kitchen")`, which reads from the package metadata set by `pyproject.toml` — the single source of truth. Includes a `PackageNotFoundError` fallback for editable/dev installs. - Remove the hardcoded `__version__` from the C++ nanobind module (`dlpack_bindings.cpp`), since the Python-level `__version__` is the canonical source and nobody accesses `_C.__version__` directly. Co-Authored-By: Claude Opus 4.6 --- comfy_kitchen/__init__.py | 7 ++++++- comfy_kitchen/backends/cuda/dlpack_bindings.cpp | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/comfy_kitchen/__init__.py b/comfy_kitchen/__init__.py index 55c611ad..0467b51c 100644 --- a/comfy_kitchen/__init__.py +++ b/comfy_kitchen/__init__.py @@ -16,7 +16,12 @@ # Import registry and exceptions from .registry import registry -__version__ = "0.1.0" +try: + from importlib.metadata import version, PackageNotFoundError + + __version__ = version("comfy-kitchen") +except PackageNotFoundError: + __version__ = "0.0.0" # Fallback for editable/dev installs __all__ = [ # Exceptions diff --git a/comfy_kitchen/backends/cuda/dlpack_bindings.cpp b/comfy_kitchen/backends/cuda/dlpack_bindings.cpp index 12ac4b40..fa9a9d4a 100644 --- a/comfy_kitchen/backends/cuda/dlpack_bindings.cpp +++ b/comfy_kitchen/backends/cuda/dlpack_bindings.cpp @@ -553,8 +553,6 @@ NB_MODULE(_C, m) { // Feature availability flag (computed at module load time) m.attr("HAS_CUBLASLT") = comfy::CublasLtRuntime::instance().is_available(); - // Add version info - m.attr("__version__") = "0.1.0"; m.attr("__nanobind__") = true; m.attr("__stable_abi__") = true; }