From 8ef035bd7c1ac5781d8cf5f563e6994379fed689 Mon Sep 17 00:00:00 2001 From: ndjama Date: Mon, 8 Jun 2026 23:52:53 +0200 Subject: [PATCH] fix: derive __version__ from package metadata codegraph/__init__.py hardcoded __version__ separately from pyproject.toml, so the 0.5.0 release shipped with a 0.4.6 banner (only pyproject was bumped, and the release workflow checks the tag against pyproject only). Read the version from importlib.metadata so pyproject.toml is the single source of truth and the two can never drift again; fall back to a source sentinel when no installed metadata is present. --- codegraph/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/codegraph/__init__.py b/codegraph/__init__.py index 361322f..ad3beb2 100644 --- a/codegraph/__init__.py +++ b/codegraph/__init__.py @@ -1,3 +1,11 @@ """codegraph, Local code graph index for AI coding assistants.""" -__version__ = "0.4.6" +from importlib.metadata import PackageNotFoundError, version + +try: + # Single source of truth: the installed package version (pyproject.toml). + # Avoids the banner drifting from the real version on a release bump. + __version__ = version("cgh") +except PackageNotFoundError: + # Running from a source tree with no installed metadata. + __version__ = "0.0.0+source"