|
1 | | -import ast |
2 | | -import os |
3 | 1 | import codecs |
4 | | - |
5 | | -from setuptools import setup |
| 2 | +from os.path import join, dirname |
| 3 | +from setuptools import setup, find_packages |
6 | 4 |
|
7 | 5 |
|
8 | 6 | classifiers=[ |
|
22 | 20 | 'Topic :: Text Processing :: Markup :: HTML' |
23 | 21 | ] |
24 | 22 |
|
25 | | -packages = ['html5lib'] + ['html5lib.'+name |
26 | | - for name in os.listdir(os.path.join('html5lib')) |
27 | | - if os.path.isdir(os.path.join('html5lib', name)) and |
28 | | - not name.startswith('.') and name != 'tests'] |
29 | | - |
30 | | -current_dir = os.path.dirname(__file__) |
31 | | -with codecs.open(os.path.join(current_dir, 'README.rst'), 'r', 'utf8') as readme_file: |
32 | | - with codecs.open(os.path.join(current_dir, 'CHANGES.rst'), 'r', 'utf8') as changes_file: |
| 23 | +here = dirname(__file__) |
| 24 | +with codecs.open(join(here, 'README.rst'), 'r', 'utf8') as readme_file: |
| 25 | + with codecs.open(join(here, 'CHANGES.rst'), 'r', 'utf8') as changes_file: |
33 | 26 | long_description = readme_file.read() + '\n' + changes_file.read() |
34 | 27 |
|
35 | 28 | version = None |
36 | | -with open(os.path.join("html5lib", "__init__.py"), "rb") as init_file: |
37 | | - t = ast.parse(init_file.read(), filename="__init__.py", mode="exec") |
38 | | - assert isinstance(t, ast.Module) |
39 | | - assignments = filter(lambda x: isinstance(x, ast.Assign), t.body) |
40 | | - for a in assignments: |
41 | | - if (len(a.targets) == 1 and |
42 | | - isinstance(a.targets[0], ast.Name) and |
43 | | - a.targets[0].id == "__version__" and |
44 | | - isinstance(a.value, ast.Str)): |
45 | | - version = a.value.s |
| 29 | +with open(join(here, 'html5lib', '__init__.py')) as fp: |
| 30 | + for line in fp: |
| 31 | + _locals = {} |
| 32 | + if line.startswith('__version__'): |
| 33 | + exec(line, None, _locals) |
| 34 | + version = _locals['__version__'] |
| 35 | + break |
46 | 36 |
|
47 | 37 | setup(name='html5lib', |
48 | 38 | version=version, |
|
53 | 43 | classifiers=classifiers, |
54 | 44 | maintainer='James Graham', |
55 | 45 | maintainer_email='james@hoppipolla.co.uk', |
56 | | - packages=packages, |
| 46 | + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), |
57 | 47 | install_requires=[ |
58 | 48 | 'six', |
59 | 49 | 'webencodings', |
|
70 | 60 |
|
71 | 61 | # Standard extras, will be installed when the extra is requested. |
72 | 62 | "genshi": ["genshi"], |
73 | | - "charade": ["charade"], |
| 63 | + "chardet": ["chardet>=2.2"], |
74 | 64 |
|
75 | 65 | # The all extra combines a standard extra which will be used anytime |
76 | 66 | # the all extra is requested, and it extends it with a conditional |
77 | 67 | # extra that will be installed whenever the condition matches and the |
78 | 68 | # all extra is requested. |
79 | | - "all": ["genshi", "charade"], |
| 69 | + "all": ["genshi", "chardet>=2.2"], |
80 | 70 | "all:python_implementation == 'CPython'": ["datrie", "lxml"], |
81 | 71 | }, |
82 | 72 | ) |
0 commit comments