setup.py: parse version and description from spec file
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 8 Apr 2014 09:21:12 +0000 (12:21 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Wed, 9 Apr 2014 07:02:55 +0000 (10:02 +0300)
Want to maintain packaging meta data in one place (i.e. spec file) as
much as possible.

Change-Id: I94a6381d5675e338db0131d070ebb75cb4280164
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
setup.py

index bd91b5b..80e624e 100644 (file)
--- a/setup.py
+++ b/setup.py
 
 from setuptools import setup
 
+def tag_from_spec(tag):
+    """Get value of an rpm tag from the spec file"""
+    with open('packaging/obs-service-gbs.spec', 'r') as spec:
+        for line in spec.readlines():
+            if line.lower().startswith(tag.lower() + ':'):
+                return line.split(':', 1)[1].strip()
+    raise Exception("ERROR: unable to parse '%s' from spec file" % tag)
+
 setup(name='obs_service_gbs',
-      version='0.0',
-      description='OBS source service utilizing GBS (Git Build System)',
+      version=tag_from_spec('Version'),
+      description=tag_from_spec('Summary'),
       author='Markus Lehtonen',
       author_email='markus.lehtonen@linux.intel.com',
       packages=['obs_service_gbs'],