1def git_version(): 2 import subprocess 3 cmd = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty'] 4 p = subprocess.Popen(cmd, stdout = subprocess.PIPE) 5 v = p.communicate()[0].strip() 6 r = p.returncode 7 if r != 0: 8 raise subprocess.CalledProcessError(r, ' '.join(cmd)) 9 return v 10