diff setup.py @ 230:5c5f6d93d9d4

Add hg revision id to version string for dev builds.
author Daniele Nicolodi <daniele@grinta.net>
date Wed, 30 Nov 2011 09:41:29 +0100
parents 9c2aa0e331e9
children 4b5f83e5a2fb
line wrap: on
line diff
--- a/setup.py	Thu Nov 24 18:24:53 2011 +0100
+++ b/setup.py	Wed Nov 30 09:41:29 2011 +0100
@@ -1,4 +1,5 @@
 from setuptools import setup, find_packages
+import os.path, subprocess
 
 version = '0.6dev'
 
@@ -23,6 +24,16 @@
     requires.append('ordereddict')
 
 
+if version.endswith('dev') and os.path.isdir('.hg'):
+    # add hg revision id to version string
+    p = subprocess.Popen(['hg', 'id', '--id'],
+                         stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    out, err = p.communicate()
+    if not p.returncode:
+        rev = out.strip().replace('+', '')
+        version += '-' + rev
+
+
 setup(name='ltpdarepo',
       version=version,
       keywords='',