Skip to content

Commit

Permalink
First try to get version from installed package. If packate is not in…
Browse files Browse the repository at this point in the history
…stalled, try to get it from the git tree
  • Loading branch information
Caspar van Leeuwen committed Sep 19, 2024
1 parent 582b7b6 commit 97e60ab
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions eessi/testsuite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from importlib.metadata import version, PackageNotFoundError
try:
from setuptools_scm import get_version
# Using a relative path for relative_to doesn't work, because it will be relative to the current working
# directory (which could be anywhere)
# __file__ is the location of this init file (a full path), and this gives us a predictable path to the root
# (namely: two levels up)
# Note that if we ever move this __init__ file relative to the root of the git tree, we'll need to adjust this
__version__ = get_version(root='../..', relative_to=__file__)
except ImportError:
__version__ = "0.0.0" # fallback version if setuptools_scm is not available
__version__ = version("eessi-testsuite")
except PackageNotFoundError:
try:
from setuptools_scm import get_version
# Using a relative path for relative_to doesn't work, because it will be relative to the current working
# directory (which could be anywhere)
# __file__ is the location of this init file (a full path), and this gives us a predictable path to the root
# (namely: two levels up)
# Note that if we ever move this __init__ file relative to the root of the git tree, we'll need to adjust this
__version__ = get_version(root='../..', relative_to=__file__)
except ImportError:
__version__ = "0.0.0" # fallback version if setuptools_scm is not available

0 comments on commit 97e60ab

Please sign in to comment.