From b6c70aabb6884e0f5f1a84a32dab83f15893661d Mon Sep 17 00:00:00 2001 From: Jim Garrison Date: Wed, 2 Sep 2026 12:53:40 -0400 Subject: [PATCH] Single-source the version from pyproject.toml The version was declared twice, in pyproject.toml and as a literal __version__ in python/__init__.py, so a release required editing both and either edit alone would leave the two disagreeing. Read it from the installed distribution metadata instead, leaving the [project] table in pyproject.toml as the single declaration. The alternative direction -- pyproject.toml declaring `dynamic = ["version"]` and reading `attr = "sbd.__version__"` -- was not taken. It relies on setuptools statically AST-parsing the assignment, and if setuptools ever falls back to importing the package it would import it before the extension modules are built, since this __init__ loads the _core_* backends at import time. --- python/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/__init__.py b/python/__init__.py index 9373b6a..824f0a4 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -29,8 +29,12 @@ import os import subprocess +from importlib.metadata import version -__version__ = "1.6.1" +# Single-sourced from the [project] table in pyproject.toml, so the version is +# declared in exactly one place. Note the argument is the *distribution* name +# ("sbd-eigensolver"), not the import name ("sbd"). +__version__ = version("sbd-eigensolver") # --------------------------------------------------------------------------- # Backend registry — eagerly load all available backends at import time.