changeset 162:e0678dfb7aec 1.7

setup: parse PKG-INFO for version information (issue3924)
author Peter Elmers <peter.elmers@yahoo.com>
date Thu, 23 Jul 2015 09:18:01 -0700
parents ec935041d1ff
children 8bc9c076cbb6
files setup.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py	Wed Apr 01 13:34:58 2015 -0500
+++ b/setup.py	Thu Jul 23 09:18:01 2015 -0700
@@ -1,7 +1,7 @@
 import os, time
 from distutils.core import setup
 
-# query Mercurial for version number
+# query Mercurial for version number, or pull from PKG-INFO
 version = 'unknown'
 if os.path.isdir('.hg'):
     cmd = "hg id -i -t"
@@ -26,6 +26,10 @@
         version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
     else:
         version = kw.get('node', '')[:12]
+elif os.path.exists('PKG-INFO'):
+    kw = dict([[t.strip() for t in l.split(':', 1)]
+               for l in open('PKG-INFO') if ':' in l])
+    version = kw.get('Version', version)
 
 setup(
     name='python-hglib',