History

aubio version : aubio-c / aubio-py add git commit support

Martin Hermant committed 9 years ago

Commit 1eb8c0e1 parent 67b66184 files · +101 −6Browse files

Showing the changes to python (1 of 4 files). Show all

Unified · Split

python/lib/moresetuptools.py+48−3
@@ -31,7 +31,13 @@ def get_aubio_version(): · 30 unmodified lines
31 AUBIO_MINOR_VERSION,31 AUBIO_MINOR_VERSION,
32 AUBIO_PATCH_VERSION]))32 AUBIO_PATCH_VERSION]))
33 33
34 if AUBIO_VERSION_STATUS is not None:34 AUBIO_GIT_SHA = get_git_revision_hash()
35 """ append sha to version in alpha release
36 """
37 if '~alpha' in AUBIO_VERSION_STATUS :
38 if AUBIO_GIT_SHA:
39 AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA
40 if AUBIO_VERSION_STATUS is not None :
35 verstr += AUBIO_VERSION_STATUS41 verstr += AUBIO_VERSION_STATUS
36 return verstr42 return verstr
37 43
@@ -39,11 +45,50 @@ def get_aubio_pyversion(): · 1 unmodified line
39 # convert to version for python according to pep 44045 # convert to version for python according to pep 440
40 # see https://www.python.org/dev/peps/pep-0440/46 # see https://www.python.org/dev/peps/pep-0440/
41 verstr = get_aubio_version()47 verstr = get_aubio_version()
42 if '~alpha' in verstr:48 if '~alpha' in verstr or '~git' in verstr:
43 verstr = verstr.split('~')[0] + 'a1'49 verstr = verstr.split('~')[0] + '+a1'
50 gitsha = get_git_revision_hash(short=True)
51 if gitsha:
52 verstr+='.git.'+gitsha
44 # TODO: add rc, .dev, and .post suffixes, add numbering53 # TODO: add rc, .dev, and .post suffixes, add numbering
45 return verstr54 return verstr
46 55
56
57
58def get_git_revision_hash( short=True):
59 def which(program):
60
61 def is_exe(fpath):
62 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
63
64 fpath, fname = os.path.split(program)
65 if fpath:
66 if is_exe(program):
67 return program
68 else:
69 for path in os.environ["PATH"].split(os.pathsep):
70 path = path.strip('"')
71 exe_file = os.path.join(path, program)
72 if is_exe(exe_file):
73 return exe_file
74
75 return None
76 if not which('git'):
77 print 'no git found on this system : can\'t get sha'
78 return ""
79
80 import subprocess
81 this_file_dir = os.path.dirname(os.path.abspath(__file__))
82 aubio_dir = os.path.join(this_file_dir, '..', '..')
83 aubio_dir = os.path.abspath(aubio_dir)
84 if not os.path.exists(aubio_dir):
85 raise SystemError("git / root folder not found")
86 gitcmd = ['git','-C',aubio_dir ,'rev-parse']
87 if short:
88 gitcmd.append('--short')
89 gitcmd.append('HEAD')
90 return subprocess.check_output(gitcmd).strip()
91
47# inspired from https://gist.github.com/abergmeier/948899092# inspired from https://gist.github.com/abergmeier/9488990
48def add_packages(packages, ext=None, **kw):93def add_packages(packages, ext=None, **kw):
49 """ use pkg-config to search which of 'packages' are installed """94 """ use pkg-config to search which of 'packages' are installed """

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t