Debian Codegraph @

setup.py

raw ◀ ▶
Source reconstructed at patch state 0 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1
2 import ast
3 import codecs
4 import sys
5
6 from os.path import join, dirname
7 from setuptools import setup, find_packages, __version__ as setuptools_version
8 from pkg_resources import parse_version
9
10 import pkg_resources
11
12 try:
13 import _markerlib.markers
14 except ImportError:
15 _markerlib = None
16
17
18 # _markerlib.default_environment() obtains its data from _VARS
19 # and wraps it in another dict, but _markerlib_evaluate writes
20 # to the dict while it is iterating the keys, causing an error
21 # on Python 3 only.
22 # Replace _markerlib.default_environment to return a custom dict
23 # that has all the necessary markers, and ignores any writes.
24
25 class Python3MarkerDict(dict):
26
27 def __setitem__(self, key, value):
28 pass
29
30 def pop(self, i=-1):
31 return self[i]
32
33
34 if _markerlib and sys.version_info[0] == 3:
35 env = _markerlib.markers._VARS
36 for key in list(env.keys()):
37 new_key = key.replace('.', '_')
38 if new_key != key:
39 env[new_key] = env[key]
40
41 _markerlib.markers._VARS = Python3MarkerDict(env)
42
43 def default_environment():
44 return _markerlib.markers._VARS
45
46 _markerlib.default_environment = default_environment
47
48 # Avoid the very buggy pkg_resources.parser, which doesn't consistently
49 # recognise the markers needed by this setup.py
50 # Change this to setuptools 20.10.0 to support all markers.
51 if pkg_resources:
52 if parse_version(setuptools_version) < parse_version('18.5'):
53 MarkerEvaluation = pkg_resources.MarkerEvaluation
54
55 del pkg_resources.parser
56 pkg_resources.evaluate_marker = MarkerEvaluation._markerlib_evaluate
57 MarkerEvaluation.evaluate_marker = MarkerEvaluation._markerlib_evaluate
58
59 classifiers = [
60 'Development Status :: 5 - Production/Stable',
61 'Intended Audience :: Developers',
62 'License :: OSI Approved :: MIT License',
63 'Operating System :: OS Independent',
64 'Programming Language :: Python',
65 'Programming Language :: Python :: 3',
66 'Programming Language :: Python :: 3.8',
67 'Programming Language :: Python :: 3.9',
68 'Programming Language :: Python :: 3.10',
69 'Programming Language :: Python :: 3.11',
70 'Programming Language :: Python :: Implementation :: CPython',
71 'Programming Language :: Python :: Implementation :: PyPy',
72 'Topic :: Software Development :: Libraries :: Python Modules',
73 'Topic :: Text Processing :: Markup :: HTML'
74 ]
75
76 here = dirname(__file__)
77 with codecs.open(join(here, 'README.rst'), 'r', 'utf8') as readme_file:
78 with codecs.open(join(here, 'CHANGES.rst'), 'r', 'utf8') as changes_file:
79 long_description = readme_file.read() + '\n' + changes_file.read()
80
81 version = None
82 with open(join(here, "html5lib", "__init__.py"), "rb") as init_file:
83 t = ast.parse(init_file.read(), filename="__init__.py", mode="exec")
84 assert isinstance(t, ast.Module)
85 assignments = filter(lambda x: isinstance(x, ast.Assign), t.body)
86 for a in assignments:
87 if (len(a.targets) == 1 and
88 isinstance(a.targets[0], ast.Name) and
89 a.targets[0].id == "__version__" and
90 isinstance(a.value, ast.Str)):
91 version = a.value.s
92
93 setup(name='html5lib',
94 version=version,
95 url='https://github.com/html5lib/html5lib-python',
96 license="MIT License",
97 description='HTML parser based on the WHATWG HTML specification',
98 long_description=long_description,
99 classifiers=classifiers,
100 maintainer='James Graham',
101 maintainer_email='[email protected]',
102 packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
103 install_requires=[],
104 python_requires=">=3.8",
105 extras_require={
106 # A conditional extra will only install these items when the extra is
107 # requested and the condition matches.
108 "lxml:platform_python_implementation == 'CPython'": ["lxml>=3.4.0"],
109
110 # Standard extras, will be installed when the extra is requested.
111 "genshi": ["genshi>=0.7.1"],
112 "chardet": ["chardet>=2.2.1"],
113
114 # The all extra combines a standard extra which will be used anytime
115 # the all extra is requested, and it extends it with a conditional
116 # extra that will be installed whenever the condition matches and the
117 # all extra is requested.
118 "all": ["genshi>=0.7.1", "chardet>=2.2.1"],
119 "all:platform_python_implementation == 'CPython'": ["lxml>=3.4.0"],
120 },
121 )