From 282debcc942bb9e06f2d2ab3b043d88f3298b723 Mon Sep 17 00:00:00 2001 From: Leonid Lunin Date: Wed, 27 May 2026 14:38:35 +0200 Subject: [PATCH] Add __version__ variable for python library (#308) [PEP 396](https://peps.python.org/pep-0396/) --------- Co-authored-by: AliceMazzoleni99 --- python/CMakeLists.txt | 1 + python/aare/__init__.py | 1 + python/aare/_version.py | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 python/aare/_version.py diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 6d3ff60..4cb6d17 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -34,6 +34,7 @@ target_include_directories( # List of python files to be copied to the build directory set(PYTHON_FILES aare/__init__.py + aare/_version.py aare/CtbRawFile.py aare/ClusterFinder.py aare/ClusterVector.py diff --git a/python/aare/__init__.py b/python/aare/__init__.py index f4bddda..3e4e64d 100644 --- a/python/aare/__init__.py +++ b/python/aare/__init__.py @@ -13,6 +13,7 @@ from ._aare import corner # from ._aare import ClusterFinderMT, ClusterCollector, ClusterFileSink, ClusterVector_i +from ._version import __version__ from .ClusterFinder import ClusterFinder, ClusterCollector, ClusterFinderMT, ClusterFileSink, ClusterFile from .ClusterVector import ClusterVector from .Cluster import Cluster diff --git a/python/aare/_version.py b/python/aare/_version.py new file mode 100644 index 0000000..d8e2b01 --- /dev/null +++ b/python/aare/_version.py @@ -0,0 +1,8 @@ +# This file is used to get the version of the package from the VERSION file +from importlib.metadata import PackageNotFoundError, version +from pathlib import Path + +try: + __version__ = version('aare') +except PackageNotFoundError: + __version__ = Path(__file__).parents[2].joinpath('VERSION').read_text().strip() \ No newline at end of file