File: setup.py

package info (click to toggle)
albatross 1.36-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,472 kB
  • ctags: 1,822
  • sloc: python: 7,437; makefile: 146; sh: 132
file content (69 lines) | stat: -rw-r--r-- 2,318 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python
# To use:
#       python setup.py install
#

import distutils, os, sys, re
from distutils.core import setup, Extension
from distutils.command.sdist import sdist

class PreReleaseCheck:
    def __init__(self, distribution):
        self.distribution = distribution
        self.check_rev('doc/albatross.tex', r'^\\release.*\{([^}]+)\}')
        self.check_rev('doc/installation.tex', 
                       r'^tar xz.*albatross-(.*)\.tar\.gz')
        self.check_rev('doc/installation.tex', r'{albatross-(.*)}')
        self.check_rev('albatross/__init__.py', r'__version__ = \'(.*)\'')

    def _extract_rev(self, filename, pattern):
        regexp = re.compile(pattern)
        match = None
        revs = []
        line_num = 0
        f = open(filename)
        try:
            for line in f.readlines():
                line_num += 1
                match = regexp.search(line)
                if match:
                    revs.append((line_num, match.group(1)))
        finally:
            f.close()
        return revs

    def check_rev(self, filename, pattern):
        file_revs = self._extract_rev(filename, pattern)
        if not file_revs:
            sys.exit("Could not locate version in %s" % filename)
        line_num, file_rev = file_revs[0]
        for num, rev in file_revs[1:]:
            if rev != file_rev:
                sys.exit("%s:%d inconsistent version on line %d" % \
                         (filename, line_num, num))
        setup_rev = self.distribution.get_version()
        if file_rev != setup_rev:
            sys.exit("%s:%d version %s does not match setup.py version %s" % \
                     (filename, line_num, file_rev, setup_rev))


class my_sdist(sdist):
    def run(self):
        PreReleaseCheck(self.distribution)
        self.announce("Pre-release checks pass!")
        sdist.run(self)


setup(name = "albatross",
    version = "1.36",
    maintainer = "Object Craft",
    maintainer_email = "albatross@object-craft.com.au",
    description = "Albatross Web Toolkit",
    url = "http://www.object-craft.com.au/projects/albatross/",
    packages = ['albatross'],
    scripts = ['session-server/al-session-daemon',
               'standalone-server/al-httpd'],
    license = 'BSD - see file LICENCE',
    cmdclass = {'sdist': my_sdist},
)