2 """Distutils installer for testtools."""
4 from setuptools import setup
5 from distutils.command.build_py import build_py
12 if getattr(testtools, 'TestCommand', None) is not None:
13 cmd_class['test'] = testtools.TestCommand
16 class testtools_build_py(build_py):
17 def build_module(self, module, module_file, package):
18 if sys.version_info >= (3,) and module == '_compat2x':
20 return build_py.build_module(self, module, module_file, package)
21 cmd_class['build_py'] = testtools_build_py
24 def get_version_from_pkg_info():
25 """Get the version from PKG-INFO file if we can."""
26 pkg_info_path = os.path.join(os.path.dirname(__file__), 'PKG-INFO')
28 pkg_info_file = open(pkg_info_path, 'r')
29 except (IOError, OSError):
32 pkg_info = email.message_from_file(pkg_info_file)
33 except email.MessageError:
35 return pkg_info.get('Version', None)
39 """Return the version of testtools that we are building."""
41 str(component) for component in testtools.__version__[0:3])
42 phase = testtools.__version__[3]
45 pkg_info_version = get_version_from_pkg_info()
47 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 "%s.0dev0" % (version,)
54 def get_long_description():
55 manual_path = os.path.join(
56 os.path.dirname(__file__), 'doc/overview.rst')
57 return open(manual_path).read()
60 setup(name='testtools',
61 author='Jonathan M. Lange',
62 author_email='jml+testtools@mumak.net',
63 url='https://github.com/testing-cabal/testtools',
64 description=('Extensions to the Python standard library unit testing '
66 long_description=get_long_description(),
67 version=get_version(),
68 classifiers=["License :: OSI Approved :: MIT License",
69 "Programming Language :: Python :: 3",
74 'testtools.testresult',
76 'testtools.tests.matchers',
82 # 'mimeparse' has not been uploaded by the maintainer with Python3 compat
83 # but someone kindly uploaded a fixed version as 'python-mimeparse'.