|
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=[ |
|
23 | 21 | 'Topic :: Text Processing :: Markup :: HTML' |
24 | 22 | ] |
25 | 23 |
|
26 | | -packages = ['html5lib'] + ['html5lib.'+name |
27 | | - for name in os.listdir(os.path.join('html5lib')) |
28 | | - if os.path.isdir(os.path.join('html5lib', name)) and |
29 | | - not name.startswith('.') and name != 'tests'] |
30 | | - |
31 | | -current_dir = os.path.dirname(__file__) |
32 | | -with codecs.open(os.path.join(current_dir, 'README.rst'), 'r', 'utf8') as readme_file: |
33 | | - with codecs.open(os.path.join(current_dir, 'CHANGES.rst'), 'r', 'utf8') as changes_file: |
| 24 | +here = dirname(__file__) |
| 25 | +with codecs.open(join(here, 'README.rst'), 'r', 'utf8') as readme_file: |
| 26 | + with codecs.open(join(here, 'CHANGES.rst'), 'r', 'utf8') as changes_file: |
34 | 27 | long_description = readme_file.read() + '\n' + changes_file.read() |
35 | 28 |
|
36 | 29 | version = None |
37 | | -with open(os.path.join("html5lib", "__init__.py"), "rb") as init_file: |
38 | | - t = ast.parse(init_file.read(), filename="__init__.py", mode="exec") |
39 | | - assert isinstance(t, ast.Module) |
40 | | - assignments = filter(lambda x: isinstance(x, ast.Assign), t.body) |
41 | | - for a in assignments: |
42 | | - if (len(a.targets) == 1 and |
43 | | - isinstance(a.targets[0], ast.Name) and |
44 | | - a.targets[0].id == "__version__" and |
45 | | - isinstance(a.value, ast.Str)): |
46 | | - version = a.value.s |
| 30 | +with open(join(here, 'html5lib', '__init__.py')) as fp: |
| 31 | + for line in fp: |
| 32 | + _locals = {} |
| 33 | + if line.startswith('__version__'): |
| 34 | + exec(line, None, _locals) |
| 35 | + version = _locals['__version__'] |
| 36 | + break |
47 | 37 |
|
48 | 38 | setup(name='html5lib', |
49 | 39 | version=version, |
|
54 | 44 | classifiers=classifiers, |
55 | 45 | maintainer='James Graham', |
56 | 46 | maintainer_email='james@hoppipolla.co.uk', |
57 | | - packages=packages, |
| 47 | + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), |
58 | 48 | install_requires=[ |
59 | 49 | 'six', |
60 | 50 | ], |
|
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