From 6e69e89905e9b47111c4954649fdba10615b1478 Mon Sep 17 00:00:00 2001 From: elioxue Date: Fri, 5 Jun 2026 09:14:55 +0800 Subject: [PATCH 1/2] fix(core): read version from package metadata instead of hardcoding The CLI `--version` was reading from a hardcoded __version__ string in __init__.py, which was never updated when bumping pyproject.toml versions. This caused `codemap --version` to show stale version numbers after install. Switch to importlib.metadata.version() so the runtime version always matches the installed package metadata (single source of truth: pyproject.toml). --- src/codemap/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/codemap/__init__.py b/src/codemap/__init__.py index 1045127..0e7da7c 100644 --- a/src/codemap/__init__.py +++ b/src/codemap/__init__.py @@ -2,6 +2,12 @@ from __future__ import annotations -__version__ = "0.1.0" +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("codemap-core") +except PackageNotFoundError: + # Fallback for running from source without installing + __version__ = "0.0.0.dev0" __all__ = ["__version__"] From 8d4c96829d4c0398efb5d94be8e41608468da1c0 Mon Sep 17 00:00:00 2001 From: elioxue Date: Fri, 5 Jun 2026 09:19:52 +0800 Subject: [PATCH 2/2] fix: sort imports to satisfy ruff isort --- src/codemap/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codemap/__init__.py b/src/codemap/__init__.py index 0e7da7c..287e48b 100644 --- a/src/codemap/__init__.py +++ b/src/codemap/__init__.py @@ -2,7 +2,7 @@ from __future__ import annotations -from importlib.metadata import version, PackageNotFoundError +from importlib.metadata import PackageNotFoundError, version try: __version__ = version("codemap-core")