From 4cece8eacd44e1690b9a75efc546eb8cbc82045c Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Mon, 14 Sep 2026 18:28:54 +0100 Subject: [PATCH] Read the package version from installed metadata __init__.py carried a hardcoded 1.1.2 while pyproject.toml was at 3.1.1, two major versions apart, because the version bump script only updates pyproject.toml. Reading from importlib.metadata means there is one source of truth and the two cannot drift again. Co-Authored-By: Claude Opus 5 (1M context) --- changelog.d/version-from-metadata.fixed.md | 1 + microimpute/__init__.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog.d/version-from-metadata.fixed.md diff --git a/changelog.d/version-from-metadata.fixed.md b/changelog.d/version-from-metadata.fixed.md new file mode 100644 index 00000000..a9a36fd8 --- /dev/null +++ b/changelog.d/version-from-metadata.fixed.md @@ -0,0 +1 @@ +- Fixed `microimpute.__version__` reporting 1.1.2 while the package was at 3.1.1, by reading the version from installed package metadata. diff --git a/microimpute/__init__.py b/microimpute/__init__.py index 2667c7ef..14cf862e 100644 --- a/microimpute/__init__.py +++ b/microimpute/__init__.py @@ -19,7 +19,12 @@ - Visualization: performance and comparison plots """ -__version__ = "1.1.2" +try: # Python 3.8+ + from importlib.metadata import PackageNotFoundError, version as _version + + __version__ = _version("microimpute") +except PackageNotFoundError: # running from a source tree without an install + __version__ = "unknown" # Import automated imputation from microimpute.comparisons.autoimpute import AutoImputeResult, autoimpute