~stefanor/ibid/dict-398764

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: Michael Gorven
  • Date: 2009-01-17 22:43:36 UTC
  • Revision ID: michael@gorven.za.net-20090117224336-3xjugthfwkq90x8c
setup.py: Write version number to ibid/.version. irc: Respond to CTCP VERSION and SOURCE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from subprocess import Popen, PIPE
 
2
 
1
3
from setuptools import setup, find_packages
2
 
from subprocess import Popen, PIPE
3
4
 
4
5
def bzr_revision():
5
6
    bzr = Popen(('bzr', 'tags', '--sort', 'time'), stdout=PIPE)
11
12
 
12
13
    lines = output.splitlines()
13
14
    if len(lines) == 0:
14
 
        raise Exception(u"No Bazaar tags defined")
15
 
 
16
 
    (tag, revision) = lines[-1].split()
 
15
        tag = '0.0.0'
 
16
        revision = '0'
 
17
    else:
 
18
        tag, revision = lines[-1].split()
17
19
 
18
20
    bzr = Popen(('bzr', 'log', '--line', '-c', '-1'), stdout=PIPE)
19
21
    output, error = bzr.communicate()
24
26
 
25
27
    latest = output.split(':')[0]
26
28
 
27
 
    if latest == revision:
28
 
        return tag
29
 
    else:
30
 
        return '%s-bzr%s' % (tag, latest)
 
29
    versionstring = latest == revision and tag or '%s-bzr%s' % (tag, latest)
 
30
 
 
31
    f = open('ibid/.version', 'w')
 
32
    f.write(versionstring)
 
33
    f.close()
 
34
 
 
35
    return versionstring
31
36
 
32
37
setup(
33
38
    name='Ibid',