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