get version from git
This commit is contained in:
parent
01fc5ad40f
commit
97bbd595bd
1 changed files with 9 additions and 1 deletions
10
setup.py
10
setup.py
|
@ -9,9 +9,17 @@ except:
|
|||
def get_bzr_version():
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
dot_git = os.path.join(os.path.dirname(__file__), '.git')
|
||||
info = os.path.join(os.path.dirname(__file__), '.bzr/branch/last-revision')
|
||||
changelog = os.path.join(os.path.dirname(__file__), 'debian/changelog')
|
||||
if os.path.exists(info):
|
||||
if os.path.exists(dot_git):
|
||||
cmd = ['git', 'rev-list', 'HEAD', '--count']
|
||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
rev = int(stdout)
|
||||
return u'%s' % rev
|
||||
elif os.path.exists(info):
|
||||
f = open(info)
|
||||
rev = int(f.read().split()[0])
|
||||
f.close()
|
||||
|
|
Loading…
Reference in a new issue