summaryrefslogtreecommitdiff
path: root/src/setup.py
blob: fa723fd18b8dc689c1206231f3c48b82f426450e (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env python
# -*- encoding: utf8 -*-
__revision__ = "$Id$"
import sys
import os

from distutils2.core import setup
from distutils2.command.sdist import sdist
from distutils2.command.install import install
from distutils2 import __version__ as VERSION
from distutils2.util import find_packages

f = open('README.txt')
try:
    README = f.read()
finally:
    f.close()

def get_tip_revision(path=os.getcwd()):
    from subprocess import Popen, PIPE
    try:
        cmd = Popen(['hg', 'tip', '--template', '{rev}', '-R', path],
                    stdout=PIPE, stderr=PIPE)
    except OSError:
        return 0
    rev = cmd.stdout.read()
    if rev == '':
        # there has been an error in the command
        return 0
    return int(rev)

DEV_SUFFIX = '.dev%d' % get_tip_revision('..')

class install_hg(install):

    user_options = install.user_options + [
            ('dev', None, "Add a dev marker")
            ]

    def initialize_options(self):
        install.initialize_options(self)
        self.dev = 0

    def run(self):
        if self.dev:
            self.distribution.metadata.version += DEV_SUFFIX
        install.run(self)


class sdist_hg(sdist):

    user_options = sdist.user_options + [
            ('dev', None, "Add a dev marker")
            ]

    def initialize_options(self):
        sdist.initialize_options(self)
        self.dev = 0

    def run(self):
        if self.dev:
            self.distribution.metadata.version += DEV_SUFFIX
        sdist.run(self)

setup_kwargs = {}
if sys.version < '2.6':
    setup_kwargs['scripts'] = ['distutils2/mkpkg.py']

_CLASSIFIERS = """\
Development Status :: 3 - Alpha
Intended Audience :: Developers
License :: OSI Approved :: Python Software Foundation License
Operating System :: OS Independent
Programming Language :: Python
Topic :: Software Development :: Libraries :: Python Modules
Topic :: System :: Archiving :: Packaging
Topic :: System :: Systems Administration
Topic :: Utilities"""

setup (name="Distutils2",
       version=VERSION,
       summary="Python Distribution Utilities",
       keywords=['packaging', 'distutils'],
       author="Tarek Ziade",
       author_email="tarek@ziade.org",
       home_page="http://bitbucket.org/tarek/distutils2/wiki/Home",
       license="PSF",
       description=README,
       classifier=_CLASSIFIERS.split('\n'),
       packages=find_packages(),
       cmdclass={'sdist': sdist_hg, 'install': install_hg},
       package_data={'distutils2._backport': ['sysconfig.cfg']},
       project_url=[('Mailing-list',
                    'http://mail.python.org/mailman/listinfo/distutils-sig/'),
                    ('Documentation',
                     'http://packages.python.org/Distutils2'),
                    ('Repository', 'http://hg.python.org/distutils2'),
                    ('Bug tracker', 'http://bugs.python.org')],
       **setup_kwargs
       )