Debian Codegraph @

third_party/python/python-hglib/setup.py

raw
1 import os, time
2 from distutils.core import setup
3
4 # query Mercurial for version number, or pull from PKG-INFO
5 version = 'unknown'
6 if os.path.isdir('.hg'):
7 cmd = "hg id -i -t"
8 l = os.popen(cmd).read().split()
9 while len(l) > 1 and l[-1][0].isalpha(): # remove non-numbered tags
10 l.pop()
11 if len(l) > 1: # tag found
12 version = l[-1]
13 if l[0].endswith('+'): # propagate the dirty status to the tag
14 version += '+'
15 elif len(l) == 1: # no tag found
16 cmd = 'hg parents --template "{latesttag}+{latesttagdistance}-"'
17 version = os.popen(cmd).read() + l[0]
18 if version.endswith('+'):
19 version += time.strftime('%Y%m%d')
20 elif os.path.exists('.hg_archival.txt'):
21 kw = dict([[t.strip() for t in l.split(':', 1)]
22 for l in open('.hg_archival.txt')])
23 if 'tag' in kw:
24 version = kw['tag']
25 elif 'latesttag' in kw:
26 version = '%(latesttag)s+%(latesttagdistance)s-%(node).12s' % kw
27 else:
28 version = kw.get('node', '')[:12]
29 elif os.path.exists('PKG-INFO'):
30 kw = dict([[t.strip() for t in l.split(':', 1)]
31 for l in open('PKG-INFO') if ':' in l])
32 version = kw.get('Version', version)
33
34 setup(
35 name='python-hglib',
36 version=version,
37 author='Idan Kamara',
38 author_email='[email protected]',
39 url='http://selenic.com/repo/python-hglib',
40 description='Mercurial Python library',
41 long_description=open(os.path.join(os.path.dirname(__file__),
42 'README')).read(),
43 classifiers=[
44 'Programming Language :: Python',
45 'Programming Language :: Python :: 2.4',
46 'Programming Language :: Python :: 2.5',
47 'Programming Language :: Python :: 2.6',
48 'Programming Language :: Python :: 2.7',
49 'Programming Language :: Python :: 3',
50 'Programming Language :: Python :: 3.4',
51
52 ],
53 license='MIT',
54 packages=['hglib'])