source: trunk/server/lib/testtools/setup.py@ 814

Last change on this file since 814 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.0 KB
Line 
1#!/usr/bin/env python
2"""Distutils installer for testtools."""
3
4from distutils.core import setup
5import email
6import os
7
8import testtools
9
10
11def get_revno():
12 import bzrlib.workingtree
13 t = bzrlib.workingtree.WorkingTree.open_containing(__file__)[0]
14 return t.branch.revno()
15
16
17def 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)
29
30
31def 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
48
49
50def get_long_description():
51 manual_path = os.path.join(os.path.dirname(__file__), 'MANUAL')
52 return open(manual_path).read()
53
54
55setup(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'])
Note: See TracBrowser for help on using the repository browser.