Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions
distutils.command.install_lib.install_lib Class Reference
Inheritance diagram for distutils.command.install_lib.install_lib:
Inheritance graph
[legend]
Collaboration diagram for distutils.command.install_lib.install_lib:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initialize_options
def finalize_options
def run
def build
def install
def byte_compile
def get_outputs
def get_inputs

Public Attributes

 install_dir
 build_dir
 force
 compile
 optimize
 skip_build

Static Public Attributes

string description = "install all Python modules (extensions and pure Python)"
list user_options
list boolean_options = ['force', 'compile', 'skip-build']
dictionary negative_opt = {'no-compile' : 'compile'}

Private Member Functions

def _mutate_outputs
def _bytecode_filenames

Detailed Description

Definition at line 16 of file install_lib.py.


Member Function Documentation

def distutils.command.install_lib.install_lib._bytecode_filenames (   self,
  py_filenames 
) [private]

Definition at line 157 of file install_lib.py.

00157 
00158     def _bytecode_filenames(self, py_filenames):
00159         bytecode_files = []
00160         for py_file in py_filenames:
00161             # Since build_py handles package data installation, the
00162             # list of outputs can contain more than just .py files.
00163             # Make sure we only report bytecode for the .py files.
00164             ext = os.path.splitext(os.path.normcase(py_file))[1]
00165             if ext != PYTHON_SOURCE_EXTENSION:
00166                 continue
00167             if self.compile:
00168                 bytecode_files.append(py_file + "c")
00169             if self.optimize > 0:
00170                 bytecode_files.append(py_file + "o")
00171 
00172         return bytecode_files
00173 

Here is the caller graph for this function:

def distutils.command.install_lib.install_lib._mutate_outputs (   self,
  has_any,
  build_cmd,
  cmd_option,
  output_dir 
) [private]

Definition at line 142 of file install_lib.py.

00142 
00143     def _mutate_outputs(self, has_any, build_cmd, cmd_option, output_dir):
00144         if not has_any:
00145             return []
00146 
00147         build_cmd = self.get_finalized_command(build_cmd)
00148         build_files = build_cmd.get_outputs()
00149         build_dir = getattr(build_cmd, cmd_option)
00150 
00151         prefix_len = len(build_dir) + len(os.sep)
00152         outputs = []
00153         for file in build_files:
00154             outputs.append(os.path.join(output_dir, file[prefix_len:]))
00155 
00156         return outputs

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 101 of file install_lib.py.

00101 
00102     def build(self):
00103         if not self.skip_build:
00104             if self.distribution.has_pure_modules():
00105                 self.run_command('build_py')
00106             if self.distribution.has_ext_modules():
00107                 self.run_command('build_ext')

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 117 of file install_lib.py.

00117 
00118     def byte_compile(self, files):
00119         if sys.dont_write_bytecode:
00120             self.warn('byte-compiling is disabled, skipping.')
00121             return
00122 
00123         from distutils.util import byte_compile
00124 
00125         # Get the "--root" directory supplied to the "install" command,
00126         # and use it as a prefix to strip off the purported filename
00127         # encoded in bytecode files.  This is far from complete, but it
00128         # should at least generate usable bytecode in RPM distributions.
00129         install_root = self.get_finalized_command('install').root
00130 
00131         if self.compile:
00132             byte_compile(files, optimize=0,
00133                          force=self.force, prefix=install_root,
00134                          dry_run=self.dry_run)
00135         if self.optimize > 0:
00136             byte_compile(files, optimize=self.optimize,
00137                          force=self.force, prefix=install_root,
00138                          verbose=self.verbose, dry_run=self.dry_run)
00139 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 59 of file install_lib.py.

00059 
00060     def finalize_options(self):
00061         # Get all the information we need to install pure Python modules
00062         # from the umbrella 'install' command -- build (source) directory,
00063         # install (target) directory, and whether to compile .py files.
00064         self.set_undefined_options('install',
00065                                    ('build_lib', 'build_dir'),
00066                                    ('install_lib', 'install_dir'),
00067                                    ('force', 'force'),
00068                                    ('compile', 'compile'),
00069                                    ('optimize', 'optimize'),
00070                                    ('skip_build', 'skip_build'),
00071                                   )
00072 
00073         if self.compile is None:
00074             self.compile = True
00075         if self.optimize is None:
00076             self.optimize = False
00077 
00078         if not isinstance(self.optimize, int):
00079             try:
00080                 self.optimize = int(self.optimize)
00081                 if self.optimize not in (0, 1, 2):
00082                     raise AssertionError
00083             except (ValueError, AssertionError):
00084                 raise DistutilsOptionError("optimize must be 0, 1, or 2")

Here is the call graph for this function:

Here is the caller graph for this function:

Get the list of files that are input to this command, ie. the
files that get installed as they are named in the build tree.
The files in this list correspond one-to-one to the output
filenames returned by 'get_outputs()'.

Definition at line 198 of file install_lib.py.

00198 
00199     def get_inputs(self):
00200         """Get the list of files that are input to this command, ie. the
00201         files that get installed as they are named in the build tree.
00202         The files in this list correspond one-to-one to the output
00203         filenames returned by 'get_outputs()'.
00204         """
00205         inputs = []
00206 
00207         if self.distribution.has_pure_modules():
00208             build_py = self.get_finalized_command('build_py')
00209             inputs.extend(build_py.get_outputs())
00210 
00211         if self.distribution.has_ext_modules():
00212             build_ext = self.get_finalized_command('build_ext')
00213             inputs.extend(build_ext.get_outputs())
00214 
00215         return inputs

Here is the call graph for this function:

Return the list of files that would be installed if this command
were actually run.  Not affected by the "dry-run" flag or whether
modules have actually been built yet.

Definition at line 177 of file install_lib.py.

00177 
00178     def get_outputs(self):
00179         """Return the list of files that would be installed if this command
00180         were actually run.  Not affected by the "dry-run" flag or whether
00181         modules have actually been built yet.
00182         """
00183         pure_outputs = \
00184             self._mutate_outputs(self.distribution.has_pure_modules(),
00185                                  'build_py', 'build_lib',
00186                                  self.install_dir)
00187         if self.compile:
00188             bytecode_outputs = self._bytecode_filenames(pure_outputs)
00189         else:
00190             bytecode_outputs = []
00191 
00192         ext_outputs = \
00193             self._mutate_outputs(self.distribution.has_ext_modules(),
00194                                  'build_ext', 'build_lib',
00195                                  self.install_dir)
00196 
00197         return pure_outputs + bytecode_outputs + ext_outputs

Here is the call graph for this function:

Definition at line 50 of file install_lib.py.

00050 
00051     def initialize_options(self):
00052         # let the 'install' command dictate our installation directory
00053         self.install_dir = None
00054         self.build_dir = None
00055         self.force = 0
00056         self.compile = None
00057         self.optimize = None
00058         self.skip_build = None

Reimplemented in setup.PyBuildInstallLib.

Definition at line 108 of file install_lib.py.

00108 
00109     def install(self):
00110         if os.path.isdir(self.build_dir):
00111             outfiles = self.copy_tree(self.build_dir, self.install_dir)
00112         else:
00113             self.warn("'%s' does not exist -- no Python modules to install" %
00114                       self.build_dir)
00115             return
00116         return outfiles

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 85 of file install_lib.py.

00085 
00086     def run(self):
00087         # Make sure we have built everything we need first
00088         self.build()
00089 
00090         # Install everything: simply dump the entire contents of the build
00091         # directory to the installation directory (that's the beauty of
00092         # having a build directory!)
00093         outfiles = self.install()
00094 
00095         # (Optionally) compile .py to .pyc
00096         if outfiles is not None and self.distribution.has_pure_modules():
00097             self.byte_compile(outfiles)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 47 of file install_lib.py.

Definition at line 53 of file install_lib.py.

Definition at line 55 of file install_lib.py.

string distutils.command.install_lib.install_lib.description = "install all Python modules (extensions and pure Python)" [static]

Definition at line 18 of file install_lib.py.

Definition at line 54 of file install_lib.py.

Definition at line 52 of file install_lib.py.

Definition at line 48 of file install_lib.py.

Definition at line 56 of file install_lib.py.

Definition at line 57 of file install_lib.py.

Initial value:
[
        ('install-dir=', 'd', "directory to install to"),
        ('build-dir=','b', "build directory (where to install from)"),
        ('force', 'f', "force installation (overwrite existing files)"),
        ('compile', 'c', "compile .py to .pyc [default]"),
        ('no-compile', None, "don't compile .py files"),
        ('optimize=', 'O',
         "also compile with optimization: -O1 for \"python -O\", "
         "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"),
        ('skip-build', None, "skip the build steps"),
        ]

Definition at line 35 of file install_lib.py.


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