Changeset 255fe0a
- Timestamp:
- Mar 23, 2017, 6:29:30 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler
- Children:
- 8da4d59
- Parents:
- f7b7a35
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
this_version.py
rf7b7a35 r255fe0a 1 1 #! python 2 2 import os 3 3 4 5 __version_info = {} 6 4 __version_info = {} # keep a reference to parse VERSION once 7 5 8 6 def get_version_info(): 9 7 # read from VERSION 10 8 # return dictionary filled with content of version 11 12 9 if not __version_info: 13 10 this_file_dir = os.path.dirname(os.path.abspath(__file__)) … … 18 15 19 16 for l in open(version_file).readlines(): 20 21 17 if l.startswith('AUBIO_MAJOR_VERSION'): 22 18 __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1]) … … 48 44 return __version_info 49 45 46 def get_libaubio_version(): 47 verfmt = '%(LIBAUBIO_LT_CUR)s.%(LIBAUBIO_LT_REV)s.%(LIBAUBIO_LT_AGE)s' 48 return str(verfmt % get_version_info()) 50 49 51 def get_aubio_version_tuple(): 52 d = get_version_info() 53 return (d['AUBIO_MAJOR_VERSION'], 54 d['AUBIO_MINOR_VERSION'], 55 d['AUBIO_PATCH_VERSION']) 50 def get_aubio_version(): 51 verfmt = '%(AUBIO_MAJOR_VERSION)s.%(AUBIO_MINOR_VERSION)s.%(AUBIO_PATCH_VERSION)s%(AUBIO_VERSION_STATUS)s' 52 return str(verfmt % get_version_info()) 56 53 57 58 def get_libaubio_version_tuple(): 59 d = get_version_info() 60 return (d['LIBAUBIO_LT_CUR'], d['LIBAUBIO_LT_REV'], d['LIBAUBIO_LT_AGE']) 61 62 63 def get_libaubio_version(): 64 return '%s.%s.%s' % get_libaubio_version_tuple() 65 66 67 def get_aubio_version(add_status=True): 68 # return string formatted as MAJ.MIN.PATCH{~git<sha> , ''} 69 vdict = get_version_info() 70 verstr = '%s.%s.%s' % get_aubio_version_tuple() 71 if add_status and vdict['AUBIO_VERSION_STATUS']: 72 verstr += vdict['AUBIO_VERSION_STATUS'] 73 return str(verstr) 74 75 76 def get_aubio_pyversion(add_status=True): 54 def get_aubio_pyversion(): 77 55 # convert to version for python according to pep 440 78 56 # see https://www.python.org/dev/peps/pep-0440/ 79 57 # outputs MAJ.MIN.PATCH[a0[+git.<sha>[.mods]]] 80 vdict = get_version_info() 81 verstr = '%s.%s.%s' % get_aubio_version_tuple() 82 if add_status and vdict['AUBIO_VERSION_STATUS']: 83 if vdict['AUBIO_VERSION_STATUS'].startswith('~git+'): 84 pep440str = vdict['AUBIO_VERSION_STATUS'].replace('+', '.') 85 verstr += pep440str.replace('~git.', 'a0+') 86 elif '~alpha' in vdict['AUBIO_VERSION_STATUS']: 87 verstr += "a0" 88 else: 89 raise SystemError("Aubio version statut not supported : %s" % 90 vdict['AUBIO_VERSION_STATUS']) 58 aubio_version = get_aubio_version() 59 if '~git+' in aubio_version: 60 pep440str = aubio_version.replace('+', '.') 61 verstr = pep440str.replace('~git.', 'a0+') 62 elif '~alpha' in aubio_version: 63 verstr += "a0" 91 64 return verstr 92 65 93 94 66 def get_git_revision_hash(short=True): 95 67 # get commit id, with +mods if local tree is not clean 96 68 if not os.path.isdir('.git'): 97 69 # print('Version : not in git repository : can\'t get sha') 98 70 return None 99 100 71 import subprocess 101 72 aubio_dir = os.path.dirname(os.path.abspath(__file__)) … … 111 82 print('git command error :%s' % e) 112 83 return None 113 114 84 # check if we have a clean tree 115 85 gitcmd = ['git', '-C', aubio_dir, 'diff-index', '--quiet'] … … 120 90 gitsha += '+mods' 121 91 return gitsha 92 93 if __name__ == '__main__': 94 print ('%30s'% 'aubio version:', get_aubio_version()) 95 print ('%30s'% 'python-aubio version:', get_aubio_pyversion())
Note: See TracChangeset
for help on using the changeset viewer.