Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
setup.PyBuildInstall Class Reference
Inheritance diagram for setup.PyBuildInstall:
Inheritance graph
[legend]
Collaboration diagram for setup.PyBuildInstall:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def initialize_options
def finalize_options
def dump_dirs
def finalize_unix
def finalize_other
def select_scheme
def expand_basedirs
def expand_dirs
def convert_paths
def handle_extra_path
def change_roots
def create_home_path
def run
def create_path_file
def get_outputs
def get_inputs
def has_lib
def has_headers
def has_scripts
def has_data

Public Attributes

 warn_dir
 prefix
 exec_prefix
 home
 user
 install_base
 install_platbase
 root
 install_purelib
 install_platlib
 install_headers
 install_lib
 install_scripts
 install_data
 install_userbase
 install_usersite
 compile
 optimize
 extra_path
 install_path_file
 force
 skip_build
 build_base
 build_lib
 record
 config_vars
 install_libbase
 path_file
 extra_dirs

Static Public Attributes

string description = "install everything from build directory"
list user_options
list boolean_options = ['compile', 'force', 'skip-build']
dictionary negative_opt = {'no-compile' : 'compile'}
list sub_commands

Detailed Description

Definition at line 1775 of file setup.py.


Member Function Documentation

def distutils.command.install.install.change_roots (   self,
  names 
) [inherited]
Change the install direcories pointed by name using root.

Definition at line 547 of file install.py.

00547 
00548     def change_roots(self, *names):
00549         """Change the install direcories pointed by name using root."""
00550         for name in names:
00551             attr = "install_" + name
00552             setattr(self, attr, change_root(self.root, getattr(self, attr)))

Here is the call graph for this function:

def distutils.command.install.install.convert_paths (   self,
  names 
) [inherited]
Call `convert_path` over `names`.

Definition at line 511 of file install.py.

00511 
00512     def convert_paths(self, *names):
00513         """Call `convert_path` over `names`."""
00514         for name in names:
00515             attr = "install_" + name
00516             setattr(self, attr, convert_path(getattr(self, attr)))

Here is the call graph for this function:

Create directories under ~.

Definition at line 553 of file install.py.

00553 
00554     def create_home_path(self):
00555         """Create directories under ~."""
00556         if not self.user:
00557             return
00558         home = convert_path(os.path.expanduser("~"))
00559         for name, path in self.config_vars.items():
00560             if path.startswith(home) and not os.path.isdir(path):
00561                 self.debug_print("os.makedirs('%s', 0o700)" % path)
00562                 os.makedirs(path, 0o700)

Here is the call graph for this function:

Creates the .pth file

Definition at line 609 of file install.py.

00609 
00610     def create_path_file(self):
00611         """Creates the .pth file"""
00612         filename = os.path.join(self.install_libbase,
00613                                 self.path_file + ".pth")
00614         if self.install_path_file:
00615             self.execute(write_file,
00616                          (filename, [self.extra_dirs]),
00617                          "creating %s" % filename)
00618         else:
00619             self.warn("path file '%s' not created" % filename)
00620 

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.command.install.install.dump_dirs (   self,
  msg 
) [inherited]
Dumps the list of user options.

Definition at line 401 of file install.py.

00401 
00402     def dump_dirs(self, msg):
00403         """Dumps the list of user options."""
00404         if not DEBUG:
00405             return
00406         from distutils.fancy_getopt import longopt_xlate
00407         log.debug(msg + ":")
00408         for opt in self.user_options:
00409             opt_name = opt[0]
00410             if opt_name[-1] == "=":
00411                 opt_name = opt_name[0:-1]
00412             if opt_name in self.negative_opt:
00413                 opt_name = self.negative_opt[opt_name]
00414                 opt_name = opt_name.translate(longopt_xlate)
00415                 val = not getattr(self, opt_name)
00416             else:
00417                 opt_name = opt_name.translate(longopt_xlate)
00418                 val = getattr(self, opt_name)
00419             log.debug("  %s: %s" % (opt_name, val))

Here is the call graph for this function:

Here is the caller graph for this function:

Calls `os.path.expanduser` on install_base, install_platbase and
root.

Definition at line 500 of file install.py.

00500 
00501     def expand_basedirs(self):
00502         """Calls `os.path.expanduser` on install_base, install_platbase and
00503         root."""
00504         self._expand_attrs(['install_base', 'install_platbase', 'root'])

Here is the call graph for this function:

Calls `os.path.expanduser` on install dirs.

Definition at line 505 of file install.py.

00505 
00506     def expand_dirs(self):
00507         """Calls `os.path.expanduser` on install dirs."""
00508         self._expand_attrs(['install_purelib', 'install_platlib',
00509                             'install_lib', 'install_headers',
00510                             'install_scripts', 'install_data',])

Here is the call graph for this function:

Finalizes options.

Definition at line 253 of file install.py.

00253 
00254     def finalize_options(self):
00255         """Finalizes options."""
00256         # This method (and its pliant slaves, like 'finalize_unix()',
00257         # 'finalize_other()', and 'select_scheme()') is where the default
00258         # installation directories for modules, extension modules, and
00259         # anything else we care to install from a Python module
00260         # distribution.  Thus, this code makes a pretty important policy
00261         # statement about how third-party stuff is added to a Python
00262         # installation!  Note that the actual work of installation is done
00263         # by the relatively simple 'install_*' commands; they just take
00264         # their orders from the installation directory options determined
00265         # here.
00266 
00267         # Check for errors/inconsistencies in the options; first, stuff
00268         # that's wrong on any platform.
00269 
00270         if ((self.prefix or self.exec_prefix or self.home) and
00271             (self.install_base or self.install_platbase)):
00272             raise DistutilsOptionError(
00273                    "must supply either prefix/exec-prefix/home or " +
00274                    "install-base/install-platbase -- not both")
00275 
00276         if self.home and (self.prefix or self.exec_prefix):
00277             raise DistutilsOptionError(
00278                   "must supply either home or prefix/exec-prefix -- not both")
00279 
00280         if self.user and (self.prefix or self.exec_prefix or self.home or
00281                 self.install_base or self.install_platbase):
00282             raise DistutilsOptionError("can't combine user with with prefix/"
00283                                        "exec_prefix/home or install_(plat)base")
00284 
00285         # Next, stuff that's wrong (or dubious) only on certain platforms.
00286         if os.name != "posix":
00287             if self.exec_prefix:
00288                 self.warn("exec-prefix option ignored on this platform")
00289                 self.exec_prefix = None
00290 
00291         # Now the interesting logic -- so interesting that we farm it out
00292         # to other methods.  The goal of these methods is to set the final
00293         # values for the install_{lib,scripts,data,...}  options, using as
00294         # input a heady brew of prefix, exec_prefix, home, install_base,
00295         # install_platbase, user-supplied versions of
00296         # install_{purelib,platlib,lib,scripts,data,...}, and the
00297         # INSTALL_SCHEME dictionary above.  Phew!
00298 
00299         self.dump_dirs("pre-finalize_{unix,other}")
00300 
00301         if os.name == 'posix':
00302             self.finalize_unix()
00303         else:
00304             self.finalize_other()
00305 
00306         self.dump_dirs("post-finalize_{unix,other}()")
00307 
00308         # Expand configuration variables, tilde, etc. in self.install_base
00309         # and self.install_platbase -- that way, we can use $base or
00310         # $platbase in the other installation directories and not worry
00311         # about needing recursive variable expansion (shudder).
00312 
00313         py_version = sys.version.split()[0]
00314         (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
00315         try:
00316             abiflags = sys.abiflags
00317         except AttributeError:
00318             # sys.abiflags may not be defined on all platforms.
00319             abiflags = ''
00320         self.config_vars = {'dist_name': self.distribution.get_name(),
00321                             'dist_version': self.distribution.get_version(),
00322                             'dist_fullname': self.distribution.get_fullname(),
00323                             'py_version': py_version,
00324                             'py_version_short': py_version[0:3],
00325                             'py_version_nodot': py_version[0] + py_version[2],
00326                             'sys_prefix': prefix,
00327                             'prefix': prefix,
00328                             'sys_exec_prefix': exec_prefix,
00329                             'exec_prefix': exec_prefix,
00330                             'abiflags': abiflags,
00331                            }
00332 
00333         if HAS_USER_SITE:
00334             self.config_vars['userbase'] = self.install_userbase
00335             self.config_vars['usersite'] = self.install_usersite
00336 
00337         self.expand_basedirs()
00338 
00339         self.dump_dirs("post-expand_basedirs()")
00340 
00341         # Now define config vars for the base directories so we can expand
00342         # everything else.
00343         self.config_vars['base'] = self.install_base
00344         self.config_vars['platbase'] = self.install_platbase
00345 
00346         if DEBUG:
00347             from pprint import pprint
00348             print("config vars:")
00349             pprint(self.config_vars)
00350 
00351         # Expand "~" and configuration variables in the installation
00352         # directories.
00353         self.expand_dirs()
00354 
00355         self.dump_dirs("post-expand_dirs()")
00356 
00357         # Create directories in the home dir:
00358         if self.user:
00359             self.create_home_path()
00360 
00361         # Pick the actual directory to install all modules to: either
00362         # install_purelib or install_platlib, depending on whether this
00363         # module distribution is pure or not.  Of course, if the user
00364         # already specified install_lib, use their selection.
00365         if self.install_lib is None:
00366             if self.distribution.ext_modules: # has extensions: non-pure
00367                 self.install_lib = self.install_platlib
00368             else:
00369                 self.install_lib = self.install_purelib
00370 
00371 
00372         # Convert directories from Unix /-separated syntax to the local
00373         # convention.
00374         self.convert_paths('lib', 'purelib', 'platlib',
00375                            'scripts', 'data', 'headers',
00376                            'userbase', 'usersite')
00377 
00378         # Well, we're not actually fully completely finalized yet: we still
00379         # have to deal with 'extra_path', which is the hack for allowing
00380         # non-packagized module distributions (hello, Numerical Python!) to
00381         # get their own directories.
00382         self.handle_extra_path()
00383         self.install_libbase = self.install_lib # needed for .pth file
00384         self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
00385 
00386         # If a new root directory was supplied, make all the installation
00387         # dirs relative to it.
00388         if self.root is not None:
00389             self.change_roots('libbase', 'lib', 'purelib', 'platlib',
00390                               'scripts', 'data', 'headers')
00391 
00392         self.dump_dirs("after prepending root")
00393 
00394         # Find out the build directories, ie. where to install from.
00395         self.set_undefined_options('build',
00396                                    ('build_base', 'build_base'),
00397                                    ('build_lib', 'build_lib'))
00398 
00399         # Punt on doc directories for now -- after all, we're punting on
00400         # documentation completely!

Here is the call graph for this function:

Here is the caller graph for this function:

Finalizes options for non-posix platforms

Definition at line 460 of file install.py.

00460 
00461     def finalize_other(self):
00462         """Finalizes options for non-posix platforms"""
00463         if self.user:
00464             if self.install_userbase is None:
00465                 raise DistutilsPlatformError(
00466                     "User base directory is not specified")
00467             self.install_base = self.install_platbase = self.install_userbase
00468             self.select_scheme(os.name + "_user")
00469         elif self.home is not None:
00470             self.install_base = self.install_platbase = self.home
00471             self.select_scheme("unix_home")
00472         else:
00473             if self.prefix is None:
00474                 self.prefix = os.path.normpath(sys.prefix)
00475 
00476             self.install_base = self.install_platbase = self.prefix
00477             try:
00478                 self.select_scheme(os.name)
00479             except KeyError:
00480                 raise DistutilsPlatformError(
00481                       "I don't know how to install stuff on '%s'" % os.name)

Here is the call graph for this function:

Here is the caller graph for this function:

Finalizes options for posix platforms.

Definition at line 420 of file install.py.

00420 
00421     def finalize_unix(self):
00422         """Finalizes options for posix platforms."""
00423         if self.install_base is not None or self.install_platbase is not None:
00424             if ((self.install_lib is None and
00425                  self.install_purelib is None and
00426                  self.install_platlib is None) or
00427                 self.install_headers is None or
00428                 self.install_scripts is None or
00429                 self.install_data is None):
00430                 raise DistutilsOptionError(
00431                       "install-base or install-platbase supplied, but "
00432                       "installation scheme is incomplete")
00433             return
00434 
00435         if self.user:
00436             if self.install_userbase is None:
00437                 raise DistutilsPlatformError(
00438                     "User base directory is not specified")
00439             self.install_base = self.install_platbase = self.install_userbase
00440             self.select_scheme("unix_user")
00441         elif self.home is not None:
00442             self.install_base = self.install_platbase = self.home
00443             self.select_scheme("unix_home")
00444         else:
00445             if self.prefix is None:
00446                 if self.exec_prefix is not None:
00447                     raise DistutilsOptionError(
00448                           "must not supply exec-prefix without prefix")
00449 
00450                 self.prefix = os.path.normpath(sys.prefix)
00451                 self.exec_prefix = os.path.normpath(sys.exec_prefix)
00452 
00453             else:
00454                 if self.exec_prefix is None:
00455                     self.exec_prefix = self.prefix
00456 
00457             self.install_base = self.prefix
00458             self.install_platbase = self.exec_prefix
00459             self.select_scheme("unix_prefix")

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the inputs of all the sub-commands

Definition at line 640 of file install.py.

00640 
00641     def get_inputs(self):
00642         """Returns the inputs of all the sub-commands"""
00643         # XXX gee, this looks familiar ;-(
00644         inputs = []
00645         for cmd_name in self.get_sub_commands():
00646             cmd = self.get_finalized_command(cmd_name)
00647             inputs.extend(cmd.get_inputs())
00648 
00649         return inputs

Here is the call graph for this function:

Assembles the outputs of all the sub-commands.

Definition at line 623 of file install.py.

00623 
00624     def get_outputs(self):
00625         """Assembles the outputs of all the sub-commands."""
00626         outputs = []
00627         for cmd_name in self.get_sub_commands():
00628             cmd = self.get_finalized_command(cmd_name)
00629             # Add the contents of cmd.get_outputs(), ensuring
00630             # that outputs doesn't contain duplicate entries
00631             for filename in cmd.get_outputs():
00632                 if filename not in outputs:
00633                     outputs.append(filename)
00634 
00635         if self.path_file and self.install_path_file:
00636             outputs.append(os.path.join(self.install_libbase,
00637                                         self.path_file + ".pth"))
00638 
00639         return outputs

Here is the call graph for this function:

Here is the caller graph for this function:

Set `path_file` and `extra_dirs` using `extra_path`.

Definition at line 517 of file install.py.

00517 
00518     def handle_extra_path(self):
00519         """Set `path_file` and `extra_dirs` using `extra_path`."""
00520         if self.extra_path is None:
00521             self.extra_path = self.distribution.extra_path
00522 
00523         if self.extra_path is not None:
00524             if isinstance(self.extra_path, str):
00525                 self.extra_path = self.extra_path.split(',')
00526 
00527             if len(self.extra_path) == 1:
00528                 path_file = extra_dirs = self.extra_path[0]
00529             elif len(self.extra_path) == 2:
00530                 path_file, extra_dirs = self.extra_path
00531             else:
00532                 raise DistutilsOptionError(
00533                       "'extra_path' option must be a list, tuple, or "
00534                       "comma-separated string with 1 or 2 elements")
00535 
00536             # convert to local form in case Unix notation used (as it
00537             # should be in setup scripts)
00538             extra_dirs = convert_path(extra_dirs)
00539         else:
00540             path_file = None
00541             extra_dirs = ''
00542 
00543         # XXX should we warn if path_file and not extra_dirs? (in which
00544         # case the path file would be harmless but pointless)
00545         self.path_file = path_file
00546         self.extra_dirs = extra_dirs

Here is the call graph for this function:

def distutils.command.install.install.has_data (   self) [inherited]
Returns true if the current distribution has any data to.
install.

Definition at line 668 of file install.py.

00668 
00669     def has_data(self):
00670         """Returns true if the current distribution has any data to.
00671         install."""
00672         return self.distribution.has_data_files()

Returns true if the current distribution has any headers to
install.

Definition at line 658 of file install.py.

00658 
00659     def has_headers(self):
00660         """Returns true if the current distribution has any headers to
00661         install."""
00662         return self.distribution.has_headers()

def distutils.command.install.install.has_lib (   self) [inherited]
Returns true if the current distribution has any Python
modules to install.

Definition at line 652 of file install.py.

00652 
00653     def has_lib(self):
00654         """Returns true if the current distribution has any Python
00655         modules to install."""
00656         return (self.distribution.has_pure_modules() or
00657                 self.distribution.has_ext_modules())

Returns true if the current distribution has any scripts to.
install.

Definition at line 663 of file install.py.

00663 
00664     def has_scripts(self):
00665         """Returns true if the current distribution has any scripts to.
00666         install."""
00667         return self.distribution.has_scripts()

Initializes options.

Reimplemented from distutils.command.install.install.

Definition at line 1779 of file setup.py.

01779 
01780     def initialize_options (self):
01781         install.initialize_options(self)
01782         self.warn_dir=0

def distutils.command.install.install.run (   self) [inherited]
Runs the command.

Definition at line 565 of file install.py.

00565 
00566     def run(self):
00567         """Runs the command."""
00568         # Obviously have to build before we can install
00569         if not self.skip_build:
00570             self.run_command('build')
00571             # If we built for any other platform, we can't install.
00572             build_plat = self.distribution.get_command_obj('build').plat_name
00573             # check warn_dir - it is a clue that the 'install' is happening
00574             # internally, and not to sys.path, so we don't check the platform
00575             # matches what we are running.
00576             if self.warn_dir and build_plat != get_platform():
00577                 raise DistutilsPlatformError("Can't install when "
00578                                              "cross-compiling")
00579 
00580         # Run all sub-commands (at least those that need to be run)
00581         for cmd_name in self.get_sub_commands():
00582             self.run_command(cmd_name)
00583 
00584         if self.path_file:
00585             self.create_path_file()
00586 
00587         # write list of installed files, if requested.
00588         if self.record:
00589             outputs = self.get_outputs()
00590             if self.root:               # strip any package prefix
00591                 root_len = len(self.root)
00592                 for counter in range(len(outputs)):
00593                     outputs[counter] = outputs[counter][root_len:]
00594             self.execute(write_file,
00595                          (self.record, outputs),
00596                          "writing list of installed files to '%s'" %
00597                          self.record)
00598 
00599         sys_path = map(os.path.normpath, sys.path)
00600         sys_path = map(os.path.normcase, sys_path)
00601         install_lib = os.path.normcase(os.path.normpath(self.install_lib))
00602         if (self.warn_dir and
00603             not (self.path_file and self.install_path_file) and
00604             install_lib not in sys_path):
00605             log.debug(("modules installed to '%s', which is not in "
00606                        "Python's module search path (sys.path) -- "
00607                        "you'll have to change the search path yourself"),
00608                        self.install_lib)

Here is the call graph for this function:

Here is the caller graph for this function:

def distutils.command.install.install.select_scheme (   self,
  name 
) [inherited]
Sets the install directories by applying the install schemes.

Definition at line 482 of file install.py.

00482 
00483     def select_scheme(self, name):
00484         """Sets the install directories by applying the install schemes."""
00485         # it's the caller's problem if they supply a bad name!
00486         scheme = INSTALL_SCHEMES[name]
00487         for key in SCHEME_KEYS:
00488             attrname = 'install_' + key
00489             if getattr(self, attrname) is None:
00490                 setattr(self, attrname, scheme[key])

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

list distutils.command.install.install.boolean_options = ['compile', 'force', 'skip-build'] [static, inherited]

Definition at line 166 of file install.py.

Definition at line 235 of file install.py.

Definition at line 236 of file install.py.

Definition at line 205 of file install.py.

Definition at line 319 of file install.py.

string distutils.command.install.install.description = "install everything from build directory" [static, inherited]

Definition at line 105 of file install.py.

Definition at line 181 of file install.py.

Definition at line 545 of file install.py.

Definition at line 216 of file install.py.

Definition at line 225 of file install.py.

Definition at line 182 of file install.py.

Definition at line 188 of file install.py.

Definition at line 201 of file install.py.

Definition at line 198 of file install.py.

Definition at line 199 of file install.py.

Definition at line 382 of file install.py.

Definition at line 217 of file install.py.

Definition at line 189 of file install.py.

Definition at line 197 of file install.py.

Definition at line 196 of file install.py.

Definition at line 200 of file install.py.

Definition at line 202 of file install.py.

Definition at line 203 of file install.py.

Definition at line 173 of file install.py.

Definition at line 206 of file install.py.

Definition at line 544 of file install.py.

Definition at line 180 of file install.py.

Definition at line 244 of file install.py.

Definition at line 190 of file install.py.

Definition at line 226 of file install.py.

Initial value:
[('install_lib',     has_lib),
                    ('install_headers', has_headers),
                    ('install_scripts', has_scripts),
                    ('install_data',    has_data),
                    ('install_egg_info', lambda self:True),
                   ]

Definition at line 675 of file install.py.

Definition at line 183 of file install.py.

Definition at line 107 of file install.py.

Reimplemented from distutils.command.install.install.

Definition at line 1781 of file setup.py.


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