Skip to content
Newer
Older
100644 186 lines (156 sloc) 6.46 KB
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
1 #!/usr/bin/env python
2 #
3 # Copyright 2009 Facebook
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License. You may obtain
7 # a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 # License for the specific language governing permissions and limitations
15 # under the License.
16
70659cb @bdarnell Add a new TORNADO_EXTENSION environment variable for testing purposes.
bdarnell authored
17 import os
0ca7fa0 @bdarnell Replace cython-based extension module with a hand-written one.
bdarnell authored
18 import platform
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
19 import sys
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
20 import warnings
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
21
3b181f5 @bdarnell Revert "Remove optional setuptools import."
bdarnell authored
22 try:
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
23 # Use setuptools if available, for install_requires (among other things).
3b181f5 @bdarnell Revert "Remove optional setuptools import."
bdarnell authored
24 import setuptools
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
25 from setuptools import setup
3b181f5 @bdarnell Revert "Remove optional setuptools import."
bdarnell authored
26 except ImportError:
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
27 setuptools = None
28 from distutils.core import setup
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
29
0ca7fa0 @bdarnell Replace cython-based extension module with a hand-written one.
bdarnell authored
30 from distutils.core import Extension
e8dc5e4 @bdarnell Add cython-based speedup for websocket mask function.
bdarnell authored
31
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
32 # The following code is copied from
33 # https://github.com/mongodb/mongo-python-driver/blob/master/setup.py
34 # to support installing without the extension on platforms where
35 # no compiler is available.
36 from distutils.command.build_ext import build_ext
37
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
38
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
39 class custom_build_ext(build_ext):
40 """Allow C extension building to fail.
41
42 The C extension speeds up websocket masking, but is not essential.
43 """
44
45 warning_message = """
46 ********************************************************************
47 WARNING: %s could not
48 be compiled. No C extensions are essential for Tornado to run,
49 although they do result in significant speed improvements for
50 websockets.
51 %s
52
53 Here are some hints for popular operating systems:
54
55 If you are seeing this message on Linux you probably need to
56 install GCC and/or the Python development package for your
57 version of Python.
58
59 Debian and Ubuntu users should issue the following command:
60
61 $ sudo apt-get install build-essential python-dev
62
02df8f7 @bheesham Update hints for popular operating systems.
bheesham authored
63 RedHat and CentOS users should issue the following command:
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
64
65 $ sudo yum install gcc python-devel
66
02df8f7 @bheesham Update hints for popular operating systems.
bheesham authored
67 Fedora users should issue the following command:
68
69 $ sudo dnf install gcc python-devel
70
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
71 If you are seeing this message on OSX please read the documentation
72 here:
73
74 http://api.mongodb.org/python/current/installation.html#osx
75 ********************************************************************
76 """
77
78 def run(self):
79 try:
80 build_ext.run(self)
58370bd @bdarnell Fall back to pure-python mode on any exception during the build.
bdarnell authored
81 except Exception:
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
82 e = sys.exc_info()[1]
83 sys.stdout.write('%s\n' % str(e))
84 warnings.warn(self.warning_message % ("Extension modules",
85 "There was an issue with "
86 "your platform configuration"
87 " - see above."))
88
89 def build_extension(self, ext):
90 name = ext.name
9fa52d7 @bdarnell Broaden catch clause in extension building.
bdarnell authored
91 try:
92 build_ext.build_extension(self, ext)
58370bd @bdarnell Fall back to pure-python mode on any exception during the build.
bdarnell authored
93 except Exception:
9fa52d7 @bdarnell Broaden catch clause in extension building.
bdarnell authored
94 e = sys.exc_info()[1]
95 sys.stdout.write('%s\n' % str(e))
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
96 warnings.warn(self.warning_message % ("The %s extension "
97 "module" % (name,),
9fa52d7 @bdarnell Broaden catch clause in extension building.
bdarnell authored
98 "The output above "
99 "this warning shows how "
100 "the compilation "
101 "failed."))
4ec9831 @bdarnell Make the C extension optional.
bdarnell authored
102
103
5e916c2 @bdarnell Automatically run 2to3 when installing on python 3
bdarnell authored
104 kwargs = {}
105
1a256e3 @bdarnell Bump master version number to 4.4.dev1
bdarnell authored
106 version = "4.4.dev1"
34f0494 @bdarnell Add download url to setup.py for pypi
bdarnell authored
107
6a8bfce @bdarnell Include readme in the setup.py long_description field.
bdarnell authored
108 with open('README.rst') as f:
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
109 kwargs['long_description'] = f.read()
6a8bfce @bdarnell Include readme in the setup.py long_description field.
bdarnell authored
110
70659cb @bdarnell Add a new TORNADO_EXTENSION environment variable for testing purposes.
bdarnell authored
111 if (platform.python_implementation() == 'CPython' and
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
112 os.environ.get('TORNADO_EXTENSION') != '0'):
0ca7fa0 @bdarnell Replace cython-based extension module with a hand-written one.
bdarnell authored
113 # This extension builds and works on pypy as well, although pypy's jit
114 # produces equivalent performance.
115 kwargs['ext_modules'] = [
116 Extension('tornado.speedups',
117 sources=['tornado/speedups.c']),
118 ]
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
119
70659cb @bdarnell Add a new TORNADO_EXTENSION environment variable for testing purposes.
bdarnell authored
120 if os.environ.get('TORNADO_EXTENSION') != '1':
121 # Unless the user has specified that the extension is mandatory,
122 # fall back to the pure-python implementation on any build failure.
123 kwargs['cmdclass'] = {'build_ext': custom_build_ext}
124
ec4b7e4 @bdarnell Remove ca-certificates bundle and instead depend on the certifi package.
bdarnell authored
125
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
126 if setuptools is not None:
127 # If setuptools is not available, you're on your own for dependencies.
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
128 install_requires = []
3546700 @bdarnell Fix singledispatch for asyncio on py26.
bdarnell authored
129 if sys.version_info < (2, 7):
130 # Only needed indirectly, for singledispatch.
131 install_requires.append('ordereddict')
4a5fdb1 @bdarnell Add backports.ssl_match_hostname dependency in place of our copy.
bdarnell authored
132 if sys.version_info < (3, 2):
ec4b7e4 @bdarnell Remove ca-certificates bundle and instead depend on the certifi package.
bdarnell authored
133 install_requires.append('backports.ssl_match_hostname')
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
134 if sys.version_info < (3, 4):
7b3e31b @bdarnell Make singledispatch and backports_abc mandatory dependencies.
bdarnell authored
135 install_requires.append('singledispatch')
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
136 # Certifi is also optional on 2.7.9+, although making our dependencies
137 # conditional on micro version numbers seems like a bad idea
138 # until we have more declarative metadata.
139 install_requires.append('certifi')
7b3e31b @bdarnell Make singledispatch and backports_abc mandatory dependencies.
bdarnell authored
140 if sys.version_info < (3, 5):
141 install_requires.append('backports_abc>=0.4')
ec4b7e4 @bdarnell Remove ca-certificates bundle and instead depend on the certifi package.
bdarnell authored
142 kwargs['install_requires'] = install_requires
e8dc5e4 @bdarnell Add cython-based speedup for websocket mask function.
bdarnell authored
143
08d75e1 @bdarnell Make setuptools optional again in setup.py.
bdarnell authored
144 setup(
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
145 name="tornado",
34f0494 @bdarnell Add download url to setup.py for pypi
bdarnell authored
146 version=version,
fe9037a @bdarnell Make "certifi" optional on py34.
bdarnell authored
147 packages=["tornado", "tornado.test", "tornado.platform"],
148 package_data={
489997d @bdarnell Fix load_gettext_translations on python 3
bdarnell authored
149 # data files need to be listed both here (which determines what gets
150 # installed) and in MANIFEST.in (which determines what gets included
151 # in the sdist tarball)
152 "tornado.test": [
153 "README",
154 "csv_translations/fr_FR.csv",
155 "gettext_translations/fr_FR/LC_MESSAGES/tornado_test.mo",
156 "gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po",
dd388bf @bdarnell Fix options.parse_config_file on Python 3.
bdarnell authored
157 "options_test.cfg",
158 "static/robots.txt",
3a881d9 @aebrahim test Content-Type for static compressed files
aebrahim authored
159 "static/sample.xml",
160 "static/sample.xml.gz",
161 "static/sample.xml.bz2",
1ccf71a @bdarnell Add method StaticFileHandler.get_content_version.
bdarnell authored
162 "static/dir/index.html",
ecb3ea7 @bdarnell Fix path traversal check in StaticFileHandler.
bdarnell authored
163 "static_foo.txt",
dd388bf @bdarnell Fix options.parse_config_file on Python 3.
bdarnell authored
164 "templates/utf8.html",
165 "test.crt",
166 "test.key",
489997d @bdarnell Fix load_gettext_translations on python 3
bdarnell authored
167 ],
c410292 @bdarnell Add test suite to tarball releases.
bdarnell authored
168 },
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
169 author="Facebook",
170 author_email="python-tornado@googlegroups.com",
171 url="http://www.tornadoweb.org/",
172 license="http://www.apache.org/licenses/LICENSE-2.0",
9a193ae @bdarnell Update pypi description field.
bdarnell authored
173 description="Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.",
ff2e119 @bdarnell Add pypi classifiers so we'll show up on python3-compatible lists.
bdarnell authored
174 classifiers=[
175 'License :: OSI Approved :: Apache Software License',
176 'Programming Language :: Python :: 2',
177 'Programming Language :: Python :: 2.7',
178 'Programming Language :: Python :: 3',
179 'Programming Language :: Python :: 3.3',
bf2cf0e @bdarnell Add python 3.4 tag to setup.py
bdarnell authored
180 'Programming Language :: Python :: 3.4',
ff2e119 @bdarnell Add pypi classifiers so we'll show up on python3-compatible lists.
bdarnell authored
181 'Programming Language :: Python :: Implementation :: CPython',
182 'Programming Language :: Python :: Implementation :: PyPy',
183 ],
5e916c2 @bdarnell Automatically run 2to3 when installing on python 3
bdarnell authored
184 **kwargs
2afa973 @finiteloop Move Tornado project to Github
finiteloop authored
185 )
Something went wrong with that request. Please try again.