summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-09-16 15:23:28 +0000
committerGreg Ward <gward@python.net>2000-09-16 15:23:28 +0000
commitf449ea51aa9b72bf8d8ea7a19e87c5a169fc9605 (patch)
treeda17493236f3dc9bca64ccd1c6f9f27413cba204
parentb3e0ad9804cac46243fb49bb8894e00b6880295a (diff)
downloadcpython-git-f449ea51aa9b72bf8d8ea7a19e87c5a169fc9605.tar.gz
Generalized 'reinitialize_command()' so it can optionally reinitialize
the command's sub-commands as well (off by default). This is essential if we want to be be able to run (eg.) "install" twice in one run, as happens when generating multiple built distributions in one run.
-rw-r--r--Lib/distutils/dist.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index 1552dc0c41..b126a99757 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -733,7 +733,7 @@ class Distribution:
(source, command_name, option)
setattr(command_obj, option, value)
- def reinitialize_command (self, command):
+ def reinitialize_command (self, command, reinit_subcommands=0):
"""Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet
finalized. This provides the opportunity to sneak option
@@ -743,9 +743,18 @@ class Distribution:
'finalize_options()' or 'ensure_finalized()') before using it for
real.
- 'command' should be a command name (string) or command object.
+ 'command' should be a command name (string) or command object. If
+ 'reinit_subcommands' is true, also reinitializes the command's
+ sub-commands, as declared by the 'sub_commands' class attribute (if
+ it has one). See the "install" command for an example. Only
+ reinitializes the sub-commands that actually matter, ie. those
+ whose test predicates return true.
+
Returns the reinitialized command object.
"""
+ print "reinitialize_command: command=%s" % command
+ print " before: have_run =", self.have_run
+
from distutils.cmd import Command
if not isinstance(command, Command):
command_name = command
@@ -759,6 +768,15 @@ class Distribution:
command.finalized = 0
self.have_run[command_name] = 0
self._set_command_options(command)
+
+ print " after: have_run =", self.have_run
+
+ if reinit_subcommands:
+ print (" reinitializing sub-commands: %s" %
+ command.get_sub_commands())
+ for sub in command.get_sub_commands():
+ self.reinitialize_command(sub, reinit_subcommands)
+
return command