3 # Copyright: This file has been placed in the public domain.
9 from distutils
.core
import setup
10 from distutils
.command
.build_py
import build_py
12 print 'Error: The "distutils" standard module, which is required for the '
13 print 'installation of Docutils, could not be found. You may need to '
14 print 'install a package called "python-devel" (or similar) on your '
15 print 'system using your package manager.'
18 # From <http://groups.google.de/groups?as_umsgid=f70e3538.0404141327.6cea58ca@posting.google.com>.
19 from distutils
.command
.install
import INSTALL_SCHEMES
20 for scheme
in INSTALL_SCHEMES
.values():
21 scheme
['data'] = scheme
['purelib']
25 kwargs
= package_data
.copy()
28 kwargs
['py_modules'] = extras
29 if sys
.hexversion
>= 0x02030000: # Python 2.3
30 kwargs
['classifiers'] = classifiers
32 kwargs
['cmdclass'] = {'build_py': dual_build_py
}
33 dist
= setup(**kwargs
)
37 for dir in glob
.glob('docutils/writers/s5_html/themes/*'):
38 if os
.path
.isdir(dir):
39 theme_files
= glob
.glob('%s/*' % dir)
40 s5_theme_files
.append((dir, theme_files
))
44 'description': 'Docutils -- Python Documentation Utilities',
45 'long_description': """\
46 Docutils is a modular system for processing documentation
47 into useful formats, such as HTML, XML, and LaTeX. For
48 input Docutils supports reStructuredText, an easy-to-read,
49 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
50 'url': 'http://docutils.sourceforge.net/',
52 'author': 'David Goodger',
53 'author_email': 'goodger@python.org',
54 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
55 'platforms': 'OS-independent',
56 'package_dir': {'docutils': 'docutils', '': 'extras'},
57 'packages': ['docutils',
60 'docutils.parsers.rst',
61 'docutils.parsers.rst.directives',
62 'docutils.parsers.rst.languages',
64 'docutils.readers.python',
65 'docutils.transforms',
67 'docutils.writers.html4css1',
68 'docutils.writers.pep_html',
69 'docutils.writers.s5_html',
70 'docutils.writers.latex2e',
71 'docutils.writers.newlatex2e'],
72 'data_files': ([('docutils/parsers/rst/include',
73 glob
.glob('docutils/parsers/rst/include/*.txt')),
74 ('docutils/writers/html4css1',
75 ['docutils/writers/html4css1/html4css1.css',
76 'docutils/writers/html4css1/template.txt']),
77 ('docutils/writers/latex2e',
78 ['docutils/writers/latex2e/latex2e.tex']),
79 ('docutils/writers/newlatex2e',
80 ['docutils/writers/newlatex2e/base.tex']),
81 ('docutils/writers/pep_html',
82 ['docutils/writers/pep_html/pep.css',
83 'docutils/writers/pep_html/template.txt']),
84 ('docutils/writers/s5_html/themes',
85 ['docutils/writers/s5_html/themes/README.txt']),]
87 'scripts' : ['tools/rst2html.py',
90 'tools/rst2newlatex.py',
92 'tools/rst2pseudoxml.py'],}
93 """Distutils setup parameters."""
96 'Development Status :: 3 - Alpha',
97 'Environment :: Console',
98 'Intended Audience :: End Users/Desktop',
99 'Intended Audience :: Other Audience',
100 'Intended Audience :: Developers',
101 'Intended Audience :: System Administrators',
102 'License :: Public Domain',
103 'License :: OSI Approved :: Python Software Foundation License',
104 'License :: OSI Approved :: BSD License',
105 'License :: OSI Approved :: GNU General Public License (GPL)',
106 'Operating System :: OS Independent',
107 'Programming Language :: Python',
108 'Topic :: Documentation',
109 'Topic :: Software Development :: Documentation',
110 'Topic :: Text Processing',
111 'Natural Language :: English', # main/default language, keep first
112 'Natural Language :: Afrikaans',
113 'Natural Language :: Esperanto',
114 'Natural Language :: French',
115 'Natural Language :: German',
116 'Natural Language :: Italian',
117 'Natural Language :: Russian',
118 'Natural Language :: Slovak',
119 'Natural Language :: Spanish',
120 'Natural Language :: Swedish',]
121 """Trove classifiers for the Distutils "register" command;
122 Python 2.3 and up."""
124 extra_modules
= [('optparse', '1.4.1', None),
125 ('textwrap', None, None),
126 ('roman', '1.4', ['toRoman', 'fromRoman',
127 'InvalidRomanNumeralError'])]
128 """Third-party modules to install if they're not already present.
129 List of (module name, minimum __version__ string, [attribute names])."""
133 for module_name
, version
, attributes
in extra_modules
:
135 module
= __import__(module_name
)
136 if version
and module
.__version
__ < version
:
138 for attribute
in attributes
or []:
139 getattr(module
, attribute
)
140 print ('"%s" module already present; ignoring extras/%s.py.'
141 % (module_name
, module_name
))
142 except (ImportError, AttributeError, ValueError):
143 extras
.append(module_name
)
147 class dual_build_py(build_py
):
150 This class allows the distribution of both packages *and* modules with one
151 call to `distutils.core.setup()` (necessary for pre-2.3 Python). Thanks
156 if not self
.py_modules
and not self
.packages
:
161 self
.build_packages()
162 self
.byte_compile(self
.get_outputs(include_bytecode
=0))
165 if __name__
== '__main__' :