OpenQuizz
Une application de gestion des contenus pédagogiques
Distribution Class Reference

Public Member Functions

def __init__ (self, attrs=None)
 
def get_option_dict (self, command)
 
def dump_option_dicts (self, header=None, commands=None, indent="")
 
def find_config_files (self)
 
def parse_config_files (self, filenames=None)
 
def parse_command_line (self)
 
def finalize_options (self)
 
def handle_display_options (self, option_order)
 
def print_command_list (self, commands, header, max_length)
 
def print_commands (self)
 
def get_command_list (self)
 
def get_command_packages (self)
 
def get_command_class (self, command)
 
def get_command_obj (self, command, create=1)
 
def reinitialize_command (self, command, reinit_subcommands=0)
 
def announce (self, msg, level=log.INFO)
 
def run_commands (self)
 
def run_command (self, command)
 
def has_pure_modules (self)
 
def has_ext_modules (self)
 
def has_c_libraries (self)
 
def has_modules (self)
 
def has_headers (self)
 
def has_scripts (self)
 
def has_data_files (self)
 
def is_pure (self)
 

Data Fields

 verbose
 
 dry_run
 
 help
 
 metadata
 
 cmdclass
 
 command_packages
 
 script_name
 
 script_args
 
 command_options
 
 dist_files
 
 packages
 
 package_data
 
 package_dir
 
 py_modules
 
 libraries
 
 headers
 
 ext_modules
 
 ext_package
 
 include_dirs
 
 extra_path
 
 scripts
 
 data_files
 
 password
 
 command_obj
 
 have_run
 
 want_user_cfg
 
 commands
 

Static Public Attributes

 global_options
 
 common_usage
 
 display_options
 
 display_option_names
 
 negative_opt
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  attrs = None 
)
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()'.

Member Function Documentation

◆ announce()

def announce (   self,
  msg,
  level = log.INFO 
)

◆ dump_option_dicts()

def dump_option_dicts (   self,
  header = None,
  commands = None,
  indent = "" 
)

◆ finalize_options()

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

◆ find_config_files()

def find_config_files (   self)
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 three possible config files: distutils.cfg in the
Distutils installation directory (ie. 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; and setup.cfg in the current directory.

The file in the user's home directory can be disabled with the
--no-user-cfg option.

◆ get_command_class()

def get_command_class (   self,
  command 
)
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.

◆ get_command_list()

def get_command_list (   self)
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'.

◆ get_command_obj()

def get_command_obj (   self,
  command,
  create = 1 
)
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.

◆ get_command_packages()

def get_command_packages (   self)
Return a list of packages from which commands are loaded.

◆ get_option_dict()

def get_option_dict (   self,
  command 
)
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.

◆ handle_display_options()

def handle_display_options (   self,
  option_order 
)
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.

◆ has_c_libraries()

def has_c_libraries (   self)

◆ has_data_files()

def has_data_files (   self)

◆ has_ext_modules()

def has_ext_modules (   self)

◆ has_headers()

def has_headers (   self)

◆ has_modules()

def has_modules (   self)

◆ has_pure_modules()

def has_pure_modules (   self)

◆ has_scripts()

def has_scripts (   self)

◆ is_pure()

def is_pure (   self)

◆ parse_command_line()

def parse_command_line (   self)
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).

◆ parse_config_files()

def parse_config_files (   self,
  filenames = None 
)

◆ print_command_list()

def print_command_list (   self,
  commands,
  header,
  max_length 
)
Print a subset of the list of all commands -- used by
'print_commands()'.

◆ print_commands()

def print_commands (   self)
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'.

◆ reinitialize_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
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.

◆ run_command()

def run_command (   self,
  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.  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).

◆ run_commands()

def run_commands (   self)
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()'.

Field Documentation

◆ cmdclass

cmdclass

◆ command_obj

command_obj

◆ command_options

command_options

◆ command_packages

command_packages

◆ commands

commands

◆ common_usage

common_usage
static

◆ data_files

data_files

◆ display_option_names

display_option_names
static

◆ display_options

display_options
static

◆ dist_files

dist_files

◆ dry_run

dry_run

◆ ext_modules

ext_modules

◆ ext_package

ext_package

◆ extra_path

extra_path

◆ global_options

global_options
static

◆ have_run

have_run

◆ headers

headers

◆ help

help

◆ include_dirs

include_dirs

◆ libraries

libraries

◆ metadata

metadata

◆ negative_opt

negative_opt
static

◆ package_data

package_data

◆ package_dir

package_dir

◆ packages

packages

◆ password

password

◆ py_modules

py_modules

◆ script_args

script_args

◆ script_name

script_name

◆ scripts

scripts

◆ verbose

verbose

◆ want_user_cfg

want_user_cfg

The documentation for this class was generated from the following file: