3 # Copyright: This file has been placed in the public domain.
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>,
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
)
26 kwargs
= package_data
.copy()
29 kwargs
['py_modules'] = extras
30 if sys
.hexversion
>= 0x02030000: # Python 2.3
31 kwargs
['classifiers'] = classifiers
33 kwargs
['cmdclass'] = {'build_py': dual_build_py
}
34 dist
= setup(**kwargs
)
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/',
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',
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."""
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;
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])."""
103 for module_name
, version
, attributes
in extra_modules
:
105 module
= __import__(module_name
)
106 if version
and module
.__version
__ < version
:
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
)
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
126 if not self
.py_modules
and not self
.packages
:
131 self
.build_packages()
132 self
.byte_compile(self
.get_outputs(include_bytecode
=0))
135 if __name__
== '__main__' :