root/asynwsgi/trunk/setup.py

Revision 467, 4.2 kB (checked in by robin, 2 years ago)

* merged the serviceapi branch

These changes firm up the dispatcher api, the service model api and the service request api

* huge set of name changes
* lots of documentation
* a number of micelaneous bug fixes and api enhancements.


Line 
1 #!/usr/bin/env python
2 """setuptools setup file"""
3 import sys, os, doctest
4 from glob import glob
5 from setuptools import setup, find_packages, Extension
6 from distutils.cmd import Command
7
8 def get_info(data, fileobj=None):
9     import re
10     info={}
11     for k,v,_ in re.findall(
12         r'(?ims)^:?(?P<key>[a-z][\w\-_ ]*):\s*'
13          '(?P<value>.*?'
14          '(?=(\Z|\n^:?[a-z][\w\-_ ]*:)))',
15          fileobj and fileobj.read() or data):
16         info.setdefault(k,[]).append(v.strip())
17     return info
18
19 def get_requires(info, printspecials=True):
20     specialdists=[]
21     distinfo=[]
22     requires = info.get('Requires', [])
23     for s in info.get('Special', []):
24         s = s.split(':',1)
25         if s[0].strip() == 'Distribution':
26             di = s[1].split(':',1)
27             d, i = len(di) and di or [di, '']
28             d = d.strip()
29             requires[:] = [r for r in requires if d not in r]
30             specialdists.append(d)
31             distinfo.append(di)
32     if not printspecials:
33         return requires
34     if specialdists:
35         print (
36             'Requirements %s not compatible with setuptools, you will '
37             'need to install them by hand before using this package.'
38             ) % ', '.join(specialdists)
39     for d,i in zip(specialdists, distinfo):
40         if i:
41             print '%s distribution hint: %s' % (d, i)
42     return requires
43
44
45
46 class build_doc(Command):
47     description = 'Builds the documentation'
48     user_options = []
49
50     def initialize_options(self):
51         pass
52
53     def finalize_options(self):
54         pass
55
56     def run(self):
57         from docutils.core import publish_cmdline
58         docutils_conf = os.path.join('doc', 'docutils.conf')
59         epydoc_conf = os.path.join('doc', 'epydoc.conf')
60
61         for source in glob('doc/*.txt'):
62             dest = os.path.splitext(source)[0] + '.html'
63             if not os.path.exists(dest) or \
64                    os.path.getmtime(dest) < os.path.getmtime(source):
65                 print 'building documentation file %s' % dest
66                 publish_cmdline(writer_name='html',
67                                 argv=['--config=%s' % docutils_conf, source,
68                                       dest])
69
70         try:
71             from epydoc import cli
72             old_argv = sys.argv[1:]
73             sys.argv[1:] = [
74                 '--config=%s' % epydoc_conf,
75                 '--no-private', # epydoc bug, not read from config
76                 '--simple-term',
77                 '--verbose'
78             ]
79             cli.cli()
80             sys.argv[1:] = old_argv
81
82         except ImportError:
83             print 'epydoc not installed, skipping API documentation.' 
84
85 class test_doc(Command):
86     description = 'Tests the code examples in the documentation'
87     user_options = []
88
89     def initialize_options(self):
90         pass
91
92     def finalize_options(self):
93         pass
94
95     def run(self):
96         for filename in glob('doc/*.txt'):
97             print 'testing documentation file %s' % filename
98             doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS)
99
100
101 PKG_INFO=get_info(file('pkg-info.rst').read())
102
103 setup(
104     cmdclass={'build_doc': build_doc, 'test_doc': test_doc},
105
106     name=PKG_INFO['Project-Label'][0],
107     version=PKG_INFO['Version'][0],
108     install_requires=get_requires(PKG_INFO),
109     long_description=PKG_INFO['Abstract'][0],
110     author=PKG_INFO['Author'][0],
111     license = PKG_INFO['License'][0],
112     author_email = PKG_INFO['Author-email'],
113     url = "http://trac.wiretooth.com/public/wiki/asynwsgi",
114     download_url = "http://svn.wiretooth.com/svn/open/asynwsgi/trunk",
115     entry_points = {
116         'console_scripts': [
117         'sclients = asynwsgi.sclients.main:run',
118         'asynget = asynwsgi.httpclient:run',
119         'ahtt-stressreq = asynwsgi.bench.http_processing:run',
120         'wsgiserver = asynwsgi.wsgiservice.server:run',
121         #'asynwsgi-clientbench = asynwsgi.bench.htclient:run',
122         ]},
123     package_dir = {'':'.'},
124     packages=find_packages(exclude=(
125         '*.tests','*.tests.*','tests.*', 'tests')),
126     classifiers=PKG_INFO['Classifiers'],
127     zip_safe=False,
128     ext_modules=[
129         Extension('asynwsgi.descriptortransport._passfd',
130             ['asynwsgi/descriptortransport/_passfd.pyx'],
131         define_macros=[('HAVE_MSGHDR_MSG_CONTROL', 1)]
132         )]
133 )
134
Note: See TracBrowser for help on using the browser.