diff -ur distutils-orig/distutils/command/install.py distutils/distutils/command/install.py --- distutils-orig/distutils/command/install.py Fri May 12 22:16:45 2000 +++ distutils/distutils/command/install.py Sun May 14 21:15:50 2000 @@ -12,7 +12,6 @@ from distutils import sysconfig from distutils.util import write_file, native_path, subst_vars, change_root from distutils.errors import DistutilsOptionError -from glob import glob INSTALL_SCHEMES = { 'unix_prefix': { @@ -423,13 +422,7 @@ def run (self): - - # Obviously have to build before we can install - if not self.skip_build: - self.run_peer ('build') - - # Run all sub-commands: currently this just means install all - # Python modules using 'install_lib'. + # Run all sub-commands. for (func, cmd_name) in self.sub_commands: if func is None or func(): self.run_peer (cmd_name) diff -ur distutils-orig/distutils/command/install_lib.py distutils/distutils/command/install_lib.py --- distutils-orig/distutils/command/install_lib.py Fri May 12 22:11:10 2000 +++ distutils/distutils/command/install_lib.py Sun May 14 21:23:58 2000 @@ -13,11 +13,17 @@ user_options = [ ('install-dir=', 'd', "directory to install to"), ('build-dir=','b', "build directory (where to install from)"), - ('compile', 'c', "compile .py to .pyc"), - ('optimize', 'o', "compile .py to .pyo (optimized)"), + ('compile', 'c', "compile .py to .pyc (default)"), + ('no-compile', None, "do not compile .py to .pyc"), + ('optimize', 'o', + "generate both optimized and non-optimized byte code (default)"), + ('no-optimize', None, + "do not generate both optimized and non-optimized byte code"), ('skip-build', None, "skip the build steps"), ] - + + negative_opt = {'no-compile': 'compile', + 'no-optimize': 'optimize'} def initialize_options (self): # let the 'install' command dictate our installation directory @@ -35,11 +41,13 @@ self.set_undefined_options ('install', ('build_lib', 'build_dir'), ('install_lib', 'install_dir'), - ('compile_py', 'compile'), - ('optimize_py', 'optimize'), ('skip_build', 'skip_build'), ) + # 'optimize implies 'compile' + if self.optimize: + self.compile = 1 + def run (self): @@ -47,6 +55,8 @@ if not self.skip_build: if self.distribution.has_pure_modules(): self.run_peer ('build_py') + if self.distribution.has_c_libraries(): + self.run_peer ('build_clib') if self.distribution.has_ext_modules(): self.run_peer ('build_ext') @@ -72,9 +82,42 @@ skip_msg = "byte-compilation of %s skipped" % f self.make_file (f, out_fn, compile, (f,), compile_msg, skip_msg) + + # run child script to generate optimized bytecode if requested + if self.optimize: + self._make_optimized() + # run () + def _make_optimized (self): + ''' Runs a child script with the opposite optimization of the current + script ''' + + # generate child command and arguments + child = ['python',] + + # if we are not optimized, run an optimizod version + if __debug__: + child.append('-O') + + # build has already been performed so we skip it, '-c' and'no-optimize' + # are passed in order to override any configuration options to the + # contrary. install-dir and build-dir are passed for essentially the + # same reason + child.extend(['setup.py', + 'install_lib', + '--no-optimize', + '-c', + '--skip-build', + '-d' + self.install_dir, + '-b' + self.build_dir]) + + self.spawn(child) + + # _make_optimized () + + def _mutate_outputs (self, has_any, build_cmd, cmd_option, output_dir): if not has_any: @@ -99,6 +142,9 @@ bytecode = py_file + (__debug__ and "c" or "o") bytecode_files.append(bytecode) + if self.optimize: # add optimize bytecode if applicable + bytecode = py_file + (__debug__ and "o" or "c") + bytecode_files.append(bytecode) return bytecode_files def get_outputs (self):