added history entries for changed transition handling
[docutils.git] / setup.py
blob66c90c3d7a27a9b55346b21b7ab6253c4d44c19a
1 #!/usr/bin/env python
2 # $Id$
3 # Copyright: This file has been placed in the public domain.
5 import sys
6 import os
7 from distutils.core import setup
8 from distutils.command.build_py import build_py
11 def do_setup():
12 kwargs = package_data.copy()
13 extras = get_extras()
14 if extras:
15 kwargs['py_modules'] = extras
16 if sys.hexversion >= 0x02030000: # Python 2.3
17 kwargs['classifiers'] = classifiers
18 else:
19 kwargs['cmdclass'] = {'build_py': dual_build_py}
20 dist = setup(**kwargs)
21 return dist
23 package_data = {
24 'name': 'docutils',
25 'description': 'Docutils -- Python Documentation Utilities',
26 'long_description': """\
27 Docutils is a modular system for processing documentation
28 into useful formats, such as HTML, XML, and LaTeX. For
29 input Docutils supports reStructuredText, an easy-to-read,
30 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
31 'url': 'http://docutils.sourceforge.net/',
32 'version': '0.3.6',
33 'author': 'David Goodger',
34 'author_email': 'goodger@users.sourceforge.net',
35 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
36 'platforms': 'OS-independent',
37 'package_dir': {'docutils': 'docutils', '': 'extras'},
38 'packages': ['docutils', 'docutils.languages',
39 'docutils.parsers', 'docutils.parsers.rst',
40 'docutils.parsers.rst.directives',
41 'docutils.parsers.rst.languages',
42 'docutils.readers', 'docutils.readers.python',
43 'docutils.transforms',
44 'docutils.writers',],
45 'scripts' : ['tools/rst2html.py','tools/rst2latex.py'],}
46 """Distutils setup parameters."""
48 classifiers = [
49 'Development Status :: 3 - Alpha',
50 'Environment :: Console',
51 'Intended Audience :: End Users/Desktop',
52 'Intended Audience :: Other Audience',
53 'Intended Audience :: Developers',
54 'Intended Audience :: System Administrators',
55 'License :: Public Domain',
56 'License :: OSI Approved :: Python Software Foundation License',
57 'License :: OSI Approved :: BSD License',
58 'License :: OSI Approved :: GNU General Public License (GPL)',
59 'Operating System :: OS Independent',
60 'Programming Language :: Python',
61 'Topic :: Documentation',
62 'Topic :: Software Development :: Documentation',
63 'Topic :: Text Processing',
64 'Natural Language :: English', # main/default language, keep first
65 'Natural Language :: Afrikaans',
66 'Natural Language :: Esperanto',
67 'Natural Language :: French',
68 'Natural Language :: German',
69 'Natural Language :: Italian',
70 'Natural Language :: Russian',
71 'Natural Language :: Slovak',
72 'Natural Language :: Spanish',
73 'Natural Language :: Swedish',]
74 """Trove classifiers for the Distutils "register" command;
75 Python 2.3 and up."""
77 extra_modules = [('optparse', '1.4.1', None),
78 ('textwrap', None, None),
79 ('roman', '1.4', ['toRoman', 'fromRoman',
80 'InvalidRomanNumeralError'])]
81 """Third-party modules to install if they're not already present.
82 List of (module name, minimum __version__ string, [attribute names])."""
84 def get_extras():
85 extras = []
86 for module_name, version, attributes in extra_modules:
87 try:
88 module = __import__(module_name)
89 if version and module.__version__ < version:
90 raise ValueError
91 for attribute in attributes or []:
92 getattr(module, attribute)
93 print ('"%s" module already present; ignoring extras/%s.py.'
94 % (module_name, module_name))
95 except (ImportError, AttributeError, ValueError):
96 extras.append(module_name)
97 return extras
100 class dual_build_py(build_py):
103 This class allows the distribution of both packages *and* modules with one
104 call to `distutils.core.setup()` (necessary for pre-2.3 Python). Thanks
105 to Thomas Heller.
108 def run(self):
109 if not self.py_modules and not self.packages:
110 return
111 if self.py_modules:
112 self.build_modules()
113 if self.packages:
114 self.build_packages()
115 self.byte_compile(self.get_outputs(include_bytecode=0))
118 if __name__ == '__main__' :
119 do_setup()