From 40c179bfbe7502b2e996e72d6e7a735eb4587e9b Mon Sep 17 00:00:00 2001 From: goodger Date: Sun, 22 Jun 2003 23:07:32 +0000 Subject: Thomas Heller showed us a better way git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@1496 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- setup.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'setup.py') diff --git a/setup.py b/setup.py index 93e869b1c..b45d649aa 100755 --- a/setup.py +++ b/setup.py @@ -3,15 +3,17 @@ # Copyright: This file has been placed in the public domain. import sys +import os from distutils.core import setup +from distutils.command.build_py import build_py + def do_setup(): + kwargs = package_data.copy() extras = get_extras() if extras: - setup(name = 'Extras--IGNORE', # name for tarball - py_modules = extras, - package_dir = {'': 'extras'}) - kwargs = package_data.copy() + kwargs['py_modules'] = extras + kwargs['cmdclass'] = {'build_py': dual_build_py} if sys.hexversion >= 0x02030000: # Python 2.3 kwargs['classifiers'] = classifiers dist = setup(**kwargs) @@ -31,6 +33,7 @@ what-you-see-is-what-you-get plaintext markup syntax.""", # wrap at col 60 'author_email': 'goodger@users.sourceforge.net', 'license': 'public domain, Python, BSD, GPL (see COPYING.txt)', 'platforms': 'OS-independent', + 'package_dir': {'docutils': 'docutils', '': 'extras'}, 'packages': ['docutils', 'docutils.languages', 'docutils.parsers', 'docutils.parsers.rst', 'docutils.parsers.rst.directives', @@ -89,5 +92,22 @@ def get_extras(): return extras +class dual_build_py(build_py): + + """ + This class allows the distribution of both packages *and* modules with one + call to `distutils.core.setup()`. Thanks to Thomas Heller. + """ + + def run(self): + if not self.py_modules and not self.packages: + return + if self.py_modules: + self.build_modules() + if self.packages: + self.build_packages() + self.byte_compile(self.get_outputs(include_bytecode=0)) + + if __name__ == '__main__' : do_setup() -- cgit v1.2.1