From 97bbd595bddf187325364384c6ecb613e6e07ed9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 24 Sep 2015 11:46:33 +0100 Subject: [PATCH] get version from git --- setup.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c43979b..0693a09 100644 --- a/setup.py +++ b/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()