Skip to content

Commit

Permalink
Make version-discovery more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed Apr 25, 2024
1 parent 0fbeb47 commit 066b3b1
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/argus/site/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,21 @@ class MetadataView(APIView):
)
def get(self, request, format=None):
try:
from argus.version import __version__
except (ModuleNotFoundError, ImportError):
import pkg_resources
# Run from source-dir
import argus.version

__version__ = pkg_resources.get_distribution("argus-server").version
__version__ = argus.version.version
except (AttributeError, ModuleNotFoundError, ImportError):
# Installed from package
try:
from importlib.metadata import version

__version__ = version("wheel")
except ImportError:
# Python < 3.8
import pkg_resources

__version__ = pkg_resources.get_distribution("argus-server").version

metadata = {
"server-version": __version__,
Expand Down

0 comments on commit 066b3b1

Please sign in to comment.