Kaydet (Commit) a963e0d9 authored tarafından Éric Araujo's avatar Éric Araujo

Undo potentially confusing name change in packaging.

This method was named reinitialize_command in distutils and accompanied
by a comment suggesting to change it to get_reinitialized_command.
Following that, I did the change for distutils2, but it proved
confusing: The Distribution object has an internal cache of command
objects, to make sure only one instance is ever used, and the name
get_reinitialized_command could suggest that the object returned was
independent of that cache, which it was not.  I’m reverting the name
change to make code clearer.
üst 4e377f21
...@@ -126,7 +126,7 @@ class bdist(Command): ...@@ -126,7 +126,7 @@ class bdist(Command):
# Reinitialize and run each command. # Reinitialize and run each command.
for i in range(len(self.formats)): for i in range(len(self.formats)):
cmd_name = commands[i] cmd_name = commands[i]
sub_cmd = self.get_reinitialized_command(cmd_name) sub_cmd = self.reinitialize_command(cmd_name)
sub_cmd.format = self.formats[i] sub_cmd.format = self.formats[i]
# passing the owner and group names for tar archiving # passing the owner and group names for tar archiving
......
...@@ -80,8 +80,8 @@ class bdist_dumb(Command): ...@@ -80,8 +80,8 @@ class bdist_dumb(Command):
if not self.skip_build: if not self.skip_build:
self.run_command('build') self.run_command('build')
install = self.get_reinitialized_command('install_dist', install = self.reinitialize_command('install_dist',
reinit_subcommands=True) reinit_subcommands=True)
install.root = self.bdist_dir install.root = self.bdist_dir
install.skip_build = self.skip_build install.skip_build = self.skip_build
install.warn_dir = False install.warn_dir = False
......
...@@ -183,13 +183,13 @@ class bdist_msi(Command): ...@@ -183,13 +183,13 @@ class bdist_msi(Command):
if not self.skip_build: if not self.skip_build:
self.run_command('build') self.run_command('build')
install = self.get_reinitialized_command('install_dist', install = self.reinitialize_command('install_dist',
reinit_subcommands=True) reinit_subcommands=True)
install.prefix = self.bdist_dir install.prefix = self.bdist_dir
install.skip_build = self.skip_build install.skip_build = self.skip_build
install.warn_dir = False install.warn_dir = False
install_lib = self.get_reinitialized_command('install_lib') install_lib = self.reinitialize_command('install_lib')
# we do not want to include pyc or pyo files # we do not want to include pyc or pyo files
install_lib.compile = False install_lib.compile = False
install_lib.optimize = 0 install_lib.optimize = 0
......
...@@ -115,14 +115,13 @@ class bdist_wininst(Command): ...@@ -115,14 +115,13 @@ class bdist_wininst(Command):
if not self.skip_build: if not self.skip_build:
self.run_command('build') self.run_command('build')
install = self.get_reinitialized_command('install', install = self.reinitialize_command('install', reinit_subcommands=True)
reinit_subcommands=True)
install.root = self.bdist_dir install.root = self.bdist_dir
install.skip_build = self.skip_build install.skip_build = self.skip_build
install.warn_dir = False install.warn_dir = False
install.plat_name = self.plat_name install.plat_name = self.plat_name
install_lib = self.get_reinitialized_command('install_lib') install_lib = self.reinitialize_command('install_lib')
# we do not want to include pyc or pyo files # we do not want to include pyc or pyo files
install_lib.compile = False install_lib.compile = False
install_lib.optimize = 0 install_lib.optimize = 0
......
...@@ -318,8 +318,8 @@ class Command: ...@@ -318,8 +318,8 @@ class Command:
cmd_obj.ensure_finalized() cmd_obj.ensure_finalized()
return cmd_obj return cmd_obj
def get_reinitialized_command(self, command, reinit_subcommands=False): def reinitialize_command(self, command, reinit_subcommands=False):
return self.distribution.get_reinitialized_command( return self.distribution.reinitialize_command(
command, reinit_subcommands) command, reinit_subcommands)
def run_command(self, command): def run_command(self, command):
......
...@@ -56,7 +56,7 @@ class test(Command): ...@@ -56,7 +56,7 @@ class test(Command):
prev_syspath = sys.path[:] prev_syspath = sys.path[:]
try: try:
# build release # build release
build = self.get_reinitialized_command('build') build = self.reinitialize_command('build')
self.run_command('build') self.run_command('build')
sys.path.insert(0, build.build_lib) sys.path.insert(0, build.build_lib)
......
...@@ -636,9 +636,9 @@ Common commands: (see '--help-commands' for more) ...@@ -636,9 +636,9 @@ Common commands: (see '--help-commands' for more)
except ValueError as msg: except ValueError as msg:
raise PackagingOptionError(msg) raise PackagingOptionError(msg)
def get_reinitialized_command(self, command, reinit_subcommands=False): def reinitialize_command(self, command, reinit_subcommands=False):
"""Reinitializes a command to the state it was in when first """Reinitializes a command to the state it was in when first
returned by 'get_command_obj()': ie., initialized but not yet returned by 'get_command_obj()': i.e., initialized but not yet
finalized. This provides the opportunity to sneak option finalized. This provides the opportunity to sneak option
values in programmatically, overriding or supplementing values in programmatically, overriding or supplementing
user-supplied values from the config files and command line. user-supplied values from the config files and command line.
...@@ -650,10 +650,11 @@ Common commands: (see '--help-commands' for more) ...@@ -650,10 +650,11 @@ Common commands: (see '--help-commands' for more)
'reinit_subcommands' is true, also reinitializes the command's 'reinit_subcommands' is true, also reinitializes the command's
sub-commands, as declared by the 'sub_commands' class attribute (if sub-commands, as declared by the 'sub_commands' class attribute (if
it has one). See the "install_dist" command for an example. Only it has one). See the "install_dist" command for an example. Only
reinitializes the sub-commands that actually matter, ie. those reinitializes the sub-commands that actually matter, i.e. those
whose test predicates return true. whose test predicate return true.
Returns the reinitialized command object. Returns the reinitialized command object. It will be the same
object as the one stored in the self.command_obj attribute.
""" """
if not isinstance(command, Command): if not isinstance(command, Command):
command_name = command command_name = command
...@@ -671,7 +672,7 @@ Common commands: (see '--help-commands' for more) ...@@ -671,7 +672,7 @@ Common commands: (see '--help-commands' for more)
if reinit_subcommands: if reinit_subcommands:
for sub in command.get_sub_commands(): for sub in command.get_sub_commands():
self.get_reinitialized_command(sub, reinit_subcommands) self.reinitialize_command(sub, reinit_subcommands)
return command return command
......
...@@ -251,7 +251,7 @@ class DummyCommand: ...@@ -251,7 +251,7 @@ class DummyCommand:
Useful for mocking one dependency command in the tests for another Useful for mocking one dependency command in the tests for another
command, see e.g. the dummy build command in test_build_scripts. command, see e.g. the dummy build command in test_build_scripts.
""" """
# XXX does not work with dist.get_reinitialized_command, which typechecks # XXX does not work with dist.reinitialize_command, which typechecks
# and wants a finalized attribute # and wants a finalized attribute
def __init__(self, **kwargs): def __init__(self, **kwargs):
......
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