From 1b15dc848f312005258c5a9bf762448acf5d9f8b Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Mon, 7 Nov 2011 16:05:20 +0100 Subject: Move gbp/version.py generation into setup.py This allows us to build on non Debian systems with setup.py only. --- setup.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'setup.py') diff --git a/setup.py b/setup.py index a57b38c..90eb524 100644 --- a/setup.py +++ b/setup.py @@ -17,9 +17,32 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # END OF COPYRIGHT # +import subprocess from setuptools import setup + +def fetch_version(): + """Get version from debian changelog and write it to gbp/version.py""" + version = "0.0" + + try: + popen = subprocess.Popen('dpkg-parsechangelog', stdout=subprocess.PIPE) + out, ret = popen.communicate() + for line in out.split('\n'): + if line.startswith('Version:'): + version = line.split(' ')[1].strip() + break + except OSError: + pass # Failing is fine, we just can't print the version then + + with file('gbp/version.py', 'w') as f: + f.write('gbp_version="%s"\n' % version) + + return version + + setup(name = "gbp", + version = fetch_version(), author = u'Guido Günther', author_email = 'agx@sigxcpu.org', scripts = [ 'bin/git-buildpackage', -- cgit v1.2.3