Changeset 07bfe2d2 for this_version.py
- Timestamp:
- Mar 23, 2017, 3:44:32 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:
- c6c20be
- Parents:
- c23d45f
- git-author:
- Martin Hermant <martin.hermant@gmail.com> (03/16/17 16:35:17)
- git-committer:
- Paul Brossier <piem@piem.org> (03/23/17 15:44:32)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
this_version.py
rc23d45f r07bfe2d2 4 4 5 5 __version_info = {} 6 6 7 7 8 def get_version_info(): … … 12 13 if not __version_info: 13 14 this_file_dir = os.path.dirname(os.path.abspath(__file__)) 14 version_file = os.path.join(this_file_dir, 15 version_file = os.path.join(this_file_dir, 'VERSION') 15 16 16 17 if not os.path.isfile(version_file): 17 18 raise SystemError("VERSION file not found.") 18 19 20 for l in open(version_file).readlines(): 19 21 20 for l in open(version_file).readlines(): 21 #exec (l.strip()) 22 if l.startswith('AUBIO_MAJOR_VERSION'): 23 __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1]) 24 if l.startswith('AUBIO_MINOR_VERSION'): 25 __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1]) 26 if l.startswith('AUBIO_PATCH_VERSION'): 27 __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1]) 28 if l.startswith('AUBIO_VERSION_STATUS'): 29 __version_info['AUBIO_VERSION_STATUS'] = l.split('=')[1].strip()[1:-1] 22 if l.startswith('AUBIO_MAJOR_VERSION'): 23 __version_info['AUBIO_MAJOR_VERSION'] = int(l.split('=')[1]) 24 if l.startswith('AUBIO_MINOR_VERSION'): 25 __version_info['AUBIO_MINOR_VERSION'] = int(l.split('=')[1]) 26 if l.startswith('AUBIO_PATCH_VERSION'): 27 __version_info['AUBIO_PATCH_VERSION'] = int(l.split('=')[1]) 28 if l.startswith('AUBIO_VERSION_STATUS'): 29 __version_info['AUBIO_VERSION_STATUS'] = \ 30 l.split('=')[1].strip()[1:-1] 30 31 31 if l.startswith('LIBAUBIO_LT_CUR'):32 __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1])33 if l.startswith('LIBAUBIO_LT_REV'):34 __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1])35 if l.startswith('LIBAUBIO_LT_AGE'):36 __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1])32 if l.startswith('LIBAUBIO_LT_CUR'): 33 __version_info['LIBAUBIO_LT_CUR'] = int(l.split('=')[1]) 34 if l.startswith('LIBAUBIO_LT_REV'): 35 __version_info['LIBAUBIO_LT_REV'] = int(l.split('=')[1]) 36 if l.startswith('LIBAUBIO_LT_AGE'): 37 __version_info['LIBAUBIO_LT_AGE'] = int(l.split('=')[1]) 37 38 38 if len(__version_info) < 6:39 if len(__version_info) < 6: 39 40 raise SystemError("Failed parsing VERSION file.") 40 41 41 42 42 # switch version status with commit sha in alpha releases 43 43 if __version_info['AUBIO_VERSION_STATUS'] and \ 44 '~alpha' in __version_info['AUBIO_VERSION_STATUS']:44 '~alpha' in __version_info['AUBIO_VERSION_STATUS']: 45 45 AUBIO_GIT_SHA = get_git_revision_hash() 46 46 if AUBIO_GIT_SHA: 47 __version_info['AUBIO_VERSION_STATUS'] = '~git'+AUBIO_GIT_SHA47 __version_info['AUBIO_VERSION_STATUS'] = '~git' + AUBIO_GIT_SHA 48 48 49 49 return __version_info … … 52 52 def get_aubio_version_tuple(): 53 53 d = get_version_info() 54 return (d['AUBIO_MAJOR_VERSION'],d['AUBIO_MINOR_VERSION'],d['AUBIO_PATCH_VERSION']) 54 return (d['AUBIO_MAJOR_VERSION'], 55 d['AUBIO_MINOR_VERSION'], 56 d['AUBIO_PATCH_VERSION']) 57 55 58 56 59 def get_libaubio_version_tuple(): 57 60 d = get_version_info() 58 return (d['LIBAUBIO_LT_CUR'],d['LIBAUBIO_LT_REV'],d['LIBAUBIO_LT_AGE']) 61 return (d['LIBAUBIO_LT_CUR'], d['LIBAUBIO_LT_REV'], d['LIBAUBIO_LT_AGE']) 62 59 63 60 64 def get_libaubio_version(): 61 return '%s.%s.%s' %get_libaubio_version_tuple()65 return '%s.%s.%s' % get_libaubio_version_tuple() 62 66 63 def get_aubio_version(add_status = True): 67 68 def get_aubio_version(add_status=True): 64 69 # return string formatted as MAJ.MIN.PATCH.{~git<sha> , ''} 65 70 vdict = get_version_info() 66 verstr = '%s.%s.%s' %get_aubio_version_tuple()71 verstr = '%s.%s.%s' % get_aubio_version_tuple() 67 72 if add_status and vdict['AUBIO_VERSION_STATUS']: 68 verstr += "." +vdict['AUBIO_VERSION_STATUS']73 verstr += "." + vdict['AUBIO_VERSION_STATUS'] 69 74 return verstr 70 75 71 def get_aubio_pyversion(add_status = True): 76 77 def get_aubio_pyversion(add_status=True): 72 78 # convert to version for python according to pep 440 73 79 # see https://www.python.org/dev/peps/pep-0440/ 74 80 # outputs MAJ.MIN.PATCH+a0{.git<sha> , ''} 75 81 vdict = get_version_info() 76 verstr = '%s.%s.%s'%get_aubio_version_tuple() 77 if add_status and vdict['AUBIO_VERSION_STATUS'] : 78 if '~git' in vdict['AUBIO_VERSION_STATUS']: 79 verstr += "+a0."+vdict['AUBIO_VERSION_STATUS'][1:] 80 elif '~alpha': 81 verstr += "+a0" 82 else: 83 raise SystemError("Aubio version statut not supported : %s"%vdict['AUBIO_VERSION_STATUS']) 82 verstr = '%s.%s.%s' % get_aubio_version_tuple() 83 if add_status and vdict['AUBIO_VERSION_STATUS']: 84 if '~git' in vdict['AUBIO_VERSION_STATUS']: 85 verstr += "+a0." + vdict['AUBIO_VERSION_STATUS'][1:] 86 elif '~alpha': 87 verstr += "+a0" 88 else: 89 raise SystemError("Aubio version statut not supported : %s" % 90 vdict['AUBIO_VERSION_STATUS']) 84 91 return verstr 85 92 86 93 87 88 def get_git_revision_hash( short=True): 94 def get_git_revision_hash(short=True): 89 95 90 96 if not os.path.isdir('.git'): … … 96 102 if not os.path.exists(aubio_dir): 97 103 raise SystemError("git / root folder not found") 98 gitcmd = ['git', '-C',aubio_dir ,'rev-parse']104 gitcmd = ['git', '-C', aubio_dir, 'rev-parse'] 99 105 if short: 100 106 gitcmd.append('--short') … … 103 109 outCmd = subprocess.check_output(gitcmd).strip().decode('utf8') 104 110 except Exception as e: 105 print ('git command error :%s'%e)111 print('git command error :%s' % e) 106 112 return None 107 113 return outCmd 108 109
Note: See TracChangeset
for help on using the changeset viewer.