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 Aug 12, 2021
1 parent fef4304 commit 259a55e
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 @@ -104,11 +104,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 259a55e

Please sign in to comment.