forked from falconry/falcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
179 lines (155 loc) · 5.41 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import glob
import importlib
import io
import os
from os import path
import re
import sys
from setuptools import Extension, find_packages, setup
MYDIR = path.abspath(os.path.dirname(__file__))
VERSION = importlib.import_module('falcon.version')
VERSION = VERSION.__version__
REQUIRES = []
try:
sys.pypy_version_info
PYPY = True
except AttributeError:
PYPY = False
if PYPY:
CYTHON = False
else:
try:
from Cython.Distutils import build_ext
CYTHON = True
except ImportError:
# TODO(kgriffs): pip now ignores all output, so the user
# may not see this message. See also:
#
# https://github.com/pypa/pip/issues/2732
#
print('\nNOTE: Cython not installed. '
'Falcon will still work fine, but may run '
'a bit slower.\n')
CYTHON = False
if CYTHON:
def list_modules(dirname, pattern):
filenames = glob.glob(path.join(dirname, pattern))
module_names = []
for name in filenames:
module, ext = path.splitext(path.basename(name))
if module != '__init__':
module_names.append((module, ext))
return module_names
package_names = [
'falcon',
'falcon.cyutil',
'falcon.media',
'falcon.routing',
'falcon.util',
'falcon.vendor.mimeparse',
]
modules_to_exclude = [
# NOTE(kgriffs): Cython does not handle dynamically-created async
# methods correctly, so we do not cythonize the following modules.
'falcon.hooks',
# NOTE(vytas): Middleware classes cannot be cythonized until
# asyncio.iscoroutinefunction recognizes cythonized coroutines:
# * https://github.com/cython/cython/issues/2273
# * https://bugs.python.org/issue38225
'falcon.middlewares',
'falcon.responders',
'falcon.util.sync',
]
cython_package_names = frozenset([
'falcon.cyutil',
])
ext_modules = [
Extension(
package + '.' + module,
[path.join(*(package.split('.') + [module + ext]))]
)
for package in package_names
for module, ext in list_modules(
path.join(MYDIR, *package.split('.')),
('*.pyx' if package in cython_package_names else '*.py'))
if (package + '.' + module) not in modules_to_exclude
]
cmdclass = {'build_ext': build_ext}
else:
cmdclass = {}
ext_modules = []
def load_description():
in_patron_list = False
in_patron_replacement = False
in_raw = False
description_lines = []
# NOTE(kgriffs): PyPI does not support the raw directive
for readme_line in io.open('README.rst', 'r', encoding='utf-8'):
# NOTE(vytas): The patron list largely builds upon raw sections
if readme_line.startswith('.. Patron list starts'):
in_patron_list = True
in_patron_replacement = True
continue
elif in_patron_list:
if not readme_line.strip():
in_patron_replacement = False
elif in_patron_replacement:
description_lines.append(readme_line.lstrip())
if readme_line.startswith('.. Patron list ends'):
in_patron_list = False
continue
elif readme_line.startswith('.. raw::'):
in_raw = True
elif in_raw:
if readme_line and not re.match(r'\s', readme_line):
in_raw = False
if not in_raw:
description_lines.append(readme_line)
return ''.join(description_lines)
setup(
name='falcon',
version=VERSION,
description='An unladen web framework for building APIs and app backends.',
long_description=load_description(),
long_description_content_type='text/x-rst',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Natural Language :: English',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'License :: OSI Approved :: Apache Software License',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Topic :: Internet :: WWW/HTTP :: WSGI',
'Topic :: Software Development :: Libraries :: Application Frameworks',
'Programming Language :: Python',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
],
keywords='wsgi web api framework rest http cloud',
author='Kurt Griffiths',
author_email='mail@kgriffs.com',
url='https://falconframework.org',
license='Apache 2.0',
packages=find_packages(exclude=['tests']),
include_package_data=True,
zip_safe=False,
python_requires='>=3.5',
install_requires=REQUIRES,
cmdclass=cmdclass,
ext_modules=ext_modules,
tests_require=['testtools', 'requests', 'pyyaml', 'pytest', 'pytest-runner'],
entry_points={
'console_scripts': [
'falcon-bench = falcon.cmd.bench:main',
'falcon-print-routes = falcon.cmd.print_routes:main'
]
}
)