forked from EESSI/test-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First try to get version from installed package. If packate is not in…
…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.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |