Maintain a back-pointer to the fsp in struct smb_Dir when opening with FDOPENDIR.
[Samba.git] / lib / testtools / setup.py
blob59e5804f05bd3ec1c40b95f362dc24e76dc6c9a5
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.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')
20 try:
21 pkg_info_file = open(pkg_info_path, 'r')
22 except (IOError, OSError):
23 return None
24 try:
25 pkg_info = email.message_from_file(pkg_info_file)
26 except email.MessageError:
27 return None
28 return pkg_info.get('Version', None)
31 def get_version():
32 """Return the version of testtools that we are building."""
33 version = '.'.join(
34 str(component) for component in testtools.__version__[0:3])
35 phase = testtools.__version__[3]
36 if phase == 'final':
37 return version
38 pkg_info_version = get_version_from_pkg_info()
39 if pkg_info_version:
40 return pkg_info_version
41 revno = get_revno()
42 if phase == 'alpha':
43 # No idea what the next version will be
44 return 'next-r%s' % revno
45 else:
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 '
60 'framework'),
61 long_description=get_long_description(),
62 version=get_version(),
63 classifiers=["License :: OSI Approved :: MIT License"],
64 packages=['testtools', 'testtools.testresult', 'testtools.tests'])