forked from aio-libs/yarl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
91 lines (74 loc) · 2.57 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
import os
import pathlib
import re
import sys
from setuptools import Extension, setup
NO_EXTENSIONS = bool(os.environ.get("YARL_NO_EXTENSIONS")) # type: bool
if sys.implementation.name != "cpython":
NO_EXTENSIONS = True
extensions = [Extension("yarl._quoting_c", ["yarl/_quoting_c.c"])]
# extra_compile_args=["-g"],
# extra_link_args=["-g"],
here = pathlib.Path(__file__).parent
fname = here / "yarl" / "__init__.py"
with fname.open(encoding="utf8") as fp:
try:
version = re.findall(r'^__version__ = "([^"]+)"$', fp.read(), re.M)[0]
except IndexError:
raise RuntimeError("Unable to determine version.")
install_requires = [
"multidict>=4.0",
"idna>=2.0",
'typing-extensions>=3.7.4;python_version<"3.8"',
]
def read(name):
fname = here / name
with fname.open(encoding="utf8") as f:
return f.read()
# $ echo ':something:`test <sdf>`' | sed 's/:\w\+:`\(\w\+\)\(\s\+\(.*\)\)\?`/``\1``/g'
# ``test``
def sanitize_rst_roles(rst_source_text: str) -> str:
"""Replace RST roles with inline highlighting."""
role_regex = r":\w+:`(?P<rendered_text>[^`]+)(\s+(.*))?`"
substitution_pattern = r"``(?P=rendered_text)``"
return re.sub(role_regex, substitution_pattern, rst_source_text)
args = dict(
name="yarl",
version=version,
description=("Yet another URL library"),
long_description="\n\n".join(
[read("README.rst"), sanitize_rst_roles(read("CHANGES.rst"))]
),
long_description_content_type="text/x-rst",
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
],
author="Andrew Svetlov",
author_email="[email protected]",
url="https://github.com/aio-libs/yarl/",
license="Apache 2",
packages=["yarl"],
install_requires=install_requires,
python_requires=">=3.7",
include_package_data=True,
exclude_package_data={"": ["*.c"]},
)
if not NO_EXTENSIONS:
print("**********************")
print("* Accelerated build *")
print("**********************")
setup(ext_modules=extensions, **args)
else:
print("*********************")
print("* Pure Python build *")
print("*********************")
setup(**args)