summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-11-07 16:05:20 +0100
committerGuido Günther <agx@sigxcpu.org>2011-11-07 17:35:45 +0100
commit1b15dc848f312005258c5a9bf762448acf5d9f8b (patch)
treeb2ed0852fab058a5184151d4dec79587c5df35e6
parent962a9937d5cf912bdbbb0f8ee14e80197a75fd5c (diff)
downloadgit-buildpackage-1b15dc848f312005258c5a9bf762448acf5d9f8b.tar.gz
git-buildpackage-1b15dc848f312005258c5a9bf762448acf5d9f8b.tar.bz2
git-buildpackage-1b15dc848f312005258c5a9bf762448acf5d9f8b.zip
Move gbp/version.py generation into setup.py
This allows us to build on non Debian systems with setup.py only.
-rw-r--r--.gitignore2
-rwxr-xr-xdebian/rules7
-rw-r--r--gbp/config.py2
-rw-r--r--setup.py23
4 files changed, 27 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index c91aead7..ce76f778 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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
diff --git a/setup.py b/setup.py
index a57b38c7..90eb5242 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',