#!/usr/bin/env python """setuptools setup file""" import sys, os, doctest from glob import glob from setuptools import setup, find_packages, Extension from distutils.cmd import Command def get_info(data, fileobj=None): import re info={} for k,v,_ in re.findall( r'(?ims)^:?(?P[a-z][\w\-_ ]*):\s*' '(?P.*?' '(?=(\Z|\n^:?[a-z][\w\-_ ]*:)))', fileobj and fileobj.read() or data): info.setdefault(k,[]).append(v.strip()) return info def get_requires(info, printspecials=True): specialdists=[] distinfo=[] requires = info.get('Requires', []) for s in info.get('Special', []): s = s.split(':',1) if s[0].strip() == 'Distribution': di = s[1].split(':',1) d, i = len(di) and di or [di, ''] d = d.strip() requires[:] = [r for r in requires if d not in r] specialdists.append(d) distinfo.append(di) if not printspecials: return requires if specialdists: print ( 'Requirements %s not compatible with setuptools, you will ' 'need to install them by hand before using this package.' ) % ', '.join(specialdists) for d,i in zip(specialdists, distinfo): if i: print '%s distribution hint: %s' % (d, i) return requires class build_doc(Command): description = 'Builds the documentation' user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): from docutils.core import publish_cmdline docutils_conf = os.path.join('doc', 'docutils.conf') epydoc_conf = os.path.join('doc', 'epydoc.conf') for source in glob('doc/*.txt'): dest = os.path.splitext(source)[0] + '.html' if not os.path.exists(dest) or \ os.path.getmtime(dest) < os.path.getmtime(source): print 'building documentation file %s' % dest publish_cmdline(writer_name='html', argv=['--config=%s' % docutils_conf, source, dest]) try: from epydoc import cli old_argv = sys.argv[1:] sys.argv[1:] = [ '--config=%s' % epydoc_conf, '--no-private', # epydoc bug, not read from config '--simple-term', '--verbose' ] cli.cli() sys.argv[1:] = old_argv except ImportError: print 'epydoc not installed, skipping API documentation.' class test_doc(Command): description = 'Tests the code examples in the documentation' user_options = [] def initialize_options(self): pass def finalize_options(self): pass def run(self): for filename in glob('doc/*.txt'): print 'testing documentation file %s' % filename doctest.testfile(filename, False, optionflags=doctest.ELLIPSIS) PKG_INFO=get_info(file('pkg-info.rst').read()) setup( cmdclass={'build_doc': build_doc, 'test_doc': test_doc}, name=PKG_INFO['Project-Label'][0], version=PKG_INFO['Version'][0], install_requires=get_requires(PKG_INFO), long_description=PKG_INFO['Abstract'][0], author=PKG_INFO['Author'][0], license = PKG_INFO['License'][0], author_email = PKG_INFO['Author-email'], url = "http://trac.wiretooth.com/public/wiki/asynwsgi", download_url = "http://svn.wiretooth.com/svn/open/asynwsgi/trunk", entry_points = { 'console_scripts': [ 'sclients = asynwsgi.sclients.main:run', 'asynget = asynwsgi.httpclient:run', 'ahtt-stressreq = asynwsgi.bench.http_processing:run', 'wsgiserver = asynwsgi.wsgiservice.server:run', #'asynwsgi-clientbench = asynwsgi.bench.htclient:run', ]}, package_dir = {'':'.'}, packages=find_packages(exclude=( '*.tests','*.tests.*','tests.*', 'tests')), classifiers=PKG_INFO['Classifiers'], zip_safe=False, ext_modules=[ Extension('asynwsgi.descriptortransport._passfd', ['asynwsgi/descriptortransport/_passfd.pyx'], define_macros=[('HAVE_MSGHDR_MSG_CONTROL', 1)] )] )