2 """Distutils installer for testtools."""
4 from distutils
.core
import setup
12 import bzrlib
.workingtree
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
43 # No idea what the next version will be
44 return 'next-r%s' % revno
46 # Preserve the version number but give it a revno prefix
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()
55 setup(name
='testtools',
56 author
='Jonathan M. Lange',
57 author_email
='jml+testtools@mumak.net',
58 url
='https://launchpad.net/testtools',
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"],
64 packages
=['testtools', 'testtools.testresult', 'testtools.tests'])