From 133873de3b9c67d526bad14b427cf8b9f47c10eb Mon Sep 17 00:00:00 2001 From: Eduard Kerkhoven Date: Fri, 6 Nov 2026 15:05:48 +0100 Subject: [PATCH] Define geckopy.__version__ geckopy.__version__ is the installed version of geckopy, as raven_toolbox.__version__ is for raven-toolbox. It is 0.0.0+unknown when geckopy runs from a source tree without an installation. --- CHANGELOG.md | 1 + src/geckopy/__init__.py | 7 +++++++ tests/test_version.py | 8 ++++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/test_version.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 617eaf4..101d82d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +* `geckopy.__version__` is the installed version of geckopy. * `cma` is a required dependency of geckopy and the extra `evotune` is removed. `import geckopy` imports `cma`. * `enzyme_usage` reports `measured_protein`, `demanded_protein` and `demand_ratio`, the usage of the enzymes with a measured concentration divided by their measured concentrations, and the same restricted to enzymes with a usage above 1e-7 mg/gDCW (`measured_protein_active`, `demand_ratio_active`). `report_enzyme_usage` carries `demand_ratio` and `demand_ratio_active`. GECKO's `getEnzymeUsage` and `reportEnzymeUsage` give the same values. * geckopy is licensed under the GNU General Public License v3 (GPL-3.0), as RAVEN and raven-toolbox. `LICENSE`, the `license` field and the classifier of `pyproject.toml`, and the README state it. Releases up to 4.0.0b2 were published under the MIT licence. diff --git a/src/geckopy/__init__.py b/src/geckopy/__init__.py index 1c7c3d4..14ccf82 100644 --- a/src/geckopy/__init__.py +++ b/src/geckopy/__init__.py @@ -31,6 +31,13 @@ live in raven-toolbox, see ``raven_toolbox.io.ec_data``) - **Per-enzyme proxy**: ``Enzyme`` (lazy view via ``model.enzymes``) """ +from importlib.metadata import PackageNotFoundError, version + +try: + __version__ = version("geckopy") +except PackageNotFoundError: # running from a source tree without an install + __version__ = "0.0.0+unknown" + # Adapter from geckopy.adapter import ModelAdapter, ModelParameters diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 0000000..a3929d5 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,8 @@ +"""geckopy.__version__ is the installed version of the package.""" +from importlib.metadata import version + +import geckopy + + +def test_version_is_the_installed_version(): + assert geckopy.__version__ == version("geckopy")