summaryrefslogtreecommitdiff
path: root/src/distutils2/command/cmd.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/distutils2/command/cmd.py')
-rw-r--r--src/distutils2/command/cmd.py43
1 files changed, 34 insertions, 9 deletions
diff --git a/src/distutils2/command/cmd.py b/src/distutils2/command/cmd.py
index ba88b89..fa6f281 100644
--- a/src/distutils2/command/cmd.py
+++ b/src/distutils2/command/cmd.py
@@ -6,7 +6,7 @@ in the distutils.command package.
__revision__ = "$Id: cmd.py 75192 2009-10-02 23:49:48Z tarek.ziade $"
-import sys, os, re
+import os, re
from distutils2.errors import DistutilsOptionError
from distutils2 import util
from distutils2 import log
@@ -19,7 +19,7 @@ try:
except ImportError:
from distutils2._backport.shutil import make_archive
-class Command:
+class Command(object):
"""Abstract base class for defining command classes, the "worker bees"
of the Distutils. A useful analogy for command classes is to think of
them as subroutines with local variables called "options". The options
@@ -188,6 +188,31 @@ class Command:
"""
log.log(level, msg)
+ # -- External interface --------------------------------------------
+ # (called by outsiders)
+
+ def get_source_files(self):
+ """Return the list of files that are used as inputs to this command,
+ i.e. the files used to generate the output files. The result is used
+ by the `sdist` command in determining the set of default files.
+
+ Command classes should implement this method if they operate on files
+ from the source tree.
+ """
+ return []
+
+ def get_outputs(self):
+ """Return the list of files that would be produced if this command
+ were actually run. Not affected by the "dry-run" flag or whether
+ any other commands have been run.
+
+ Command classes should implement this method if they produce any
+ output files that get consumed by another command. e.g., `build_ext`
+ returns the list of built extension modules, but not any temporary
+ files used in the compilation process.
+ """
+ return []
+
# -- Option validation methods -------------------------------------
# (these are very handy in writing the 'finalize_options()' method)
#
@@ -307,10 +332,8 @@ class Command:
cmd_obj.ensure_finalized()
return cmd_obj
- # XXX rename to 'get_reinitialized_command()'? (should do the
- # same in dist.py, if so)
- def reinitialize_command(self, command, reinit_subcommands=0):
- return self.distribution.reinitialize_command(
+ def get_reinitialized_command(self, command, reinit_subcommands=0):
+ return self.distribution.get_reinitialized_command(
command, reinit_subcommands)
def run_command(self, command):
@@ -350,8 +373,10 @@ class Command:
if os.path.isdir(name) or name == '':
return
if dry_run:
+ head = ''
for part in name.split(os.sep):
- self.log(part)
+ log.info("created directory %s%s", head, part)
+ head += part + os.sep
return
os.makedirs(name, mode)
@@ -386,7 +411,7 @@ class Command:
def spawn(self, cmd, search_path=1, level=1):
"""Spawn an external command respecting dry-run flag."""
- from distutils2.spawn import spawn
+ from distutils2.util import spawn
spawn(cmd, search_path, dry_run= self.dry_run)
def make_archive(self, base_name, format, root_dir=None, base_dir=None,
@@ -422,7 +447,7 @@ class Command:
# If 'outfile' must be regenerated (either because it doesn't
# exist, is out-of-date, or the 'force' flag is true) then
# perform the action that presumably regenerates it
- if self.force or dep_util.newer_group(infiles, outfile):
+ if self.force or util.newer_group(infiles, outfile):
self.execute(func, args, exec_msg, level)
# Otherwise, print the "skip" message