Commit 157e9188 authored by Greg Ward's avatar Greg Ward

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
parent 2ab90e20
...@@ -97,26 +97,34 @@ class build (Command): ...@@ -97,26 +97,34 @@ class build (Command):
def run (self): def run (self):
# For now, "build" means "build_py" then "build_ext". (Eventually # Run all relevant sub-commands. This will be some subset of:
# it should also build documentation.) # - build_py - pure Python modules
# - build_clib - standalone C libraries
# Invoke the 'build_py' command to "build" pure Python modules # - build_ext - Python extensions
# (ie. copy 'em into the build tree) # - build_scripts - (Python) scripts
if self.distribution.has_pure_modules(): for cmd_name in self.get_sub_commands():
self.run_command ('build_py') self.run_command(cmd_name)
# Build any standalone C libraries next -- they're most likely to
# be needed by extension modules, so obviously have to be done # -- Predicates for the sub-command list ---------------------------
# first!
if self.distribution.has_c_libraries(): def has_pure_modules (self):
self.run_command ('build_clib') return self.distribution.has_pure_modules()
# And now 'build_ext' -- compile extension modules and put them def has_c_libraries (self):
# into the build tree return self.distribution.has_c_libraries()
if self.distribution.has_ext_modules():
self.run_command ('build_ext') def has_ext_modules (self):
return self.distribution.has_ext_modules()
if self.distribution.has_scripts():
self.run_command ('build_scripts') 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 # class build
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment