3 for l in open('VERSION').readlines(): exec (l.strip())
5 # def get_git_revision_hash( short=True):
9 # return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
11 # fpath, fname = os.path.split(program)
16 # for path in os.environ["PATH"].split(os.pathsep):
17 # path = path.strip('"')
18 # exe_file = os.path.join(path, program)
19 # if is_exe(exe_file):
23 # if not which('git') :
24 # # print('no git found on this system : can\'t get sha')
26 # if not os.path.isdir('.git'):
27 # # print('Version : not in git repository : can\'t get sha')
31 # aubio_dir = os.path.abspath(os.curdir)
32 # if not os.path.exists(aubio_dir):
33 # raise SystemError("git / root folder not found")
34 # gitcmd = ['git','-C',aubio_dir ,'rev-parse']
36 # gitcmd.append('--short')
37 # gitcmd.append('HEAD')
38 # outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
42 def get_aubio_version():
44 this_file_dir = os.path.dirname(os.path.abspath(__file__))
45 version_file = os.path.join(this_file_dir, 'VERSION')
47 if not os.path.isfile(version_file):
48 raise SystemError("VERSION file not found.")
50 for l in open(version_file).readlines():
52 if l.startswith('AUBIO_MAJOR_VERSION'):
53 AUBIO_MAJOR_VERSION = int(l.split('=')[1])
54 if l.startswith('AUBIO_MINOR_VERSION'):
55 AUBIO_MINOR_VERSION = int(l.split('=')[1])
56 if l.startswith('AUBIO_PATCH_VERSION'):
57 AUBIO_PATCH_VERSION = int(l.split('=')[1])
58 if l.startswith('AUBIO_VERSION_STATUS'):
59 AUBIO_VERSION_STATUS = l.split('=')[1].strip()[1:-1]
61 if AUBIO_MAJOR_VERSION is None or AUBIO_MINOR_VERSION is None \
62 or AUBIO_PATCH_VERSION is None:
63 raise SystemError("Failed parsing VERSION file.")
65 verstr = '.'.join(map(str, [AUBIO_MAJOR_VERSION,
67 AUBIO_PATCH_VERSION]))
70 # append sha to version in alpha release
71 # MAJ.MIN.PATCH.{~git<sha> , ''}
72 if '~alpha' in AUBIO_VERSION_STATUS :
73 AUBIO_GIT_SHA = get_git_revision_hash()
75 AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA
77 if AUBIO_VERSION_STATUS is not None :
78 verstr += AUBIO_VERSION_STATUS
81 def get_aubio_pyversion():
82 # convert to version for python according to pep 440
83 # see https://www.python.org/dev/peps/pep-0440/
84 verstr = get_aubio_version()
85 spl = verstr.split('~')
87 verstr = spl[0] + '+a1.'+spl[1]
89 # TODO: add rc, .dev, and .post suffixes, add numbering
94 def get_git_revision_hash( short=True):
98 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
100 fpath, fname = os.path.split(program)
105 for path in os.environ["PATH"].split(os.pathsep):
106 path = path.strip('"')
107 exe_file = os.path.join(path, program)
113 if not which('git') :
114 # print('no git found on this system : can\'t get sha')
116 if not os.path.isdir('.git'):
117 # print('Version : not in git repository : can\'t get sha')
121 aubio_dir = os.path.dirname(os.path.abspath(__file__))
122 if not os.path.exists(aubio_dir):
123 raise SystemError("git / root folder not found")
124 gitcmd = ['git','-C',aubio_dir ,'rev-parse']
126 gitcmd.append('--short')
127 gitcmd.append('HEAD')
128 outCmd = subprocess.check_output(gitcmd).strip().decode('utf8')
133 # append sha to version in alpha release
134 if AUBIO_VERSION_STATUS and '~alpha' in AUBIO_VERSION_STATUS :
135 AUBIO_GIT_SHA = get_git_revision_hash()
137 AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA