-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Today ramalama just share version 0.5.5 (as example) but don't tell users and developer which commit it's using. Resolves: #754 Signed-off-by: Douglas Schilling Landgraf <[email protected]>
- Loading branch information
Showing
2 changed files
with
35 additions
and
14 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
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,16 +1,15 @@ | ||
import importlib.metadata | ||
|
||
"""Version of RamaLamaPy.""" | ||
import os | ||
|
||
CONFIG_DIR = os.path.expanduser("~/.config/ramalama") | ||
VERSION_FILE = os.path.join(CONFIG_DIR, "version") | ||
|
||
def version(): | ||
try: | ||
return importlib.metadata.version("ramalama") | ||
except importlib.metadata.PackageNotFoundError: | ||
return "0" | ||
|
||
return "0" | ||
|
||
|
||
def print_version(args): | ||
print("ramalama version %s" % version()) | ||
"""Reads the version from ~/.config/ramalama/version.""" | ||
if os.path.exists(VERSION_FILE): | ||
with open(VERSION_FILE, "r") as f: | ||
return f.read().strip() | ||
return f"cannot be detected, see if exists {VERSION_FILE}" | ||
|
||
def print_version(args=None): | ||
"""Prints the current version of the package.""" | ||
print(f"ramalama version {version()}") |