forked from mopemope/meinheld
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
125 lines (105 loc) · 3.34 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
try:
from setuptools import Extension, setup
except ImportError:
from distutils.core import Extension, setup
import os
import sys
import os.path
import platform
import fnmatch
develop = False
if os.environ.get("MEINHELD_DEVELOP") == "1":
develop = True
# develop = True
nogreen = False
if os.environ.get("MEINHELD_NOGREEN") == "1":
nogreen = True
def read(name):
return open(os.path.join(os.path.dirname(__file__), name)).read()
def check_platform():
if "posix" not in os.name:
print("Are you really running a posix compliant OS ?")
print("Be posix compliant is mandatory")
sys.exit(1)
def check_pypy():
return "PyPy" in sys.version
def get_picoev_file():
poller_file = None
if "Linux" == platform.system():
poller_file = 'meinheld/server/picoev_epoll.c'
elif "Darwin" == platform.system():
poller_file = 'meinheld/server/picoev_kqueue.c'
elif "FreeBSD" == platform.system():
poller_file = 'meinheld/server/picoev_kqueue.c'
else:
print("Sorry, not support .")
sys.exit(1)
return poller_file
def get_sources(path, ignore_files):
src = []
for root, dirs , files in os.walk(path):
for file in files:
src_path = os.path.join(root, file)
#ignore = reduce(lambda x, y: x or y, [fnmatch.fnmatch(src_path, i) for i in ignore_files])
ignore = [i for i in ignore_files if fnmatch.fnmatch(src_path, i)]
if not ignore and src_path.endswith(".c"):
src.append(src_path)
return src
check_platform()
pypy = check_pypy()
if pypy:
nogreen = True
if nogreen:
define_macros=[
("HTTP_PARSER_DEBUG", "0") ]
install_requires=[]
else:
define_macros=[
("WITH_GREENLET",None),
("HTTP_PARSER_DEBUG", "0") ]
install_requires=['greenlet>=0.4.5,<0.5']
if develop:
define_macros.append(("DEVELOP",None))
sources = get_sources("meinheld", ["*picoev_*"])
sources.append(get_picoev_file())
library_dirs=[]
#TODO set python include dirs
include_dirs=[]
setup(name='meinheld',
version="0.6.1",
description="High performance asynchronous Python WSGI Web Server",
long_description=read('README.rst'),
author='yutaka matsubara',
author_email='[email protected]',
url='http://meinheld.org',
license='BSD',
platforms='Linux, BSD, Darwin',
packages= ['meinheld'],
install_requires=install_requires,
entry_points="""
[gunicorn.workers]
gunicorn_worker=meinheld.gmeinheld:MeinheldWorker
""",
ext_modules = [
Extension('meinheld.server',
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
# libraries=["profiler"],
# extra_compile_args=[""],
define_macros=define_macros
)],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: POSIX :: Linux',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX :: BSD :: FreeBSD',
'Programming Language :: C',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Server'
],
)