2
2
"""Distutils installer for testtools."""
4
4
from distutils.core import setup
6
version = '.'.join(str(component) for component in testtools.__version__[0:3])
7
phase = testtools.__version__[3]
9
12
import bzrlib.workingtree
10
13
t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
14
return t.branch.revno()
17
def get_version_from_pkg_info():
18
"""Get the version from PKG-INFO file if we can."""
19
pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
21
pkg_info_file = open(pkg_info_path, 'r')
22
except (IOError, OSError):
25
pkg_info = email.message_from_file(pkg_info_file)
26
except email.MessageError:
28
return pkg_info.get('Version', None)
32
"""Return the version of testtools that we are building."""
34
str(component) for component in testtools.__version__[0:3])
35
phase = testtools.__version__[3]
38
pkg_info_version = get_version_from_pkg_info()
40
return pkg_info_version
11
42
if phase == 'alpha':
12
43
# No idea what the next version will be
13
version = 'next-%s' % t.branch.revno()
44
return 'next-r%s' % revno
15
46
# Preserve the version number but give it a revno prefix
16
version = version + '~%s' % t.branch.revno()
47
return version + '-r%s' % revno
50
def get_long_description():
51
manual_path = os.path.join(os.path.dirname(__file__), 'MANUAL')
52
return open(manual_path).read()
18
55
setup(name='testtools',
19
56
author='Jonathan M. Lange',
21
58
url='https://launchpad.net/testtools',
22
59
description=('Extensions to the Python standard library unit testing '
61
long_description=get_long_description(),
62
version=get_version(),
63
classifiers=["License :: OSI Approved :: MIT License"],
25
64
packages=['testtools', 'testtools.testresult', 'testtools.tests'])