-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
120 lines (105 loc) · 3.76 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
#!/usr/bin/env python
import multiprocessing
import os
import platform
import re
import sys
from setuptools import setup
extra = {"ext_modules": []}
try:
from Cython.Build import cythonize
p = os.path.join("src", "wheezy", "html")
extra["ext_modules"] += cythonize(
[os.path.join(p, "*.py"), os.path.join(p, "ext", "*.py")],
exclude=[
os.path.join(p, "__init__.py"),
os.path.join(p, "ext", "__init__.py"),
],
# https://github.com/cython/cython/issues/3262
nthreads=0 if multiprocessing.get_start_method() == "spawn" else 2,
compiler_directives={"language_level": 3},
quiet=True,
)
except ImportError:
pass
can_build_ext = (
getattr(platform, "python_implementation", lambda: None)() != "PyPy"
and "java" not in sys.platform
)
if can_build_ext: # noqa: C901
from distutils.command.build_ext import build_ext # noqa
from distutils.core import Extension # noqa
sources = [os.path.join("src", "wheezy", "html", "boost.c")]
extra["ext_modules"] += [Extension("wheezy.html.boost", sources)]
class BuildExtOptional(build_ext):
def run(self):
from distutils.errors import DistutilsPlatformError
try:
build_ext.run(self)
except DistutilsPlatformError:
self.warn()
def build_extension(self, ext):
from distutils.errors import CCompilerError, DistutilsExecError
try:
build_ext.build_extension(self, ext)
except (CCompilerError, DistutilsExecError):
self.warn()
def warn(self):
print(" WARNING ".center(44, "*"))
print("An optional extension could not be compiled.")
extra["cmdclass"] = {"build_ext": BuildExtOptional}
README = open(os.path.join(os.path.dirname(__file__), "README.md")).read()
VERSION = (
re.search(
r'__version__ = "(.+)"',
open("src/wheezy/html/__init__.py").read(),
)
.group(1)
.strip()
)
setup(
name="wheezy.html",
version=VERSION,
python_requires=">=3.9",
description="A lightweight html rendering library",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/akornatskyy/wheezy.html",
author="Andriy Kornatskyy",
author_email="[email protected]",
license="MIT",
classifiers=[
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Widget Sets",
"Topic :: Text Processing :: Markup :: HTML",
],
keywords="html widget markup mako jinja2 tenjin wheezy.template "
"preprocessor",
packages=["wheezy", "wheezy.html", "wheezy.html.ext"],
package_dir={"": "src"},
namespace_packages=["wheezy"],
zip_safe=False,
extras_require={
"mako": ["mako>=0.7.0"],
"tenjin": ["tenjin>=1.1.0"],
"jinja2": ["jinja2>=2.6"],
"wheezy.template": ["wheezy.template>=0.1.88"],
},
platforms="any",
**extra
)