diff --git a/.gitignore b/.gitignore index 0fd1e86926f3a1e3df68a6071f6824f28a2ff422..895cc7ab27515c2648bc85c7180faec3b6abbe9e 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8e4c54f2d057e440fee491193210d25e427b181b 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 0000000000000000000000000000000000000000..b1c0b28fc823475ee45b605d96a61421b8ad5dfb --- /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"