Minor fixes to emacs hook and documentation additions.
[docutils.git] / setup.py
blob49b399f9e678787fc921b8e4679103cf85cf5612
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 from distutils.core import setup
9 from distutils.command.build_py import build_py
10 from distutils.command.install_data import install_data
13 class smart_install_data(install_data):
15 # From <http://wiki.python.org/moin/DistutilsInstallDataScattered>,
16 # by Pete Shinners.
18 def run(self):
19 #need to change self.install_dir to the library dir
20 install_cmd = self.get_finalized_command('install')
21 self.install_dir = getattr(install_cmd, 'install_lib')
22 return install_data.run(self)
25 def do_setup():
26 kwargs = package_data.copy()
27 extras = get_extras()
28 if extras:
29 kwargs['py_modules'] = extras
30 if sys.hexversion >= 0x02030000: # Python 2.3
31 kwargs['classifiers'] = classifiers
32 else:
33 kwargs['cmdclass'] = {'build_py': dual_build_py}
34 dist = setup(**kwargs)
35 return dist
37 package_data = {
38 'name': 'docutils',
39 'description': 'Docutils -- Python Documentation Utilities',
40 'long_description': """\
41 Docutils is a modular system for processing documentation
42 into useful formats, such as HTML, XML, and LaTeX. For
43 input Docutils supports reStructuredText, an easy-to-read,
44 what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60
45 'url': 'http://docutils.sourceforge.net/',
46 'version': '0.3.10',
47 'author': 'David Goodger',
48 'author_email': 'goodger@users.sourceforge.net',
49 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)',
50 'platforms': 'OS-independent',
51 'cmdclass': {'install_data': smart_install_data},
52 'package_dir': {'docutils': 'docutils', '': 'extras'},
53 'packages': ['docutils', 'docutils.languages',
54 'docutils.parsers', 'docutils.parsers.rst',
55 'docutils.parsers.rst.directives',
56 'docutils.parsers.rst.languages',
57 'docutils.readers', 'docutils.readers.python',
58 'docutils.transforms',
59 'docutils.writers',],
60 'data_files': [('docutils/parsers/rst/include',
61 glob.glob('docutils/parsers/rst/include/*.txt'))],
62 'scripts' : ['tools/rst2html.py','tools/rst2latex.py'],}
63 """Distutils setup parameters."""
65 classifiers = [
66 'Development Status :: 3 - Alpha',
67 'Environment :: Console',
68 'Intended Audience :: End Users/Desktop',
69 'Intended Audience :: Other Audience',
70 'Intended Audience :: Developers',
71 'Intended Audience :: System Administrators',
72 'License :: Public Domain',
73 'License :: OSI Approved :: Python Software Foundation License',
74 'License :: OSI Approved :: BSD License',
75 'License :: OSI Approved :: GNU General Public License (GPL)',
76 'Operating System :: OS Independent',
77 'Programming Language :: Python',
78 'Topic :: Documentation',
79 'Topic :: Software Development :: Documentation',
80 'Topic :: Text Processing',
81 'Natural Language :: English', # main/default language, keep first
82 'Natural Language :: Afrikaans',
83 'Natural Language :: Esperanto',
84 'Natural Language :: French',
85 'Natural Language :: German',
86 'Natural Language :: Italian',
87 'Natural Language :: Russian',
88 'Natural Language :: Slovak',
89 'Natural Language :: Spanish',
90 'Natural Language :: Swedish',]
91 """Trove classifiers for the Distutils "register" command;
92 Python 2.3 and up."""
94 extra_modules = [('optparse', '1.4.1', None),
95 ('textwrap', None, None),
96 ('roman', '1.4', ['toRoman', 'fromRoman',
97 'InvalidRomanNumeralError'])]
98 """Third-party modules to install if they're not already present.
99 List of (module name, minimum __version__ string, [attribute names])."""
101 def get_extras():
102 extras = []
103 for module_name, version, attributes in extra_modules:
104 try:
105 module = __import__(module_name)
106 if version and module.__version__ < version:
107 raise ValueError
108 for attribute in attributes or []:
109 getattr(module, attribute)
110 print ('"%s" module already present; ignoring extras/%s.py.'
111 % (module_name, module_name))
112 except (ImportError, AttributeError, ValueError):
113 extras.append(module_name)
114 return extras
117 class dual_build_py(build_py):
120 This class allows the distribution of both packages *and* modules with one
121 call to `distutils.core.setup()` (necessary for pre-2.3 Python). Thanks
122 to Thomas Heller.
125 def run(self):
126 if not self.py_modules and not self.packages:
127 return
128 if self.py_modules:
129 self.build_modules()
130 if self.packages:
131 self.build_packages()
132 self.byte_compile(self.get_outputs(include_bytecode=0))
135 if __name__ == '__main__' :
136 do_setup()