I have cleaned up all the emacs support code for restructured text.
[docutils.git] / setup.py
blob24caa593c1423cdfb9be11db668807319adb64ff
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 import glob
8 from distutils.core import setup
9 from distutils.command.build_py import build_py
10 from distutils.command.install_data import install_data
13 class smart_install_data(install_data):
15 # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
16 # by Pete Shinners.
18 def run(self):
19 #need to change self.install_dir to the library dir
20 install_cmd = self.get_finalized_command('install')
21 self.install_dir = getattr(install_cmd, 'install_lib')
22 return install_data.run(self)
25 def do_setup():
26 kwargs = package_data.copy()
27 extras = get_extras()
28 if extras:
29 kwargs['py_modules'] = extras
30 if sys.hexversion >= 0x02030000: # Python 2.3
31 kwargs['classifiers'] = classifiers
32 else:
33 kwargs['cmdclass'] = {'build_py': dual_build_py}
34 dist = setup(**kwargs)
35 return dist
37 package_data = {
38 'name': 'docutils',
39 'description': 'Docutils -- Python Documentation Utilities',
40 'long_description': """\
41 Docutils is a modular system for processing documentation
42 into useful formats, such as HTML, XML, and LaTeX. For
43 input Docutils supports reStructuredText, an easy-to-read,
44 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
45 'url': 'http://docutils.sourceforge.net/',
46 'version': '0.3.10',
47 'author': 'David Goodger',
48 'author_email': 'goodger@users.sourceforge.net',
49 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
50 'platforms': 'OS-independent',
51 'cmdclass': {'install_data': smart_install_data},
52 'package_dir': {'docutils': 'docutils', '': 'extras'},
53 'packages': ['docutils',
54 'docutils.languages',
55 'docutils.parsers',
56 'docutils.parsers.rst',
57 'docutils.parsers.rst.directives',
58 'docutils.parsers.rst.languages',
59 'docutils.readers',
60 'docutils.readers.python',
61 'docutils.transforms',
62 'docutils.writers',
63 'docutils.writers.support',
64 'docutils.writers.support.newlatex2e'],
65 'data_files': [('docutils/parsers/rst/include',
66 glob.glob('docutils/parsers/rst/include/*.txt')),
67 ('docutils/writers/support',
68 ['docutils/writers/support/html4css1.css',
69 'docutils/writers/support/latex2e.tex']),
70 ('docutils/writers/support/newlatex2e',
71 ['docutils/writers/support/newlatex2e/base.tex']),
72 ('docutils/writers/support/pep_html',
73 ['docutils/writers/support/pep_html/pep.css',
74 'docutils/writers/support/pep_html/template.txt']),],
75 'scripts' : ['tools/rst2html.py',
76 'tools/rst2latex.py',
77 'tools/rst2newlatex.py',
78 'tools/rst2xml.py',
79 'tools/rst2pseudoxml.py'],}
80 """Distutils setup parameters."""
82 classifiers = [
83 'Development Status :: 3 - Alpha',
84 'Environment :: Console',
85 'Intended Audience :: End Users/Desktop',
86 'Intended Audience :: Other Audience',
87 'Intended Audience :: Developers',
88 'Intended Audience :: System Administrators',
89 'License :: Public Domain',
90 'License :: OSI Approved :: Python Software Foundation License',
91 'License :: OSI Approved :: BSD License',
92 'License :: OSI Approved :: GNU General Public License (GPL)',
93 'Operating System :: OS Independent',
94 'Programming Language :: Python',
95 'Topic :: Documentation',
96 'Topic :: Software Development :: Documentation',
97 'Topic :: Text Processing',
98 'Natural Language :: English', # main/default language, keep first
99 'Natural Language :: Afrikaans',
100 'Natural Language :: Esperanto',
101 'Natural Language :: French',
102 'Natural Language :: German',
103 'Natural Language :: Italian',
104 'Natural Language :: Russian',
105 'Natural Language :: Slovak',
106 'Natural Language :: Spanish',
107 'Natural Language :: Swedish',]
108 """Trove classifiers for the Distutils "register" command;
109 Python 2.3 and up."""
111 extra_modules = [('optparse', '1.4.1', None),
112 ('textwrap', None, None),
113 ('roman', '1.4', ['toRoman', 'fromRoman',
114 'InvalidRomanNumeralError'])]
115 """Third-party modules to install if they're not already present.
116 List of (module name, minimum __version__ string, [attribute names])."""
118 def get_extras():
119 extras = []
120 for module_name, version, attributes in extra_modules:
121 try:
122 module = __import__(module_name)
123 if version and module.__version__ < version:
124 raise ValueError
125 for attribute in attributes or []:
126 getattr(module, attribute)
127 print ('"%s" module already present; ignoring extras/%s.py.'
128 % (module_name, module_name))
129 except (ImportError, AttributeError, ValueError):
130 extras.append(module_name)
131 return extras
134 class dual_build_py(build_py):
137 This class allows the distribution of both packages *and* modules with one
138 call to `distutils.core.setup()` (necessary for pre-2.3 Python). Thanks
139 to Thomas Heller.
142 def run(self):
143 if not self.py_modules and not self.packages:
144 return
145 if self.py_modules:
146 self.build_modules()
147 if self.packages:
148 self.build_packages()
149 self.byte_compile(self.get_outputs(include_bytecode=0))
152 if __name__ == '__main__' :
153 do_setup()