forked from william-os4y/fapws3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
133 lines (114 loc) · 4.79 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages, Extension
import os
import sys
import os.path
import distutils.sysconfig
import platform
def read_file(name):
return open(os.path.join(os.path.dirname(__file__),name)).read()
def find_file(fname, dirs):
founded=False
for ckdir in dirs:
fpname=os.path.join(ckdir,fname)
if os.path.isfile(fpname):
founded=True
#we don't find it, it can be located into a subdirectory ;-)
localdirs=[]
try:
elems=os.listdir(ckdir)
except:
elems=[]
for elem in elems:
fpname=os.path.join(ckdir,elem)
if os.path.isdir(fpname):
localdirs.append(fpname)
if elem[:len(fname)]==fname:
founded=True
break
if founded:
print "----------Find",fname," in ", ckdir
return ckdir
if localdirs:
res=find_file(fname,localdirs)
if res:
return res
return False
readme = read_file('README.markdown')
if "posix" not in os.name:
print "Are you really running a posix compliant OS ?"
print "Be posix compliant is mandatory"
sys.exit(1)
search_library_dirs=[]
search_include_dirs=[]
library_dirs=[]
include_dirs=[]
#we add, at the begining of the list, the existing environemental variables
if os.environ.has_key('C_INCLUDE_PATH'):
search_include_dirs.extend(os.environ['C_INCLUDE_PATH'].split(os.pathsep))
if os.environ.has_key('LD_LIBRARY_PATH'):
search_library_dirs.extend(os.environ['LD_LIBRARY_PATH'].split(os.pathsep))
if os.environ.has_key('LIBPATH'):
search_library_dirs.append(os.path.join(os.environ['LIBPATH'],'lib'))
search_include_dirs.append(os.path.join(os.environ['LIBPATH'],'include'))
#anyhow we include the standards directories
search_library_dirs.extend(['/usr/lib','/usr/local/lib','/opt/local/lib','/usr/lib64','/usr/pkg/lib/ev'])
search_include_dirs.extend(['/usr/include','/usr/local/include','/opt/local/include','/usr/pkg/include/ev'])
version=platform.python_version_tuple()
if int(version[0])==2 and int(version[1])>=4:
print "Find python 2.4 or higher"
else:
print "Fapws has been developped with python 2.4 or higher (not yet python 3.X). Instead we found python %s.%s" % (version[0], version[1])
sys.exit(1)
res=find_file('ev.h',search_include_dirs)
if res==False:
print "We don't find 'ev.h' which is a mandatory file to compile Fapws"
print "Please install the sources of libev, or provide the path by setting the shell environmental variable C_INCLUDE_PATH"
sys.exit(1)
include_dirs.append(res)
res=find_file('Python.h',[distutils.sysconfig.get_python_inc()])
if res==False:
print "We don't find 'Python.h' which is a mandatory file to compile Fapws"
print "Please install the sources of python, or provide the path by setting the shell environmental variable C_INCLUDE_PATH"
sys.exit(1)
include_dirs.append(res)
res=find_file('libev.a',search_library_dirs)
if res==False:
print "We don't find 'libev.so' which is a mandatory file to run Fapws"
print "Please install libev, or provide the path by setting the shell environmental variable LD_LIBRARY_PATH"
sys.exit(1)
library_dirs.append(res)
extra_link_args=['-Wl,-R%s' % res]
setup(name='fapws3',
version="0.10",
description="Fast Asynchronous Python Web Server",
long_description=readme,
classifiers=['Development Status :: 4 - Beta','Environment :: Web Environment','License :: OSI Approved :: GNU General Public License (GPL)','Programming Language :: C','Programming Language :: Python','Topic :: Internet :: WWW/HTTP :: HTTP Servers','Topic :: Internet :: WWW/HTTP :: WSGI :: Server'], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='',
author='William',
author_email='[email protected]',
url='http://www.fapws.org',
license='GPL',
include_package_data=True,
zip_safe=False,
install_requires=[
# -*- Extra requirements: -*-
],
entry_points="""
# -*- Entry points: -*-
""",
packages= find_packages(),
ext_modules = [
Extension('fapws._evwsgi',
depends=['fapws/extra.h','fapws/wsgi.h','fapws/mainloop.h','fapws/common.h'],
sources=['fapws/extra.c', 'fapws/wsgi.c','fapws/mainloop.c','fapws/_evwsgi.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=['ev'],
extra_link_args=extra_link_args, #comment this line if you prefer to play with LD_LIBRARY_PATH
#extra_compile_args=["-ggdb"],
#define_macros=[("DEBUG", "1")],
)
]
)
# end of file: setup.py