2 """Distutils installer for testtools."""
4 from distutils
.core
import setup
13 import bzrlib
.workingtree
15 t
= bzrlib
.workingtree
.WorkingTree
.open_containing(__file__
)[0]
16 except (bzrlib
.errors
.NotBranchError
, bzrlib
.errors
.NoWorkingTree
):
19 return t
.branch
.revno()
22 def get_version_from_pkg_info():
23 """Get the version from PKG-INFO file if we can."""
24 pkg_info_path
= os
.path
.join(os
.path
.dirname(__file__
), 'PKG-INFO')
26 pkg_info_file
= open(pkg_info_path
, 'r')
27 except (IOError, OSError):
30 pkg_info
= email
.message_from_file(pkg_info_file
)
31 except email
.MessageError
:
33 return pkg_info
.get('Version', None)
37 """Return the version of testtools that we are building."""
39 str(component
) for component
in testtools
.__version
__[0:3])
40 phase
= testtools
.__version
__[3]
43 pkg_info_version
= get_version_from_pkg_info()
45 return pkg_info_version
50 # No idea what the next version will be
51 return 'next-r%s' % revno
53 # Preserve the version number but give it a revno prefix
54 return version
+ '-r%s' % revno
57 def get_long_description():
58 manual_path
= os
.path
.join(
59 os
.path
.dirname(__file__
), 'doc/overview.rst')
60 return open(manual_path
).read()
63 setup(name
='testtools',
64 author
='Jonathan M. Lange',
65 author_email
='jml+testtools@mumak.net',
66 url
='https://launchpad.net/testtools',
67 description
=('Extensions to the Python standard library unit testing '
69 long_description
=get_long_description(),
70 version
=get_version(),
71 classifiers
=["License :: OSI Approved :: MIT License"],
72 packages
=['testtools', 'testtools.testresult', 'testtools.tests'],
73 cmdclass
={'test': testtools
.TestCommand
})