File: setup.py

package info (click to toggle)
testrepository 0.0.20-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 752 kB
  • sloc: python: 5,871; sh: 37; makefile: 27
file content (114 lines) | stat: -rwxr-xr-x 3,718 bytes parent folder | download | duplicates (4)
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
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
#
# Copyright (c) 2009-2013 Testrepository Contributors
# 
# Licensed under either the Apache License, Version 2.0 or the BSD 3-clause
# license at the users choice. A copy of both licenses are available in the
# project source as Apache-2.0 and BSD. You may not use this file except in
# compliance with one of these two licences.
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under these licenses is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
# license you chose for the specific language governing permissions and
# limitations under that license.

from setuptools import setup
import email
import os

import testrepository


def get_revno():
    import bzrlib.workingtree
    t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
    return t.branch.revno()


def get_version_from_pkg_info():
    """Get the version from PKG-INFO file if we can."""
    pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
    try:
        pkg_info_file = open(pkg_info_path, 'r')
    except (IOError, OSError):
        return None
    try:
        pkg_info = email.message_from_file(pkg_info_file)
    except email.MessageError:
        return None
    return pkg_info.get('Version', None)


def get_version():
    """Return the version of testrepository that we are building."""
    version = '.'.join(
        str(component) for component in testrepository.__version__[0:3])
    phase = testrepository.__version__[3]
    if phase == 'final':
        return version
    pkg_info_version = get_version_from_pkg_info()
    if pkg_info_version:
        return pkg_info_version
    revno = get_revno()
    if phase == 'alpha':
        # No idea what the next version will be
        return 'next-r%s' % revno
    else:
        # Preserve the version number but give it a revno prefix
        return version + '-r%s' % revno


description = open(os.path.join(os.path.dirname(__file__), 'README.txt'), 'rt').read()


setup(name='testrepository',
      author='Robert Collins',
      author_email='robertc@robertcollins.net',
      url='https://launchpad.net/testrepository',
      description='A repository of test results.',
      long_description=description,
      keywords="subunit unittest testrunner",
      classifiers = [
          'Development Status :: 6 - Mature',
          'Intended Audience :: Developers',
          'License :: OSI Approved :: BSD License',
          'License :: OSI Approved :: Apache Software License',
          'Operating System :: OS Independent',
          'Programming Language :: Python',
          'Programming Language :: Python :: 3',
          'Topic :: Software Development :: Quality Assurance',
          'Topic :: Software Development :: Testing',
          ],
      scripts=['testr'],
      version=get_version(),
      packages=['testrepository',
        'testrepository.arguments',
        'testrepository.commands',
        'testrepository.repository',
        'testrepository.tests',
        'testrepository.tests.arguments',
        'testrepository.tests.commands',
        'testrepository.tests.repository',
        'testrepository.tests.ui',
        'testrepository.ui',
        ],
      install_requires=[
        'fixtures',
        'python-subunit >= 0.0.18',
        'testtools >= 0.9.30',
        ],
      extras_require = dict(
        test=[
            'bzr',
            'pytz',
            'testresources',
            'testscenarios',
            ]
        ),
      entry_points={
        'distutils.commands': [
          'testr = testrepository.setuptools_command:Testr',
          ],
        },
      )