]>
Commit | Line | Data |
---|---|---|
2afa9734 BT |
1 | # |
2 | # Copyright 2009 Facebook | |
3 | # | |
4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may | |
5 | # not use this file except in compliance with the License. You may obtain | |
6 | # a copy of the License at | |
7 | # | |
8 | # http://www.apache.org/licenses/LICENSE-2.0 | |
9 | # | |
10 | # Unless required by applicable law or agreed to in writing, software | |
11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
13 | # License for the specific language governing permissions and limitations | |
14 | # under the License. | |
15 | ||
44ae52ce BD |
16 | # type: ignore |
17 | ||
70659cbc | 18 | import os |
0ca7fa01 | 19 | import platform |
e71fb6e6 | 20 | import setuptools |
4a5fdb1e | 21 | |
3b181f54 | 22 | try: |
e71fb6e6 | 23 | import wheel.bdist_wheel |
3b181f54 | 24 | except ImportError: |
e71fb6e6 | 25 | wheel = None |
4ec9831f BD |
26 | |
27 | ||
5e916c27 BD |
28 | kwargs = {} |
29 | ||
32117141 BD |
30 | with open("tornado/__init__.py") as f: |
31 | ns = {} | |
32 | exec(f.read(), ns) | |
33 | version = ns["version"] | |
34f04945 | 34 | |
4824f41a BD |
35 | with open("README.rst") as f: |
36 | kwargs["long_description"] = f.read() | |
9d3e0e44 | 37 | kwargs["long_description_content_type"] = "text/x-rst" |
6a8bfce5 | 38 | |
4824f41a BD |
39 | if ( |
40 | platform.python_implementation() == "CPython" | |
41 | and os.environ.get("TORNADO_EXTENSION") != "0" | |
42 | ): | |
0ca7fa01 BD |
43 | # This extension builds and works on pypy as well, although pypy's jit |
44 | # produces equivalent performance. | |
4824f41a | 45 | kwargs["ext_modules"] = [ |
e71fb6e6 BD |
46 | setuptools.Extension( |
47 | "tornado.speedups", | |
48 | sources=["tornado/speedups.c"], | |
49 | # Unless the user has specified that the extension is mandatory, | |
50 | # fall back to the pure-python implementation on any build failure. | |
51 | optional=os.environ.get("TORNADO_EXTENSION") != "1", | |
52 | # Use the stable ABI so our wheels are compatible across python | |
53 | # versions. | |
54 | py_limited_api=True, | |
aa59da6e | 55 | define_macros=[("Py_LIMITED_API", "0x03080000")], |
e71fb6e6 | 56 | ) |
0ca7fa01 | 57 | ] |
4a5fdb1e | 58 | |
e71fb6e6 BD |
59 | if wheel is not None: |
60 | # From https://github.com/joerick/python-abi3-package-sample/blob/main/setup.py | |
61 | class bdist_wheel_abi3(wheel.bdist_wheel.bdist_wheel): | |
62 | def get_tag(self): | |
63 | python, abi, plat = super().get_tag() | |
64 | ||
65 | if python.startswith("cp"): | |
aa59da6e | 66 | return "cp38", "abi3", plat |
e71fb6e6 | 67 | return python, abi, plat |
70659cbc | 68 | |
e71fb6e6 | 69 | kwargs["cmdclass"] = {"bdist_wheel": bdist_wheel_abi3} |
ec4b7e46 | 70 | |
be5d8114 | 71 | |
e71fb6e6 | 72 | setuptools.setup( |
2afa9734 | 73 | name="tornado", |
34f04945 | 74 | version=version, |
aa59da6e | 75 | python_requires=">= 3.8", |
fe9037a1 BD |
76 | packages=["tornado", "tornado.test", "tornado.platform"], |
77 | package_data={ | |
489997d1 BD |
78 | # data files need to be listed both here (which determines what gets |
79 | # installed) and in MANIFEST.in (which determines what gets included | |
80 | # in the sdist tarball) | |
2d5ba2fa | 81 | "tornado": ["py.typed"], |
489997d1 BD |
82 | "tornado.test": [ |
83 | "README", | |
489997d1 BD |
84 | "csv_translations/fr_FR.csv", |
85 | "gettext_translations/fr_FR/LC_MESSAGES/tornado_test.mo", | |
86 | "gettext_translations/fr_FR/LC_MESSAGES/tornado_test.po", | |
dd388bf1 | 87 | "options_test.cfg", |
4576fb07 | 88 | "options_test_types.cfg", |
5b8f6103 | 89 | "options_test_types_str.cfg", |
dd388bf1 | 90 | "static/robots.txt", |
3a881d9c AE |
91 | "static/sample.xml", |
92 | "static/sample.xml.gz", | |
93 | "static/sample.xml.bz2", | |
1ccf71a5 | 94 | "static/dir/index.html", |
ecb3ea75 | 95 | "static_foo.txt", |
dd388bf1 BD |
96 | "templates/utf8.html", |
97 | "test.crt", | |
98 | "test.key", | |
2d5ba2fa | 99 | ], |
48e042f2 | 100 | }, |
2afa9734 BT |
101 | author="Facebook", |
102 | author_email="python-tornado@googlegroups.com", | |
103 | url="http://www.tornadoweb.org/", | |
4417599b AO |
104 | project_urls={ |
105 | "Source": "https://github.com/tornadoweb/tornado", | |
106 | }, | |
60a48010 | 107 | license="Apache-2.0", |
4824f41a BD |
108 | description=( |
109 | "Tornado is a Python web framework and asynchronous networking library," | |
110 | " originally developed at FriendFeed." | |
111 | ), | |
ff2e119a | 112 | classifiers=[ |
4824f41a BD |
113 | "License :: OSI Approved :: Apache Software License", |
114 | "Programming Language :: Python :: 3", | |
bdf8b286 | 115 | "Programming Language :: Python :: 3.8", |
2d85002b | 116 | "Programming Language :: Python :: 3.9", |
1f8aab8b | 117 | "Programming Language :: Python :: 3.10", |
2ef1fd31 | 118 | "Programming Language :: Python :: 3.11", |
09efc06e | 119 | "Programming Language :: Python :: 3.12", |
4824f41a BD |
120 | "Programming Language :: Python :: Implementation :: CPython", |
121 | "Programming Language :: Python :: Implementation :: PyPy", | |
48e042f2 | 122 | ], |
5e916c27 | 123 | **kwargs |
2afa9734 | 124 | ) |