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
48 # Apparently if we just say "snapshot" then distribute won't accept it
49 # as satisfying versioned dependencies. This is a problem for the
50 # daily build version.
51 return "snapshot-%s" % (version
,)
53 # No idea what the next version will be
54 return 'next-r%s' % revno
56 # Preserve the version number but give it a revno prefix
57 return version
+ '-r%s' % revno
60 def get_long_description():
61 manual_path
= os
.path
.join(
62 os
.path
.dirname(__file__
), 'doc/overview.rst')
63 return open(manual_path
).read()
66 setup(name
='testtools',
67 author
='Jonathan M. Lange',
68 author_email
='jml+testtools@mumak.net',
69 url
='https://launchpad.net/testtools',
70 description
=('Extensions to the Python standard library unit testing '
72 long_description
=get_long_description(),
73 version
=get_version(),
74 classifiers
=["License :: OSI Approved :: MIT License"],
75 packages
=['testtools', 'testtools.testresult', 'testtools.tests'],
76 cmdclass
={'test': testtools
.TestCommand
})