-
Notifications
You must be signed in to change notification settings - Fork 107
/
Copy pathsetup.py
85 lines (80 loc) · 2.66 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
import os
from setuptools import setup, find_packages, Extension
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
def no_cythonize(extensions, **_ignore):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in (".pyx", ".py"):
if extension.language == "c++":
ext = ".cpp"
else:
ext = ".c"
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
extensions = [
Extension(f"w3lib._{name}", [f"w3lib/_{name}.pyx"])
for name in (
"infra",
"rfc2396",
"rfc3986",
"rfc5892",
"types",
"url",
"util",
"utr46",
)
]
if bool(int(os.getenv("CYTHONIZE", 0))):
from Cython.Build import cythonize
compiler_directives = {
"language_level": 3,
"profile": bool(int(os.getenv("CYTHON_PROFILE", 0))),
}
extensions = cythonize(extensions, compiler_directives=compiler_directives, force=bool(int(os.getenv("CYTHON_FORCE", 0))))
else:
extensions = no_cythonize(extensions)
setup(
name="w3lib",
version="2.1.2",
license="BSD",
description="Library of web-related functions",
author="Scrapy project",
author_email="[email protected]",
url="https://github.com/scrapy/w3lib",
project_urls={
"Documentation": "https://w3lib.readthedocs.io/en/latest/",
"Source Code": "https://github.com/scrapy/w3lib",
"Issue Tracker": "https://github.com/scrapy/w3lib/issues",
},
packages=find_packages(exclude=("tests", "tests.*")),
package_data={
"w3lib": ["py.typed"],
},
include_package_data=True,
zip_safe=False,
platforms=["Any"],
python_requires=">=3.8",
install_requires=[
"idna",
],
ext_modules=extensions,
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP",
],
)