this_version.py: build a valid pep440 version string
authorPaul Brossier <piem@piem.org>
Thu, 23 Mar 2017 17:03:22 +0000 (18:03 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 23 Mar 2017 17:03:22 +0000 (18:03 +0100)
this_version.py

index 797ff4e..d78c878 100644 (file)
@@ -76,14 +76,15 @@ def get_aubio_version(add_status=True):
 def get_aubio_pyversion(add_status=True):
     # convert to version for python according to pep 440
     # see https://www.python.org/dev/peps/pep-0440/
-    # outputs MAJ.MIN.PATCH+a0{.git<sha> , ''}
+    # outputs MAJ.MIN.PATCH[a0[+git.<sha>[.mods]]]
     vdict = get_version_info()
     verstr = '%s.%s.%s' % get_aubio_version_tuple()
     if add_status and vdict['AUBIO_VERSION_STATUS']:
-        if '~git' in vdict['AUBIO_VERSION_STATUS']:
-            verstr += "+a0." + vdict['AUBIO_VERSION_STATUS'][1:]
+        if vdict['AUBIO_VERSION_STATUS'].startswith('~git+'):
+            pep440str = vdict['AUBIO_VERSION_STATUS'].replace('+', '.')
+            verstr += pep440str.replace('~git.', 'a0+')
         elif '~alpha' in vdict['AUBIO_VERSION_STATUS']:
-            verstr += "+a0"
+            verstr += "a0"
         else:
             raise SystemError("Aubio version statut not supported : %s" %
                               vdict['AUBIO_VERSION_STATUS'])