3 # Copyright: This file has been placed in the public domain.
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
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.')
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.
35 exclude *.pyc *~ .DS_Store
36 recursive-exclude * *.pyc *~ .DS_Store
37 recursive-exclude functional/output *
38 include functional/output/README.txt
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>,
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
):
71 def finalize_options(self
):
75 build_py
= self
.get_finalized_command('build_py')
76 data_files
= self
.distribution
.data_files
78 dir = convert_path(f
[0])
79 dir = os
.path
.join(build_py
.build_lib
, dir)
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))
90 kwargs
= package_data
.copy()
93 kwargs
['py_modules'] = extras
94 kwargs
['classifiers'] = classifiers
95 # Install data files properly.
96 kwargs
['cmdclass'] = {'build_data': build_data
,
97 'install_data': smart_install_data
}
98 # Auto-convert source code for Python 3
99 if sys
.version_info
>= (3,):
100 kwargs
['cmdclass']['build_py'] = copy_build_py_2to3
102 kwargs
['cmdclass']['build_py'] = build_py
103 dist
= setup(**kwargs
)
107 for dir in glob
.glob('docutils/writers/s5_html/themes/*'):
108 if os
.path
.isdir(dir):
109 theme_files
= glob
.glob('%s/*' % dir)
110 s5_theme_files
.append((dir, theme_files
))
114 'description': 'Docutils -- Python Documentation Utilities',
115 'long_description': """\
116 Docutils is a modular system for processing documentation
117 into useful formats, such as HTML, XML, and LaTeX. For
118 input Docutils supports reStructuredText, an easy-to-read,
119 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
120 'url': 'http://docutils.sourceforge.net/',
122 'author': 'David Goodger',
123 'author_email': 'goodger@python.org',
124 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
125 'platforms': 'OS-independent',
126 'package_dir': {'docutils': 'docutils',
128 'docutils.tools': 'tools'},
129 'packages': ['docutils',
130 'docutils.languages',
132 'docutils.parsers.rst',
133 'docutils.parsers.rst.directives',
134 'docutils.parsers.rst.languages',
136 # 'docutils.readers.python', # in the sandbox since 0.8
137 'docutils.transforms',
140 'docutils.writers.html4css1',
141 # 'docutils.writers.html4strict', # in the sandbox!
142 'docutils.writers.pep_html',
143 'docutils.writers.s5_html',
144 'docutils.writers.latex2e',
145 # 'docutils.writers.newlatex2e', # in the sandbox since 0.8
146 'docutils.writers.xetex',
147 'docutils.writers.odf_odt',
149 'data_files': ([('docutils/parsers/rst/include',
150 glob
.glob('docutils/parsers/rst/include/*.txt')),
151 ('docutils/writers/html4css1',
152 ['docutils/writers/html4css1/html4css1.css',
153 'docutils/writers/html4css1/template.txt']),
154 ('docutils/writers/latex2e',
155 ['docutils/writers/latex2e/default.tex',
156 'docutils/writers/latex2e/titlepage.tex',
157 'docutils/writers/latex2e/xelatex.tex',]),
158 # ('docutils/writers/newlatex2e',
159 # ['docutils/writers/newlatex2e/base.tex']),
160 ('docutils/writers/pep_html',
161 ['docutils/writers/pep_html/pep.css',
162 'docutils/writers/pep_html/template.txt']),
163 ('docutils/writers/s5_html/themes',
164 ['docutils/writers/s5_html/themes/README.txt']),
165 ('docutils/writers/odf_odt',
166 ['docutils/writers/odf_odt/styles.odt']),
169 'scripts' : ['tools/rst2html.py',
171 'tools/rst2latex.py',
172 # 'tools/rst2newlatex.py',
173 'tools/rst2xetex.py',
176 'tools/rst2pseudoxml.py',
177 'tools/rstpep2html.py',
179 'tools/rst2odt_prepstyles.py',
181 """Distutils setup parameters."""
184 'Development Status :: 4 - Beta',
185 'Environment :: Console',
186 'Intended Audience :: End Users/Desktop',
187 'Intended Audience :: Other Audience',
188 'Intended Audience :: Developers',
189 'Intended Audience :: System Administrators',
190 'License :: Public Domain',
191 'License :: OSI Approved :: Python Software Foundation License',
192 'License :: OSI Approved :: BSD License',
193 'License :: OSI Approved :: GNU General Public License (GPL)',
194 'Operating System :: OS Independent',
195 'Programming Language :: Python',
196 'Topic :: Documentation',
197 'Topic :: Software Development :: Documentation',
198 'Topic :: Text Processing',
199 'Natural Language :: English', # main/default language, keep first
200 'Natural Language :: Afrikaans',
201 'Natural Language :: Esperanto',
202 'Natural Language :: French',
203 'Natural Language :: German',
204 'Natural Language :: Italian',
205 'Natural Language :: Russian',
206 'Natural Language :: Slovak',
207 'Natural Language :: Spanish',
208 'Natural Language :: Swedish',]
209 """Trove classifiers for the Distutils "register" command;
210 Python 2.3 and up."""
212 extra_modules
= [('roman', '1.4', ['toRoman', 'fromRoman',
213 'InvalidRomanNumeralError'])]
214 """Third-party modules to install if they're not already present.
215 List of (module name, minimum __version__ string, [attribute names])."""
219 for module_name
, version
, attributes
in extra_modules
:
221 module
= __import__(module_name
)
222 if version
and module
.__version
__ < version
:
224 for attribute
in attributes
or []:
225 getattr(module
, attribute
)
226 print ('"%s" module already present; ignoring extras/%s.py.'
227 % (module_name
, module_name
))
228 except (ImportError, AttributeError, ValueError):
229 extras
.append(module_name
)
233 if __name__
== '__main__' :