Index: python/lib/moresetuptools.py
===================================================================
--- python/lib/moresetuptools.py	(revision 67b66184a3c5ac1bc2d2bc837bc5b1f192f10b15)
+++ python/lib/moresetuptools.py	(revision 1eb8c0eccce9e1aef6ab34c734ec92d2d72bffff)
@@ -32,5 +32,11 @@
                                      AUBIO_PATCH_VERSION]))
 
-    if AUBIO_VERSION_STATUS is not None:
+    AUBIO_GIT_SHA = get_git_revision_hash()
+    """ append sha to version in alpha release
+    """
+    if '~alpha' in AUBIO_VERSION_STATUS :
+        if AUBIO_GIT_SHA:
+            AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA
+    if AUBIO_VERSION_STATUS is not None :
         verstr += AUBIO_VERSION_STATUS
     return verstr
@@ -40,8 +46,47 @@
     # see https://www.python.org/dev/peps/pep-0440/
     verstr = get_aubio_version()
-    if '~alpha' in verstr:
-        verstr = verstr.split('~')[0] + 'a1'
+    if '~alpha' in verstr or '~git' in verstr:
+        verstr = verstr.split('~')[0] + '+a1'
+        gitsha = get_git_revision_hash(short=True)
+        if gitsha:
+            verstr+='.git.'+gitsha
     # TODO: add rc, .dev, and .post suffixes, add numbering
     return verstr
+
+
+
+def get_git_revision_hash( short=True):
+    def which(program):
+    
+        def is_exe(fpath):
+            return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+        fpath, fname = os.path.split(program)
+        if fpath:
+            if is_exe(program):
+                return program
+        else:
+            for path in os.environ["PATH"].split(os.pathsep):
+                path = path.strip('"')
+                exe_file = os.path.join(path, program)
+                if is_exe(exe_file):
+                    return exe_file
+
+        return None
+    if not which('git'):
+        print 'no git found on this system : can\'t get sha'
+        return ""
+
+    import subprocess
+    this_file_dir = os.path.dirname(os.path.abspath(__file__))
+    aubio_dir = os.path.join(this_file_dir, '..', '..')
+    aubio_dir = os.path.abspath(aubio_dir)
+    if not os.path.exists(aubio_dir):
+        raise SystemError("git / root folder not found")
+    gitcmd = ['git','-C',aubio_dir ,'rev-parse']
+    if short:
+      gitcmd.append('--short')
+    gitcmd.append('HEAD')
+    return subprocess.check_output(gitcmd).strip()
 
 # inspired from https://gist.github.com/abergmeier/9488990
Index: setup.py
===================================================================
--- setup.py	(revision 67b66184a3c5ac1bc2d2bc837bc5b1f192f10b15)
+++ setup.py	(revision 1eb8c0eccce9e1aef6ab34c734ec92d2d72bffff)
@@ -7,5 +7,6 @@
 from python.lib.gen_external import generate_external, header, output_path
 
-__version__ = get_aubio_pyversion()
+__version__ = get_aubio_version()
+__pip_version__ = get_aubio_pyversion()
 
 include_dirs = []
@@ -55,5 +56,5 @@
 
 distrib = setup(name='aubio',
-    version = __version__,
+    version = __pip_version__,
     packages = ['aubio'],
     package_dir = {'aubio':'python/lib/aubio'},
Index: src/wscript_build
===================================================================
--- src/wscript_build	(revision 67b66184a3c5ac1bc2d2bc837bc5b1f192f10b15)
+++ src/wscript_build	(revision 1eb8c0eccce9e1aef6ab34c734ec92d2d72bffff)
@@ -47,4 +47,4 @@
 # install headers, except _priv.h ones
 ctx.install_files('${INCLUDEDIR}/aubio/',
-        ctx.path.ant_glob('**/*.h', excl = ['**_priv.h', 'config.h']),
+        ctx.path.ant_glob('**/*.h', excl = ['**_priv.h']),
         relative_trick=True)
Index: wscript
===================================================================
--- wscript	(revision 67b66184a3c5ac1bc2d2bc837bc5b1f192f10b15)
+++ wscript	(revision 1eb8c0eccce9e1aef6ab34c734ec92d2d72bffff)
@@ -17,4 +17,47 @@
 # source VERSION
 for l in open('VERSION').readlines(): exec (l.strip())
+
+def get_git_revision_hash( short=True):
+    import os
+    def which(program):
+        def is_exe(fpath):
+            return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+        fpath, fname = os.path.split(program)
+        if fpath:
+            if is_exe(program):
+                return program
+        else:
+            for path in os.environ["PATH"].split(os.pathsep):
+                path = path.strip('"')
+                exe_file = os.path.join(path, program)
+                if is_exe(exe_file):
+                    return exe_file
+
+        return None
+        
+    if not which('git'):
+        print 'no git found on this system : can\'t get sha'
+        return ""
+
+    import subprocess
+    aubio_dir = os.path.abspath(os.curdir)
+    if not os.path.exists(aubio_dir):
+        raise SystemError("git / root folder not found")
+    gitcmd = ['git','-C',aubio_dir ,'rev-parse']
+    if short:
+      gitcmd.append('--short')
+    gitcmd.append('HEAD')
+    return subprocess.check_output(gitcmd).strip()
+
+AUBIO_GIT_SHA = get_git_revision_hash()
+""" append sha to version in alpha release
+"""
+if '~alpha' in AUBIO_VERSION_STATUS :
+    if AUBIO_GIT_SHA:
+        AUBIO_VERSION_STATUS = '~git'+AUBIO_GIT_SHA
+
+
+
 
 VERSION = '.'.join ([str(x) for x in [
@@ -132,4 +175,10 @@
     ctx.env['DEST_OS'] = target_platform
 
+    ctx.define('AUBIO_VERSION',VERSION)
+    ctx.define('AUBIO_MAJOR_VERSION',AUBIO_MAJOR_VERSION)
+    ctx.define('AUBIO_MINOR_VERSION',AUBIO_MINOR_VERSION)
+    ctx.define('AUBIO_PATCH_VERSION',AUBIO_PATCH_VERSION)
+    ctx.define('AUBIO_VERSION_STATUS',AUBIO_VERSION_STATUS)
+    ctx.define('AUBIO_GIT_SHA',AUBIO_GIT_SHA)
     if ctx.options.build_type == "debug":
         ctx.define('DEBUG', 1)
