gevent-py3k / setup.py

#!/usr/bin/env python
import sys
import os
import glob
import re
from setuptools import find_packages, setup
from distutils.core import Extension

name = 'gevent.core'
sources = ['gevent/core.c']
ev_dir = None

if ev_dir is None and glob.glob('/usr/lib/libevent.*'):
    print 'found system libevent for', sys.platform
    libevent = Extension(name=name,
                         sources=sources,
                         libraries=['event'])
elif ev_dir is None and glob.glob('%s/lib/libevent.*' % sys.prefix):
    print 'found installed libevent in', sys.prefix
    libevent = Extension(name=name,
                         sources=sources,
                         include_dirs=['%s/include' % sys.prefix],
                         library_dirs=['%s/lib' % sys.prefix],
                         libraries=['event'])
else:
    if ev_dir is None:
        l = glob.glob('../libevent*')
        l.reverse()
        for dir in l:
            if os.path.isdir(dir):
                ev_dir = dir
                break
    if not ev_dir:
        raise "couldn't find libevent installation or build directory"
    
    print 'found libevent build directory', ev_dir
    ev_incdirs = [ev_dir, ev_dir + '/compat']
    ev_extargs = []
    ev_extobjs = []
    ev_libraries = ['event']
    
    if sys.platform == 'win32':
        ev_incdirs.extend(['%s/WIN32-Code' % ev_dir,
                           '%s/compat' % ev_dir])
        sources.extend(['%s/%s' % (ev_dir, x) for x in [
            'WIN32-Code/misc.c', 'WIN32-Code/win32.c',
            'log.c', 'event.c']])
        ev_extargs = ['-DWIN32', '-DHAVE_CONFIG_H']
        ev_libraries = ['wsock32']
    else:
        ev_extobjs = glob.glob('%s/*.o' % dir)

    libevent = Extension(name=name,
                         sources=sources,
                         include_dirs=ev_incdirs,
                         extra_compile_args=ev_extargs,
                         extra_objects=ev_extobjs,
                         libraries=ev_libraries)

version = re.search("__version__\s*=\s*'(.*)'", open('gevent/__init__.py').read(), re.M).group(1).strip()
assert version, version

setup(
    name='gevent',
    version=version,
    description='Greenlet/Libevent-based networking library',
    author='Denis Bilenko',
    author_email='denis.bilenko@gmail.com',
    packages=find_packages(exclude=['greentest']),
    ext_modules=[libevent],
    classifiers=[
    "License :: OSI Approved :: MIT License",
    "Programming Language :: Python",
    "Operating System :: MacOS :: MacOS X",
    "Operating System :: POSIX",
    "Topic :: Internet",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Intended Audience :: Developers",
    "Development Status :: 4 - Beta"]
    )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.