class documentation

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 are "declared" in 'initialize_options()' and "defined" (given their final values, aka "finalized") in 'finalize_options()', both of which must be defined by every command class. The distinction between the two is necessary because option values might come from the outside world (command line, config file, ...), and any options dependent on other options must be computed *after* these outside influences have been processed -- hence 'finalize_options()'. The "body" of the subroutine, where it does all its work based on the values of its options, is the 'run()' method, which must also be implemented by every command class.

Method __getattr__ Undocumented
Method __init__ Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated.
Method announce Undocumented
Method copy_file Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)
Method copy_tree Copy an entire directory tree respecting verbose, dry-run, and force flags.
Method debug_print Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.
Method dump_options Undocumented
Method ensure_dirname Undocumented
Method ensure_filename Ensure that 'option' is the name of an existing file.
Method ensure_finalized Undocumented
Method ensure_string Ensure that 'option' is a string; if not defined, set it to 'default'.
Method ensure_string_list Ensure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"].
Method execute Undocumented
Method finalize_options Set final values for all the options that this command supports. This is always called as late as possible, ie. after any option assignments from the command-line or from other commands have been done...
Method get_command_name Undocumented
Method get_finalized_command Wrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object.
Method get_sub_commands Determine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution...
Method initialize_options Set default values for all the options that this command supports. Note that these defaults may be overridden by other commands, by the setup script, by config files, or by the command-line. Thus, this is not the place to code dependencies between options; generally, 'initialize_options()' implementations are just a bunch of "self...
Method make_archive Undocumented
Method make_file Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'...
Method mkpath Undocumented
Method move_file Move a file respecting dry-run flag.
Method reinitialize_command Undocumented
Method run A command's raison d'etre: carry out the action it exists to perform, controlled by the options initialized in 'initialize_options()', customized by other commands, the setup script, the command-line, and config files, and finalized in 'finalize_options()'...
Method run_command Run some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method.
Method set_undefined_options Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'...
Method spawn Spawn an external command respecting dry-run flag.
Method warn Undocumented
Class Variable sub_commands Undocumented
Instance Variable distribution Undocumented
Instance Variable finalized Undocumented
Instance Variable force Undocumented
Instance Variable help Undocumented
Instance Variable verbose Undocumented
Method _ensure_stringlike Undocumented
Method _ensure_tested_string Undocumented
Instance Variable _dry_run Undocumented
def __getattr__(self, attr): (source)

Undocumented

def __init__(self, dist): (source)

Create and initialize a new Command object. Most importantly, invokes the 'initialize_options()' method, which is the real initializer and depends on the actual command being instantiated.

def announce(self, msg, level=logging.DEBUG): (source)

Undocumented

def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1, link=None, level=1): (source)

Copy a file respecting verbose, dry-run and force flags. (The former two default to whatever is in the Distribution object, and the latter defaults to false for commands that don't define it.)

def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1, preserve_symlinks=0, level=1): (source)

Copy an entire directory tree respecting verbose, dry-run, and force flags.

def debug_print(self, msg): (source)

Print 'msg' to stdout if the global DEBUG (taken from the DISTUTILS_DEBUG environment variable) flag is true.

def dump_options(self, header=None, indent=''): (source)

Undocumented

def ensure_dirname(self, option): (source)

Undocumented

def ensure_filename(self, option): (source)

Ensure that 'option' is the name of an existing file.

def ensure_finalized(self): (source)

Undocumented

def ensure_string(self, option, default=None): (source)

Ensure that 'option' is a string; if not defined, set it to 'default'.

def ensure_string_list(self, option): (source)

Ensure that 'option' is a list of strings. If 'option' is currently a string, we split it either on /,\s*/ or /\s+/, so "foo bar baz", "foo,bar,baz", and "foo, bar baz" all become ["foo", "bar", "baz"].

def execute(self, func, args, msg=None, level=1): (source)

Undocumented

def get_command_name(self): (source)

Undocumented

def get_finalized_command(self, command, create=1): (source)

Wrapper around Distribution's 'get_command_obj()' method: find (create if necessary and 'create' is true) the command object for 'command', call its 'ensure_finalized()' method, and return the finalized command object.

def get_sub_commands(self): (source)

Determine the sub-commands that are relevant in the current distribution (ie., that need to be run). This is based on the 'sub_commands' class attribute: each tuple in that list may include a method that we call to determine if the subcommand needs to be run for the current distribution. Return a list of command names.

def make_archive(self, base_name, format, root_dir=None, base_dir=None, owner=None, group=None): (source)

Undocumented

def make_file(self, infiles, outfile, func, args, exec_msg=None, skip_msg=None, level=1): (source)

Special case of 'execute()' for operations that process one or more input files and generate one output file. Works just like 'execute()', except the operation is skipped and a different message printed if 'outfile' already exists and is newer than all files listed in 'infiles'. If the command defined 'self.force', and it is true, then the command is unconditionally run -- does no timestamp checks.

def mkpath(self, name, mode=511): (source)

Undocumented

def move_file(self, src, dst, level=1): (source)

Move a file respecting dry-run flag.

def reinitialize_command(self, command, reinit_subcommands=0): (source)

Undocumented

def run_command(self, command): (source)

Run some other command: uses the 'run_command()' method of Distribution, which creates and finalizes the command object if necessary and then invokes its 'run()' method.

def set_undefined_options(self, src_cmd, *option_pairs): (source)

Set the values of any "undefined" options from corresponding option values in some other command object. "Undefined" here means "is None", which is the convention used to indicate that an option has not been changed between 'initialize_options()' and 'finalize_options()'. Usually called from 'finalize_options()' for options that depend on some other command rather than another option of the same command. 'src_cmd' is the other command from which option values will be taken (a command object will be created for it if necessary); the remaining arguments are '(src_option,dst_option)' tuples which mean "take the value of 'src_option' in the 'src_cmd' command object, and copy it to 'dst_option' in the current command object".

def spawn(self, cmd, search_path=1, level=1): (source)

Spawn an external command respecting dry-run flag.

def warn(self, msg): (source)

Undocumented

distribution = (source)

Undocumented

finalized: int = (source)

Undocumented

Undocumented

Undocumented

def _ensure_stringlike(self, option, what, default=None): (source)

Undocumented

def _ensure_tested_string(self, option, tester, what, error_fmt, default=None): (source)

Undocumented

_dry_run = (source)

Undocumented