Commit 1b15dc84 authored by Guido Günther's avatar Guido Günther

Move gbp/version.py generation into setup.py

This allows us to build on non Debian systems with setup.py only.
parent 962a9937
*.pyc
.noseids
.coverage
gbp/gbp_version.py
gbp/version.py
build/
gbp.egg-info/
......
......@@ -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)
......@@ -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',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment