From 9653c0e3cbc3d3e95f33335ee7494f93f19111cd Mon Sep 17 00:00:00 2001 From: Markus Holzer <markus.holzer@fau.de> Date: Tue, 26 Jan 2021 09:12:34 +0100 Subject: [PATCH] Added version String to lbmpy --- .gitignore | 1 + lbmpy/__init__.py | 10 ++++++++++ lbmpy_tests/test_version_string.py | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 lbmpy_tests/test_version_string.py diff --git a/.gitignore b/.gitignore index 0fd1e869..895cc7ab 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ _local_tmp /lbmpy_tests/db doc/bibtex.json /html_doc +RELEASE-VERSION diff --git a/lbmpy/__init__.py b/lbmpy/__init__.py index e69de29b..8e4c54f2 100644 --- a/lbmpy/__init__.py +++ b/lbmpy/__init__.py @@ -0,0 +1,10 @@ +def _get_release_file(): + import os.path + file_path = os.path.abspath(os.path.dirname(__file__)) + return os.path.join(file_path, '..', 'RELEASE-VERSION') + + +try: + __version__ = open(_get_release_file(), 'r').read() +except IOError: + __version__ = 'development' diff --git a/lbmpy_tests/test_version_string.py b/lbmpy_tests/test_version_string.py new file mode 100644 index 00000000..b1c0b28f --- /dev/null +++ b/lbmpy_tests/test_version_string.py @@ -0,0 +1,12 @@ +import pystencils as ps +from pathlib import Path + +def test_version_string(): + file_path = Path(__file__).parent + release_version = file_path.parent.absolute() / 'RELEASE-VERSION' + if release_version.exists (): + with open(release_version, "r") as f: + version = f.read() + assert ps.__version__ == version + else: + assert ps.__version__ == "development" -- GitLab