Mercurial > python-hglib
changeset 80:009e7858a93b
setup: add version number lookup
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 10 Nov 2011 16:42:12 -0600 |
parents | ca5f8f43e585 |
children | b3c2f0e6bda2 |
files | setup.py |
diffstat | 1 files changed, 28 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/setup.py Wed Nov 09 16:09:46 2011 -0600 +++ b/setup.py Thu Nov 10 16:42:12 2011 -0600 @@ -1,9 +1,35 @@ -import os +import os, time from distutils.core import setup +# query Mercurial for version number +version = 'unknown' +if os.path.isdir('.hg'): + cmd = "hg id -i -t" + l = os.popen(cmd).read().split() + while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags + l.pop() + if len(l) > 1: # tag found + version = l[-1] + if l[0].endswith('+'): # propagate the dirty status to the tag + version += '+' + elif len(l) == 1: # no tag found + cmd = 'hg parents --template "{latesttag}+{latesttagdistance}-"' + version = os.popen(cmd).read() + l[0] + if version.endswith('+'): + version += time.strftime('%Y%m%d') +elif os.path.exists('.hg_archival.txt'): + kw = dict([[t.strip() for t in l.split(':', 1)] + for l in open('.hg_archival.txt')]) + if 'tag' in kw: + version = kw['tag'] + elif 'latesttag' in kw: + version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw + else: + version = kw.get('node', '')[:12] + setup( name='python-hglib', - version='0.1', + version=version, author='Idan Kamara', author_email='idankk86@gmail.com', url='http://selenic.com/repo/python-hglib',