Put ensuremath around some latin1 chars.
[docutils.git] / setup.py
blob46daaeb71b2c8b06d5f54a97ca0208506265b083
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 try:
9 from distutils.core import setup
10 from distutils.command.build_py import build_py
11 from distutils.command.install_data import install_data
12 except ImportError:
13 print 'Error: The "distutils" standard module, which is required for the '
14 print 'installation of Docutils, could not be found. You may need to '
15 print 'install a package called "python-devel" (or similar) on your '
16 print 'system using your package manager.'
17 sys.exit(1)
19 if sys.hexversion < 0x02030000:
20 # Hack for Python < 2.3.
21 # From <http://groups.google.de/groups?as_umsgid=f70e3538.0404141327.6cea58ca@posting.google.com>.
22 from distutils.command.install import INSTALL_SCHEMES
23 for scheme in INSTALL_SCHEMES.values():
24 scheme['data'] = scheme['purelib']
27 class smart_install_data(install_data):
29 # Hack for Python > 2.3.
30 # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
31 # by Pete Shinners.
33 def run(self):
34 #need to change self.install_dir to the library dir
35 install_cmd = self.get_finalized_command('install')
36 self.install_dir = getattr(install_cmd, 'install_lib')
37 return install_data.run(self)
40 def do_setup():
41 kwargs = package_data.copy()
42 extras = get_extras()
43 if extras:
44 kwargs['py_modules'] = extras
45 if sys.hexversion >= 0x02030000: # Python 2.3
46 kwargs['classifiers'] = classifiers
47 # Install data files properly. Note that we use a different
48 # hack for Python 2.2, which does not *always* work, though;
49 # see
50 # <http://article.gmane.org/gmane.text.docutils.user/2867>.
51 # So for Python 2.3+, we prefer this hack.
52 kwargs['cmdclass'] = {'install_data': smart_install_data}
53 else:
54 # Install data files properly. (Another hack for Python 2.2
55 # is at the top of this file.)
56 kwargs['cmdclass'] = {'build_py': dual_build_py}
57 dist = setup(**kwargs)
58 return dist
60 s5_theme_files = []
61 for dir in glob.glob('docutils/writers/s5_html/themes/*'):
62 if os.path.isdir(dir):
63 theme_files = glob.glob('%s/*' % dir)
64 s5_theme_files.append((dir, theme_files))
66 package_data = {
67 'name': 'docutils',
68 'description': 'Docutils -- Python Documentation Utilities',
69 'long_description': """\
70 Docutils is a modular system for processing documentation
71 into useful formats, such as HTML, XML, and LaTeX. For
72 input Docutils supports reStructuredText, an easy-to-read,
73 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
74 'url': 'http://docutils.sourceforge.net/',
75 'version': '0.5',
76 'author': 'David Goodger',
77 'author_email': 'goodger@python.org',
78 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
79 'platforms': 'OS-independent',
80 'package_dir': {'docutils': 'docutils', '': 'extras'},
81 'packages': ['docutils',
82 'docutils.languages',
83 'docutils.parsers',
84 'docutils.parsers.rst',
85 'docutils.parsers.rst.directives',
86 'docutils.parsers.rst.languages',
87 'docutils.readers',
88 'docutils.readers.python',
89 'docutils.transforms',
90 'docutils.writers',
91 'docutils.writers.html4css1',
92 'docutils.writers.pep_html',
93 'docutils.writers.s5_html',
94 'docutils.writers.latex2e',
95 'docutils.writers.newlatex2e'],
96 'data_files': ([('docutils/parsers/rst/include',
97 glob.glob('docutils/parsers/rst/include/*.txt')),
98 ('docutils/writers/html4css1',
99 ['docutils/writers/html4css1/html4css1.css',
100 'docutils/writers/html4css1/template.txt']),
101 ('docutils/writers/latex2e',
102 ['docutils/writers/latex2e/latex2e.tex']),
103 ('docutils/writers/newlatex2e',
104 ['docutils/writers/newlatex2e/base.tex']),
105 ('docutils/writers/pep_html',
106 ['docutils/writers/pep_html/pep.css',
107 'docutils/writers/pep_html/template.txt']),
108 ('docutils/writers/s5_html/themes',
109 ['docutils/writers/s5_html/themes/README.txt']),]
110 + s5_theme_files),
111 'scripts' : ['tools/rst2html.py',
112 'tools/rst2s5.py',
113 'tools/rst2latex.py',
114 'tools/rst2newlatex.py',
115 'tools/rst2xml.py',
116 'tools/rst2pseudoxml.py'],}
117 """Distutils setup parameters."""
119 classifiers = [
120 'Development Status :: 3 - Alpha',
121 'Environment :: Console',
122 'Intended Audience :: End Users/Desktop',
123 'Intended Audience :: Other Audience',
124 'Intended Audience :: Developers',
125 'Intended Audience :: System Administrators',
126 'License :: Public Domain',
127 'License :: OSI Approved :: Python Software Foundation License',
128 'License :: OSI Approved :: BSD License',
129 'License :: OSI Approved :: GNU General Public License (GPL)',
130 'Operating System :: OS Independent',
131 'Programming Language :: Python',
132 'Topic :: Documentation',
133 'Topic :: Software Development :: Documentation',
134 'Topic :: Text Processing',
135 'Natural Language :: English', # main/default language, keep first
136 'Natural Language :: Afrikaans',
137 'Natural Language :: Esperanto',
138 'Natural Language :: French',
139 'Natural Language :: German',
140 'Natural Language :: Italian',
141 'Natural Language :: Russian',
142 'Natural Language :: Slovak',
143 'Natural Language :: Spanish',
144 'Natural Language :: Swedish',]
145 """Trove classifiers for the Distutils "register" command;
146 Python 2.3 and up."""
148 extra_modules = [('optparse', '1.4.1', None),
149 ('textwrap', None, None),
150 ('roman', '1.4', ['toRoman', 'fromRoman',
151 'InvalidRomanNumeralError'])]
152 """Third-party modules to install if they're not already present.
153 List of (module name, minimum __version__ string, [attribute names])."""
155 def get_extras():
156 extras = []
157 for module_name, version, attributes in extra_modules:
158 try:
159 module = __import__(module_name)
160 if version and module.__version__ < version:
161 raise ValueError
162 for attribute in attributes or []:
163 getattr(module, attribute)
164 print ('"%s" module already present; ignoring extras/%s.py.'
165 % (module_name, module_name))
166 except (ImportError, AttributeError, ValueError):
167 extras.append(module_name)
168 return extras
171 class dual_build_py(build_py):
174 This class allows the distribution of both packages *and* modules with one
175 call to `distutils.core.setup()` (necessary for pre-2.3 Python). Thanks
176 to Thomas Heller.
179 def run(self):
180 if not self.py_modules and not self.packages:
181 return
182 if self.py_modules:
183 self.build_modules()
184 if self.packages:
185 self.build_packages()
186 self.byte_compile(self.get_outputs(include_bytecode=0))
189 if __name__ == '__main__' :
190 do_setup()