ntdb: Cast getpid() result to unsigned int for GNU/Solaris build
[Samba/gbeck.git] / lib / testtools / setup.py
blob7ecd6d24d2623d46293d238d98899ea218d7be03
1 #!/usr/bin/env python
2 """Distutils installer for testtools."""
4 from distutils.core import setup
5 import email
6 import os
8 import testtools
11 def get_revno():
12 import bzrlib.errors
13 import bzrlib.workingtree
14 try:
15 t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
16 except (bzrlib.errors.NotBranchError, bzrlib.errors.NoWorkingTree):
17 return None
18 else:
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')
25 try:
26 pkg_info_file = open(pkg_info_path, 'r')
27 except (IOError, OSError):
28 return None
29 try:
30 pkg_info = email.message_from_file(pkg_info_file)
31 except email.MessageError:
32 return None
33 return pkg_info.get('Version', None)
36 def get_version():
37 """Return the version of testtools that we are building."""
38 version = '.'.join(
39 str(component) for component in testtools.__version__[0:3])
40 phase = testtools.__version__[3]
41 if phase == 'final':
42 return version
43 pkg_info_version = get_version_from_pkg_info()
44 if pkg_info_version:
45 return pkg_info_version
46 revno = get_revno()
47 if revno is None:
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,)
52 if phase == 'alpha':
53 # No idea what the next version will be
54 return 'next-r%s' % revno
55 else:
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 '
71 'framework'),
72 long_description=get_long_description(),
73 version=get_version(),
74 classifiers=["License :: OSI Approved :: MIT License",
75 "Programming Language :: Python :: 3",
77 packages=[
78 'testtools',
79 'testtools.matchers',
80 'testtools.testresult',
81 'testtools.tests',
82 'testtools.tests.matchers',
84 cmdclass={'test': testtools.TestCommand},
85 zip_safe=False)