class documentation

class Distribution: (source)

View In Hierarchy

The core of the Distutils. Most of the work hiding behind 'setup' is really done within a Distribution instance, which farms the work out to the Distutils commands specified on the command line. Setup scripts will almost never instantiate Distribution directly, unless the 'setup()' function is totally inadequate to their needs. However, it is conceivable that a setup script might wish to subclass Distribution for some specialized purpose, and then pass the subclass to 'setup()' as the 'distclass' keyword argument. If so, it is necessary to respect the expectations that 'setup' has of Distribution. See the code for 'setup()', in core.py, for details.

Method __init__ Construct a new Distribution instance: initialize all the attributes of a Distribution, and then use 'attrs' (a dictionary mapping attribute names to values) to assign some of those attributes their "real" values...
Method announce Undocumented
Method dump_option_dicts Undocumented
Method finalize_options Set final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects.
Method find_config_files Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions).
Method get_command_class Return the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it...
Method get_command_list Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command)...
Method get_command_obj Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None.
Method get_command_packages Return a list of packages from which commands are loaded.
Method get_option_dict Get the option dictionary for a given command. If that command's option dictionary hasn't been created yet, then create it and return the new dictionary; otherwise, return the existing option dictionary.
Method handle_display_options If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false.
Method has_c_libraries Undocumented
Method has_data_files Undocumented
Method has_ext_modules Undocumented
Method has_headers Undocumented
Method has_modules Undocumented
Method has_pure_modules Undocumented
Method has_scripts Undocumented
Method is_pure Undocumented
Method parse_command_line Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance...
Method parse_config_files Undocumented
Method print_command_list Print a subset of the list of all commands -- used by 'print_commands()'.
Method print_commands Print out a help message listing all available commands with a description of each. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self...
Method reinitialize_command 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 values in programmatically, overriding or supplementing user-supplied values from the config files and command line...
Method run_command Do whatever it takes to run a command (including nothing at all, if the command has already been run). Specifically: if we have already created and run the command named by 'command', return silently without doing anything...
Method run_commands Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'.
Class Variable common_usage Undocumented
Class Variable display_option_names Undocumented
Class Variable display_options Undocumented
Class Variable global_options Undocumented
Class Variable negative_opt Undocumented
Instance Variable cmdclass Undocumented
Instance Variable command_obj Undocumented
Instance Variable command_options Undocumented
Instance Variable command_packages Undocumented
Instance Variable commands Undocumented
Instance Variable data_files Undocumented
Instance Variable dist_files Undocumented
Instance Variable dry_run Undocumented
Instance Variable ext_modules Undocumented
Instance Variable ext_package Undocumented
Instance Variable extra_path Undocumented
Instance Variable have_run Undocumented
Instance Variable headers Undocumented
Instance Variable help Undocumented
Instance Variable include_dirs Undocumented
Instance Variable libraries Undocumented
Instance Variable metadata Undocumented
Instance Variable package_data Undocumented
Instance Variable package_dir Undocumented
Instance Variable packages Undocumented
Instance Variable password Undocumented
Instance Variable py_modules Undocumented
Instance Variable script_args Undocumented
Instance Variable script_name Undocumented
Instance Variable scripts Undocumented
Instance Variable verbose Undocumented
Instance Variable want_user_cfg Undocumented
Method _gen_paths Undocumented
Method _get_toplevel_options Return the non-display options recognized at the top level.
Method _parse_command_opts Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse)...
Method _set_command_options Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command').
Method _show_help Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make it generate the correct help text.
def __init__(self, attrs=None): (source)

Construct a new Distribution instance: initialize all the attributes of a Distribution, and then use 'attrs' (a dictionary mapping attribute names to values) to assign some of those attributes their "real" values. (Any attributes not mentioned in 'attrs' will be assigned to some null value: 0, None, an empty list or dictionary, etc.) Most importantly, initialize the 'command_obj' attribute to the empty dictionary; this will be filled in with real command objects by 'parse_command_line()'.

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

Undocumented

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

Undocumented

def finalize_options(self): (source)

Set final values for all the options on the Distribution instance, analogous to the .finalize_options() method of Command objects.

def find_config_files(self): (source)

Find as many configuration files as should be processed for this platform, and return a list of filenames in the order in which they should be parsed. The filenames returned are guaranteed to exist (modulo nasty race conditions). There are multiple possible config files: - distutils.cfg in the Distutils installation directory (i.e. where the top-level Distutils __inst__.py file lives) - a file in the user's home directory named .pydistutils.cfg on Unix and pydistutils.cfg on Windows/Mac; may be disabled with the ``--no-user-cfg`` option - setup.cfg in the current directory - a file named by an environment variable

def get_command_class(self, command): (source)

Return the class that implements the Distutils command named by 'command'. First we check the 'cmdclass' dictionary; if the command is mentioned there, we fetch the class object from the dictionary and return it. Otherwise we load the command module ("distutils.command." + command) and fetch the command class from the module. The loaded class is also stored in 'cmdclass' to speed future calls to 'get_command_class()'. Raises DistutilsModuleError if the expected module could not be found, or if that module does not define the expected class.

def get_command_list(self): (source)

Get a list of (command, description) tuples. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command class attribute 'description'.

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

Return the command object for 'command'. Normally this object is cached on a previous call to 'get_command_obj()'; if no command object for 'command' is in the cache, then we either create and return it (if 'create' is true) or return None.

def get_command_packages(self): (source)

Return a list of packages from which commands are loaded.

def get_option_dict(self, command): (source)

Get the option dictionary for a given command. If that command's option dictionary hasn't been created yet, then create it and return the new dictionary; otherwise, return the existing option dictionary.

def handle_display_options(self, option_order): (source)

If there were any non-global "display-only" options (--help-commands or the metadata display options) on the command line, display the requested info and return true; else return false.

def has_c_libraries(self): (source)

Undocumented

def has_data_files(self): (source)

Undocumented

def has_ext_modules(self): (source)

Undocumented

def has_headers(self): (source)

Undocumented

def has_modules(self): (source)

Undocumented

def has_pure_modules(self): (source)

Undocumented

def has_scripts(self): (source)

Undocumented

def is_pure(self): (source)

Undocumented

def parse_command_line(self): (source)

Parse the setup script's command line, taken from the 'script_args' instance attribute (which defaults to 'sys.argv[1:]' -- see 'setup()' in core.py). This list is first processed for "global options" -- options that set attributes of the Distribution instance. Then, it is alternately scanned for Distutils commands and options for that command. Each new command terminates the options for the previous command. The allowed options for a command are determined by the 'user_options' attribute of the command class -- thus, we have to be able to load command classes in order to parse the command line. Any error in that 'options' attribute raises DistutilsGetoptError; any error on the command-line raises DistutilsArgError. If no Distutils commands were found on the command line, raises DistutilsArgError. Return true if command-line was successfully parsed and we should carry on with executing commands; false if no errors but we shouldn't execute commands (currently, this only happens if user asks for help).

def parse_config_files(self, filenames=None): (source)

Undocumented

def print_command_list(self, commands, header, max_length): (source)

Print a subset of the list of all commands -- used by 'print_commands()'.

def print_commands(self): (source)

Print out a help message listing all available commands with a description of each. The list is divided into "standard commands" (listed in distutils.command.__all__) and "extra commands" (mentioned in self.cmdclass, but not a standard command). The descriptions come from the command class attribute 'description'.

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

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 values in programmatically, overriding or supplementing user-supplied values from the config files and command line. You'll have to re-finalize the command object (by calling 'finalize_options()' or 'ensure_finalized()') before using it for real. '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.

def run_command(self, command): (source)

Do whatever it takes to run a command (including nothing at all, if the command has already been run). Specifically: if we have already created and run the command named by 'command', return silently without doing anything. If the command named by 'command' doesn't even have a command object yet, create one. Then invoke 'run()' on that command object (or an existing one).

def run_commands(self): (source)

Run each command that was seen on the setup script command line. Uses the list of commands found and cache of command objects created by 'get_command_obj()'.

common_usage: str = (source)

Undocumented

display_option_names = (source)

Undocumented

display_options: list = (source)

Undocumented

global_options: list = (source)

Undocumented

negative_opt: dict[str, str] = (source)

Undocumented

cmdclass: dict = (source)

Undocumented

command_obj: dict = (source)

Undocumented

command_options: dict = (source)

Undocumented

command_packages = (source)

Undocumented

commands: list = (source)

Undocumented

data_files = (source)

Undocumented

dist_files: list = (source)

Undocumented

Undocumented

ext_modules = (source)

Undocumented

ext_package = (source)

Undocumented

extra_path = (source)

Undocumented

have_run: dict = (source)

Undocumented

Undocumented

Undocumented

include_dirs = (source)

Undocumented

libraries = (source)

Undocumented

metadata = (source)

Undocumented

package_data: dict = (source)

Undocumented

package_dir = (source)

Undocumented

packages = (source)

Undocumented

password: str = (source)

Undocumented

py_modules = (source)

Undocumented

script_args = (source)

Undocumented

script_name = (source)

Undocumented

Undocumented

Undocumented

want_user_cfg: bool = (source)

Undocumented

def _gen_paths(self): (source)

Undocumented

def _get_toplevel_options(self): (source)

Return the non-display options recognized at the top level. This includes options that are recognized *only* at the top level as well as options recognized for commands.

def _parse_command_opts(self, parser, args): (source)

Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' with the next command at the front of the list; will be the empty list if there are no more commands on the command line. Returns None if the user asked for help on this command.

def _set_command_options(self, command_obj, option_dict=None): (source)

Set the options for 'command_obj' from 'option_dict'. Basically this means copying elements of a dictionary ('option_dict') to attributes of an instance ('command'). 'command_obj' must be a Command instance. If 'option_dict' is not supplied, uses the standard option dictionary for this command (from 'self.command_options').

def _show_help(self, parser, global_options=1, display_options=1, commands=[]): (source)

Show help for the setup script command-line in the form of several lists of command-line options. 'parser' should be a FancyGetopt instance; do not expect it to be returned in the same state, as its option table will be reset to make it generate the correct help text. If 'global_options' is true, lists the global options: --verbose, --dry-run, etc. If 'display_options' is true, lists the "display-only" options: --name, --version, etc. Finally, lists per-command help for every command name or command class in 'commands'.