diff --git a/omnistat/utils.py b/omnistat/utils.py index cb600ab2..cca70395 100644 --- a/omnistat/utils.py +++ b/omnistat/utils.py @@ -263,7 +263,14 @@ def removeQuotes(input): def getVersion(): """Return omnistat version info""" - return version('omnistat') + try: + return version('omnistat') + except importlib.metadata.PackageNotFoundError: + # When package is not installed, rely on setuptools-git-versioning + # to figure out the version; use the executable because the internal + # API is not guaranteed to remain compatible. + result = runShellCommand("setuptools-git-versioning") + return result.stdout.strip() def displayVersion(version): diff --git a/requirements.txt b/requirements.txt index 468f7ee8..7bf509e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ prometheus_client>=0.17.0 gunicorn>=21.2.0 packaging>=24.1 parallel-ssh>=2.12.0 +setuptools-git-versioning>=2.0,<3