Skip to content

Commit

Permalink
Fix version when package is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
jordap authored and koomie committed Jul 8, 2024
1 parent e805b20 commit 23f78d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion omnistat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 23f78d3

Please sign in to comment.