aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/versions.py
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-07 13:03:38 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-08 19:08:36 +0200
commit9ab39cd31422636b4678bcea2363f178a7e298d7 (patch)
tree8e106ca6bfff856d97f82477202666fa83b78355 /src/hydrilla/versions.py
parent6b4de4125e0552292087f443a61518c433981465 (diff)
downloadhaketilo-hydrilla-9ab39cd31422636b4678bcea2363f178a7e298d7.tar.gz
haketilo-hydrilla-9ab39cd31422636b4678bcea2363f178a7e298d7.zip
[builder][server][proxy] make current Haketilo version available to our code as a tuple of integers
Diffstat (limited to 'src/hydrilla/versions.py')
-rw-r--r--src/hydrilla/versions.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/hydrilla/versions.py b/src/hydrilla/versions.py
index dcebaa2..065ccca 100644
--- a/src/hydrilla/versions.py
+++ b/src/hydrilla/versions.py
@@ -35,6 +35,11 @@ from __future__ import annotations
import typing as t
+from itertools import takewhile
+
+from . import _version
+
+
VerTuple = t.NewType('VerTuple', 'tuple[int, ...]')
def normalize(ver: t.Sequence[int]) -> VerTuple:
@@ -66,3 +71,8 @@ def version_string(ver: VerTuple, rev: t.Optional[int] = None) -> str:
1.2.3-5
"""
return '.'.join(str(n) for n in ver) + ('' if rev is None else f'-{rev}')
+
+haketilo_version = normalize(tuple(takewhile(
+ lambda i: isinstance(i, int),
+ _version.version_tuple # type: ignore
+)))