diff options
author | Greg Ward <gward@python.net> | 2000-09-30 17:08:12 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-09-30 17:08:12 (GMT) |
commit | 64d855adca8f78356e4699355e876810b8fd575f (patch) | |
tree | eeced0ac692fbadf77dd0d6d2904ff9e68eafbbf /Lib/distutils/command/build.py | |
parent | 70b1fd1a99d7f9f907d49bdcbed8dbbb648a3ede (diff) | |
download | cpython-64d855adca8f78356e4699355e876810b8fd575f.zip cpython-64d855adca8f78356e4699355e876810b8fd575f.tar.gz cpython-64d855adca8f78356e4699355e876810b8fd575f.tar.bz2 |
Changed to use the 'sub-commands' machinery:
- added 'sub_commands' class attr
- added 'has_*()' predicates referenced by the sub-command list
- rewrote 'run()' so it's a trivial loop over relevant sub-commands
Diffstat (limited to 'Lib/distutils/command/build.py')
-rw-r--r-- | Lib/distutils/command/build.py | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py index f30f4ee..1f78599 100644 --- a/Lib/distutils/command/build.py +++ b/Lib/distutils/command/build.py @@ -97,26 +97,34 @@ class build (Command): def run (self): - # For now, "build" means "build_py" then "build_ext". (Eventually - # it should also build documentation.) - - # Invoke the 'build_py' command to "build" pure Python modules - # (ie. copy 'em into the build tree) - if self.distribution.has_pure_modules(): - self.run_command ('build_py') - - # Build any standalone C libraries next -- they're most likely to - # be needed by extension modules, so obviously have to be done - # first! - if self.distribution.has_c_libraries(): - self.run_command ('build_clib') - - # And now 'build_ext' -- compile extension modules and put them - # into the build tree - if self.distribution.has_ext_modules(): - self.run_command ('build_ext') - - if self.distribution.has_scripts(): - self.run_command ('build_scripts') + # Run all relevant sub-commands. This will be some subset of: + # - build_py - pure Python modules + # - build_clib - standalone C libraries + # - build_ext - Python extensions + # - build_scripts - (Python) scripts + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) + + + # -- Predicates for the sub-command list --------------------------- + + def has_pure_modules (self): + return self.distribution.has_pure_modules() + + def has_c_libraries (self): + return self.distribution.has_c_libraries() + + def has_ext_modules (self): + return self.distribution.has_ext_modules() + + def has_scripts (self): + return self.distribution.has_scripts() + + + sub_commands = [('build_py', has_pure_modules), + ('build_clib', has_c_libraries), + ('build_ext', has_ext_modules), + ('build_scripts', has_scripts), + ] # class build |