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 from distutils
.command
.install_data
import install_data
13 from distutils
.util
import convert_path
15 print ('Error: The "distutils" standard module, which is required for the ')
16 print ('installation of Docutils, could not be found. You may need to ')
17 print ('install a package called "python-devel" (or similar) on your ')
18 print ('system using your package manager.')
22 from distutils
.command
.build_py
import build_py_2to3
as build_py
24 from distutils
.command
.build_py
import build_py
27 class smart_install_data(install_data
):
28 # Hack for Python > 2.3.
29 # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
33 #need to change self.install_dir to the library dir
34 install_cmd
= self
.get_finalized_command('install')
35 self
.install_dir
= getattr(install_cmd
, 'install_lib')
36 return install_data
.run(self
)
38 class build_data(Command
):
40 def initialize_options(self
):
43 def finalize_options(self
):
47 build_py
= self
.get_finalized_command('build_py')
48 data_files
= self
.distribution
.data_files
50 dir = convert_path(f
[0])
51 dir = os
.path
.join(build_py
.build_lib
, dir)
54 data
= convert_path(data
)
55 self
.copy_file(data
, dir)
57 # let our build_data run
58 build
.sub_commands
.append(('build_data', lambda *a
: True))
62 kwargs
= package_data
.copy()
65 kwargs
['py_modules'] = extras
66 kwargs
['classifiers'] = classifiers
67 # Install data files properly. Note that we use a different
68 # hack for Python 2.2, which does not *always* work, though;
70 # <http://article.gmane.org/gmane.text.docutils.user/2867>.
71 # So for Python 2.3+, we prefer this hack.
72 kwargs
['cmdclass'] = {'install_data': smart_install_data
,
74 'build_data': build_data
}
75 dist
= setup(**kwargs
)
79 for dir in glob
.glob('docutils/writers/s5_html/themes/*'):
80 if os
.path
.isdir(dir):
81 theme_files
= glob
.glob('%s/*' % dir)
82 s5_theme_files
.append((dir, theme_files
))
86 'description': 'Docutils -- Python Documentation Utilities',
87 'long_description': """\
88 Docutils is a modular system for processing documentation
89 into useful formats, such as HTML, XML, and LaTeX. For
90 input Docutils supports reStructuredText, an easy-to-read,
91 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
92 'url': 'http://docutils.sourceforge.net/',
94 'author': 'David Goodger',
95 'author_email': 'goodger@python.org',
96 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
97 'platforms': 'OS-independent',
98 'package_dir': {'docutils': 'docutils', '': 'extras'},
99 'packages': ['docutils',
100 'docutils.languages',
102 'docutils.parsers.rst',
103 'docutils.parsers.rst.directives',
104 'docutils.parsers.rst.languages',
106 'docutils.readers.python',
107 'docutils.transforms',
109 'docutils.writers.html4css1',
110 'docutils.writers.pep_html',
111 'docutils.writers.s5_html',
112 'docutils.writers.latex2e',
113 'docutils.writers.newlatex2e',
114 'docutils.writers.odf_odt',
116 'data_files': ([('docutils/parsers/rst/include',
117 glob
.glob('docutils/parsers/rst/include/*.txt')),
118 ('docutils/writers/html4css1',
119 ['docutils/writers/html4css1/html4css1.css',
120 'docutils/writers/html4css1/template.txt']),
121 ('docutils/writers/latex2e',
122 ['docutils/writers/latex2e/latex2e.tex']),
123 ('docutils/writers/newlatex2e',
124 ['docutils/writers/newlatex2e/base.tex']),
125 ('docutils/writers/pep_html',
126 ['docutils/writers/pep_html/pep.css',
127 'docutils/writers/pep_html/template.txt']),
128 ('docutils/writers/s5_html/themes',
129 ['docutils/writers/s5_html/themes/README.txt']),
130 ('docutils/writers/odf_odt',
131 ['docutils/writers/odf_odt/styles.odt']),
134 'scripts' : ['tools/rst2html.py',
136 'tools/rst2latex.py',
137 'tools/rst2newlatex.py',
139 'tools/rst2pseudoxml.py',
140 'tools/rstpep2html.py',
142 'tools/rst2odt_prepstyles.py',
144 """Distutils setup parameters."""
147 'Development Status :: 3 - Alpha',
148 'Environment :: Console',
149 'Intended Audience :: End Users/Desktop',
150 'Intended Audience :: Other Audience',
151 'Intended Audience :: Developers',
152 'Intended Audience :: System Administrators',
153 'License :: Public Domain',
154 'License :: OSI Approved :: Python Software Foundation License',
155 'License :: OSI Approved :: BSD License',
156 'License :: OSI Approved :: GNU General Public License (GPL)',
157 'Operating System :: OS Independent',
158 'Programming Language :: Python',
159 'Topic :: Documentation',
160 'Topic :: Software Development :: Documentation',
161 'Topic :: Text Processing',
162 'Natural Language :: English', # main/default language, keep first
163 'Natural Language :: Afrikaans',
164 'Natural Language :: Esperanto',
165 'Natural Language :: French',
166 'Natural Language :: German',
167 'Natural Language :: Italian',
168 'Natural Language :: Russian',
169 'Natural Language :: Slovak',
170 'Natural Language :: Spanish',
171 'Natural Language :: Swedish',]
172 """Trove classifiers for the Distutils "register" command;
173 Python 2.3 and up."""
175 extra_modules
= [('optparse', '1.4.1', None),
176 ('textwrap', None, None),
177 ('roman', '1.4', ['toRoman', 'fromRoman',
178 'InvalidRomanNumeralError'])]
179 """Third-party modules to install if they're not already present.
180 List of (module name, minimum __version__ string, [attribute names])."""
184 for module_name
, version
, attributes
in extra_modules
:
186 module
= __import__(module_name
)
187 if version
and module
.__version
__ < version
:
189 for attribute
in attributes
or []:
190 getattr(module
, attribute
)
191 print ('"%s" module already present; ignoring extras/%s.py.'
192 % (module_name
, module_name
))
193 except (ImportError, AttributeError, ValueError):
194 extras
.append(module_name
)
198 if __name__
== '__main__' :