Rewrite torture_samba3_rpc_sharesec() to use a non-privileged user for share security...
[Samba/bb.git] / lib / testtools / setup.py
blob0fabb066939d0000cc7ee6ab7320e11552d9486d
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 packages=['testtools', 'testtools.testresult', 'testtools.tests'],
76 cmdclass={'test': testtools.TestCommand})