announce change of default behaviour and deprecation of `handle_io_errors`
[docutils.git] / setup.py
blobaa12eba07aaca3ed2bfe4a583ac6ceb4ad2c8c68
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, Command
10 from distutils.command.build import build
11 from distutils.command.build_py import build_py
12 if sys.version_info >= (3,):
13 from distutils.command.build_py import build_py_2to3
14 from distutils.util import copydir_run_2to3
15 from distutils.command.install_data import install_data
16 from distutils.util import convert_path
17 from distutils import log
18 except ImportError:
19 print ('Error: The "distutils" standard module, which is required for the ')
20 print ('installation of Docutils, could not be found. You may need to ')
21 print ('install a package called "python-devel" (or similar) on your ')
22 print ('system using your package manager.')
23 sys.exit(1)
26 if sys.version_info >= (3,):
27 # copy-convert auxiliary python sources
28 class copy_build_py_2to3(build_py_2to3):
29 """Copy/convert Python source files in given directories recursively.
31 Build py3k versions of the modules and packages. Also copy
32 'tools/' and 'test/' dirs and run 2to3 on *.py files.
33 """
34 manifest_in = """\
35 exclude *.pyc *~ .DS_Store
36 recursive-exclude * *.pyc *~ .DS_Store
37 recursive-exclude functional/output *
38 include functional/output/README.txt
39 prune .svn
40 prune */.svn
41 prune */*/.svn
42 prune */*/*/.svn
43 prune */*/*/*/.svn
44 prune */*/*/*/*/.svn
45 """
46 def run(self):
47 build_py_2to3.run(self)
48 print("copying aux dirs")
49 loglevel = log.set_threshold(log.ERROR)
50 for source in ['tools', 'test']:
51 dest = os.path.join(self.build_lib, source)
52 copydir_run_2to3(source, dest, template=self.manifest_in)
53 log.set_threshold(loglevel)
56 class smart_install_data(install_data):
57 # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
58 # by Pete Shinners.
60 def run(self):
61 #need to change self.install_dir to the library dir
62 install_cmd = self.get_finalized_command('install')
63 self.install_dir = getattr(install_cmd, 'install_lib')
64 return install_data.run(self)
66 class build_data(Command):
68 def initialize_options(self):
69 pass
71 def finalize_options(self):
72 pass
74 def run(self):
75 build_py = self.get_finalized_command('build_py')
76 data_files = self.distribution.data_files
77 for f in data_files:
78 dir = convert_path(f[0])
79 dir = os.path.join(build_py.build_lib, dir)
80 self.mkpath(dir)
81 for data in f[1]:
82 data = convert_path(data)
83 self.copy_file(data, dir)
85 # let our build_data run
86 build.sub_commands.append(('build_data', lambda *a: True))
89 def do_setup():
90 kwargs = package_data.copy()
91 kwargs['classifiers'] = classifiers
92 # Install data files properly.
93 kwargs['cmdclass'] = {'build_data': build_data,
94 'install_data': smart_install_data}
95 # Auto-convert source code for Python 3
96 if sys.version_info >= (3,):
97 kwargs['cmdclass']['build_py'] = copy_build_py_2to3
98 else:
99 kwargs['cmdclass']['build_py'] = build_py
100 dist = setup(**kwargs)
101 return dist
103 s5_theme_files = []
104 for dir in glob.glob('docutils/writers/s5_html/themes/*'):
105 if os.path.isdir(dir):
106 theme_files = glob.glob('%s/*' % dir)
107 s5_theme_files.append((dir, theme_files))
109 package_data = {
110 'name': 'docutils',
111 'description': 'Docutils -- Python Documentation Utilities',
112 'long_description': """\
113 Docutils is a modular system for processing documentation
114 into useful formats, such as HTML, XML, and LaTeX. For
115 input Docutils supports reStructuredText, an easy-to-read,
116 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
117 'url': 'http://docutils.sourceforge.net/',
118 'version': '0.9',
119 'author': 'David Goodger',
120 'author_email': 'goodger@python.org',
121 'license': 'public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)',
122 'platforms': 'OS-independent',
123 'package_dir': {'docutils': 'docutils',
124 'docutils.tools': 'tools'},
125 'packages': ['docutils',
126 'docutils.languages',
127 'docutils.parsers',
128 'docutils.parsers.rst',
129 'docutils.parsers.rst.directives',
130 'docutils.parsers.rst.languages',
131 'docutils.readers',
132 # 'docutils.readers.python', # in the sandbox since 0.8
133 'docutils.transforms',
134 'docutils.utils',
135 'docutils.math',
136 'docutils.writers',
137 'docutils.writers.html4css1',
138 # 'docutils.writers.html4strict', # in the sandbox!
139 'docutils.writers.pep_html',
140 'docutils.writers.s5_html',
141 'docutils.writers.latex2e',
142 # 'docutils.writers.newlatex2e', # in the sandbox since 0.8
143 'docutils.writers.xetex',
144 'docutils.writers.odf_odt',
146 'data_files': ([('docutils/parsers/rst/include',
147 glob.glob('docutils/parsers/rst/include/*.txt')),
148 ('docutils/writers/html4css1',
149 ['docutils/writers/html4css1/html4css1.css',
150 'docutils/writers/html4css1/template.txt']),
151 ('docutils/writers/latex2e',
152 ['docutils/writers/latex2e/default.tex',
153 'docutils/writers/latex2e/titlepage.tex',
154 'docutils/writers/latex2e/xelatex.tex',]),
155 ('docutils/writers/pep_html',
156 ['docutils/writers/pep_html/pep.css',
157 'docutils/writers/pep_html/template.txt']),
158 ('docutils/writers/s5_html/themes',
159 ['docutils/writers/s5_html/themes/README.txt']),
160 ('docutils/writers/odf_odt',
161 ['docutils/writers/odf_odt/styles.odt']),
163 + s5_theme_files),
164 'scripts' : ['tools/rst2html.py',
165 'tools/rst2s5.py',
166 'tools/rst2latex.py',
167 'tools/rst2xetex.py',
168 'tools/rst2man.py',
169 'tools/rst2xml.py',
170 'tools/rst2pseudoxml.py',
171 'tools/rstpep2html.py',
172 'tools/rst2odt.py',
173 'tools/rst2odt_prepstyles.py',
175 """Distutils setup parameters."""
177 classifiers = [
178 'Development Status :: 4 - Beta',
179 'Environment :: Console',
180 'Intended Audience :: End Users/Desktop',
181 'Intended Audience :: Other Audience',
182 'Intended Audience :: Developers',
183 'Intended Audience :: System Administrators',
184 'License :: Public Domain',
185 'License :: OSI Approved :: Python Software Foundation License',
186 'License :: OSI Approved :: BSD License',
187 'License :: OSI Approved :: GNU General Public License (GPL)',
188 'Operating System :: OS Independent',
189 'Programming Language :: Python',
190 'Topic :: Documentation',
191 'Topic :: Software Development :: Documentation',
192 'Topic :: Text Processing',
193 'Natural Language :: English', # main/default language, keep first
194 'Natural Language :: Afrikaans',
195 'Natural Language :: Brazilian Portuguese',
196 'Natural Language :: Catalan',
197 'Natural Language :: Czech',
198 'Natural Language :: Dutch',
199 'Natural Language :: Esperanto',
200 'Natural Language :: Finnish',
201 'Natural Language :: French',
202 'Natural Language :: Galician',
203 'Natural Language :: German',
204 'Natural Language :: Italian',
205 'Natural Language :: Japanese',
206 'Natural Language :: Lithuanian',
207 'Natural Language :: Polish',
208 'Natural Language :: Russian',
209 'Natural Language :: Simplified Chinese ',
210 'Natural Language :: Slovak',
211 'Natural Language :: Spanish',
212 'Natural Language :: Swedish',
213 'Natural Language :: Traditional Chinese ',
215 """Trove classifiers for the Distutils "register" command;
216 Python 2.3 and up."""
218 if __name__ == '__main__' :
219 do_setup()