From c7cdc9344d9ab9d74cb52eb6227dbe024df0be66 Mon Sep 17 00:00:00 2001 From: Jorn Bruggeman Date: Wed, 3 Jan 2024 11:29:11 +0000 Subject: [PATCH] pyfabm: added __version__ attribute --- .github/workflows/fabm.yml | 2 +- src/pyfabm/__init__.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fabm.yml b/.github/workflows/fabm.yml index 7014c3d7..23eb7a36 100644 --- a/.github/workflows/fabm.yml +++ b/.github/workflows/fabm.yml @@ -227,7 +227,7 @@ jobs: run: python -m pip install . - name: Test run: | - python -c "import pyfabm" + python -c "import pyfabm;print('pyfabm version =', getattr(pyfabm, '__version__', None))" for f in testcases/*.yaml; do fabm_describe_model $f; done for f in testcases/*.yaml; do fabm_complete_yaml --add_missing $f; done fabm0d: diff --git a/src/pyfabm/__init__.py b/src/pyfabm/__init__.py index 73720aec..bc4d875d 100644 --- a/src/pyfabm/__init__.py +++ b/src/pyfabm/__init__.py @@ -15,6 +15,13 @@ Sequence, ) +try: + import importlib.metadata + + __version__ = importlib.metadata.version("pyfabm") +except ImportError: + pass + try: import numpy as np except ImportError: