summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2022-11-21 14:13:14 -0600
committerGitHub <noreply@github.com>2022-11-21 13:13:14 -0700
commit47174014c09e454b452c234a118756e981f95a01 (patch)
treecabefafcc8068aae6e9cf2af0f51228cc73d93bc /setup.py
parent5c1bd34e36dbce6b378e8c59d8bd105e285ddb33 (diff)
downloadcloud-init-git-47174014c09e454b452c234a118756e981f95a01.tar.gz
Update read-version
Use 'git describe <branch>' as the version number, even if the version differs from what is in version.py. This means that if the most recent commit is a tag, we'll get the tag number, otherwise we'll also show the number of commits since the last tag on the branch. Fix setup.py to align with PEP 440 versioning replacing trailing hyphen beyond major.minor.patch-g<HASH> with a "+". Additionally, did some cleanup and typing fixes on the script.
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/setup.py b/setup.py
index 470dd774..04aae5b2 100644
--- a/setup.py
+++ b/setup.py
@@ -73,7 +73,13 @@ def in_virtualenv():
def get_version():
cmd = [sys.executable, "tools/read-version"]
ver = subprocess.check_output(cmd)
- return ver.decode("utf-8").strip()
+ version = ver.decode("utf-8").strip()
+ # read-version can spit out something like 22.4-15-g7f97aee24
+ # which is invalid under PEP440. If we replace the first - with a +
+ # that should give us a valid version.
+ if "-" in version:
+ version = version.replace("-", "+", 1)
+ return version
def read_requires():