Replies: 4 comments 2 replies
-
I've been trying to figure out a reliable way to determine the version without manually updating |
Beta Was this translation helpful? Give feedback.
-
hows this look ? its untested - will try soon. - Im a python beginner, so will make some beginner mistakes for a while # -*- mode: python -*- # Copyright 2023 Andrea Righi """virtme-ng version""" import subprocess def get_version_string(): try: # Run the `git describe` command and strip the leading 'v' version_output = subprocess.check_output(['git', 'describe'], universal_newlines=True).strip() return version_output[1:] except subprocess.CalledProcessError: # Git repository not found, return an empty string return "" MAN_VERSION = "1.17" GIT_VERSION = get_version_string() # maintainer check for leading match on 2 versions if GIT_VERSION.startswith(MAN_VERSION): version_string = GIT_VERSION[len(MAN_VERSION):].replace('-', '+') print("Using Git version:", version_string) else: print("Git version mismatch:", GIT_VERSION) VERSION = GIT_VERSION or MAN_VERSION if __name__ == '__main__': print(VERSION) |
Beta Was this translation helpful? Give feedback.
-
hi Andrea, have you thought any more about versioning ? python versioning, ala PEP440, disallows direct use of heres the error Im seeing atm, I think with the version I sent previously.
so that approach is out. and and google gemini tells me that PEP440 doesnt allow any extensions, but setting a different accessory version isnt crazy. is there a way to run git describe at pip install ? |
Beta Was this translation helpful? Give feedback.
-
this patch gives me a legal version,
[jimc@frodo virtme-ng]$ vng -V
virtme-ng 1.17+v1.17-14-ga19857a
its arguably a bit noisy, but it could also be more deeply flawed
(whats it do when there is no repo, and could that even matter?)
so its an idea for now..
[jimc@frodo virtme-ng]$ git diff
diff --git a/virtme_ng/version.py b/virtme_ng/version.py
index fb930bc..d7a88a1 100644
--- a/virtme_ng/version.py
+++ b/virtme_ng/version.py
@@ -3,7 +3,10 @@
"""virtme-ng version"""
-VERSION = "1.17"
+import subprocess
+
+VERSION = "1.17+" + subprocess.check_output(
if name == 'main':
print(VERSION)
Beta Was this translation helpful? Give feedback.
All reactions