diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | debian/rules | 7 | ||||
-rw-r--r-- | gbp/config.py | 2 | ||||
-rw-r--r-- | setup.py | 23 |
4 files changed, 27 insertions, 7 deletions
@@ -1,7 +1,7 @@ *.pyc .noseids .coverage -gbp/gbp_version.py +gbp/version.py build/ gbp.egg-info/ diff --git a/debian/rules b/debian/rules index 6ca66d16..bc552320 100755 --- a/debian/rules +++ b/debian/rules @@ -10,7 +10,6 @@ EXAMPLE_SCRIPTS=\ DEB_COMPRESS_EXCLUDE=$(EXAMPLE_SCRIPTS) PYCHECKER_ARGS=-boptparse --no-override --no-shadowbuiltin -GBP_VERSION=gbp/gbp_version.py %: dh $@ --with python2 @@ -26,7 +25,7 @@ override_dh_auto_test: PYTHONPATH=. pychecker $(PYCHECKER_ARGS) -q gbp gbp.scripts gbp.git -override_dh_auto_build: $(GBP_VERSION) +override_dh_auto_build: dh_auto_build epydoc --config=setup.cfg make -C docs/ @@ -38,10 +37,8 @@ override_dh_auto_install: voerride_dh_auto_clean: dh_auto_clean make -C docs/ clean - -rm gbp/gbp_version.py + -rm gbp/version.py override_dh_compress: dh_compress --exclude=usr/share/doc/git-buildpackage/examples/ -$(GBP_VERSION): debian/changelog - echo 'gbp_version="$(DEB_VERSION)"' > $(GBP_VERSION) diff --git a/gbp/config.py b/gbp/config.py index d0c8716e..241fa1b8 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -21,7 +21,7 @@ from ConfigParser import SafeConfigParser from copy import copy import os.path try: - from gbp.gbp_version import gbp_version + from gbp.version import gbp_version except ImportError: gbp_version = "[Unknown version]" import gbp.tristate @@ -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', |