diff options
| author | ?ric Araujo <merwok@netwok.org> | 2010-08-07 18:19:03 +0200 |
|---|---|---|
| committer | ?ric Araujo <merwok@netwok.org> | 2010-08-07 18:19:03 +0200 |
| commit | 3f478eb52c69810dbfd0f87cbc4366d0056eb2e4 (patch) | |
| tree | 64584eefc6cc90d3d2e024a98b2a96239852bcd5 /src | |
| parent | 174684a8667175c6e4320b3b6e4c8f48c88c4a24 (diff) | |
| download | disutils2-3f478eb52c69810dbfd0f87cbc4366d0056eb2e4.tar.gz | |
Cleanup sweep (PEP 8)
Diffstat (limited to 'src')
| -rw-r--r-- | src/distutils2/command/install.py | 105 |
1 files changed, 51 insertions, 54 deletions
diff --git a/src/distutils2/command/install.py b/src/distutils2/command/install.py index 3cf3eff..1a6bd0e 100644 --- a/src/distutils2/command/install.py +++ b/src/distutils2/command/install.py @@ -18,6 +18,7 @@ from distutils2.util import write_file from distutils2.util import convert_path, change_root, get_platform from distutils2.errors import DistutilsOptionError + class install(Command): description = "install everything from build directory" @@ -31,7 +32,7 @@ class install(Command): ('home=', None, "(Unix only) home directory to install under"), - # Or, just set the base director(y|ies) + # Or just set the base director(y|ies) ('install-base=', None, "base installation directory (instead of --prefix or --home)"), ('install-platbase=', None, @@ -40,7 +41,7 @@ class install(Command): ('root=', None, "install everything relative to this alternate root directory"), - # Or, explicitly set the installation scheme + # Or explicitly set the installation scheme ('install-purelib=', None, "installation directory for pure Python module distributions"), ('install-platlib=', None, @@ -62,8 +63,8 @@ class install(Command): ('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]"), + 'also compile with optimization: -O1 for "python -O", ' + '-O2 for "python -OO", and -O0 to disable [default: -O0]'), # Miscellaneous control options ('force', 'f', @@ -98,7 +99,6 @@ class install(Command): boolean_options = ['compile', 'force', 'skip-build', 'no-distinfo', 'requested', 'no-record'] - negative_opt = {'no-compile' : 'compile', 'no-requested': 'requested'} if sys.version >= '2.6': user_options.append( ('user', None, @@ -107,9 +107,9 @@ class install(Command): boolean_options.append('user') + negative_opt = {'no-compile': 'compile', 'no-requested': 'requested'} def initialize_options(self): - """Initializes options.""" # High-level options: these select both an installation base # and scheme. self.prefix = None @@ -186,7 +186,6 @@ class install(Command): self.requested = None self.no_record = None - # -- Option finalizing methods ------------------------------------- # (This is rather more involved than for most commands, # because this is where the policy for installing third- @@ -194,7 +193,6 @@ class install(Command): # array of user input is decided. Yes, it's quite complex!) def finalize_options(self): - """Finalizes options.""" # This method (and its pliant slaves, like 'finalize_unix()', # 'finalize_other()', and 'select_scheme()') is where the default # installation directories for modules, extension modules, and @@ -211,18 +209,19 @@ class install(Command): if ((self.prefix or self.exec_prefix or self.home) and (self.install_base or self.install_platbase)): - raise DistutilsOptionError, \ - ("must supply either prefix/exec-prefix/home or " + - "install-base/install-platbase -- not both") + raise DistutilsOptionError( + "must supply either prefix/exec-prefix/home or " + "install-base/install-platbase -- not both") if self.home and (self.prefix or self.exec_prefix): - raise DistutilsOptionError, \ - "must supply either home or prefix/exec-prefix -- not both" + raise DistutilsOptionError( + "must supply either home or prefix/exec-prefix -- not both") if self.user and (self.prefix or self.exec_prefix or self.home or - self.install_base or self.install_platbase): - raise DistutilsOptionError("can't combine user with with prefix/" - "exec_prefix/home or install_(plat)base") + self.install_base or self.install_platbase): + raise DistutilsOptionError( + "can't combine user with prefix/exec_prefix/home or " + "install_base/install_platbase") # Next, stuff that's wrong (or dubious) only on certain platforms. if os.name != "posix": @@ -257,18 +256,19 @@ class install(Command): 'srcdir') metadata = self.distribution.metadata - self.config_vars = {'dist_name': metadata['Name'], - 'dist_version': metadata['Version'], - 'dist_fullname': metadata.get_fullname(), - 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'py_version_nodot': py_version[0] + py_version[2], - 'sys_prefix': prefix, - 'prefix': prefix, - 'sys_exec_prefix': exec_prefix, - 'exec_prefix': exec_prefix, - 'srcdir': srcdir, - } + self.config_vars = { + 'dist_name': metadata['Name'], + 'dist_version': metadata['Version'], + 'dist_fullname': metadata.get_fullname(), + 'py_version': py_version, + 'py_version_short': py_version[:3], + 'py_version_nodot': py_version[:3:2], + 'sys_prefix': prefix, + 'prefix': prefix, + 'sys_exec_prefix': exec_prefix, + 'exec_prefix': exec_prefix, + 'srcdir': srcdir, + } self.config_vars['userbase'] = self.install_userbase self.config_vars['usersite'] = self.install_usersite @@ -296,12 +296,11 @@ class install(Command): # module distribution is pure or not. Of course, if the user # already specified install_lib, use their selection. if self.install_lib is None: - if self.distribution.ext_modules: # has extensions: non-pure + if self.distribution.ext_modules: # has extensions: non-pure self.install_lib = self.install_platlib else: self.install_lib = self.install_purelib - # Convert directories from Unix /-separated syntax to the local # convention. self.convert_paths('lib', 'purelib', 'platlib', @@ -313,7 +312,7 @@ class install(Command): # non-packagized module distributions (hello, Numerical Python!) to # get their own directories. self.handle_extra_path() - self.install_libbase = self.install_lib # needed for .pth file + self.install_libbase = self.install_lib # needed for .pth file self.install_lib = os.path.join(self.install_lib, self.extra_dirs) # If a new root directory was supplied, make all the installation @@ -334,7 +333,7 @@ class install(Command): self.no_distinfo = False def finalize_unix(self): - """Finalizes options for posix platforms.""" + """Finalize options for posix platforms.""" if self.install_base is not None or self.install_platbase is not None: if ((self.install_lib is None and self.install_purelib is None and @@ -342,15 +341,15 @@ class install(Command): self.install_headers is None or self.install_scripts is None or self.install_data is None): - raise DistutilsOptionError, \ - ("install-base or install-platbase supplied, but " - "installation scheme is incomplete") + raise DistutilsOptionError( + "install-base or install-platbase supplied, but " + "installation scheme is incomplete") return if self.user: if self.install_userbase is None: raise DistutilsPlatformError( - "User base directory is not specified") + "user base directory is not specified") self.install_base = self.install_platbase = self.install_userbase self.select_scheme("posix_user") elif self.home is not None: @@ -359,8 +358,8 @@ class install(Command): else: if self.prefix is None: if self.exec_prefix is not None: - raise DistutilsOptionError, \ - "must not supply exec-prefix without prefix" + raise DistutilsOptionError( + "must not supply exec-prefix without prefix") self.prefix = os.path.normpath(sys.prefix) self.exec_prefix = os.path.normpath(sys.exec_prefix) @@ -374,11 +373,11 @@ class install(Command): self.select_scheme("posix_prefix") def finalize_other(self): - """Finalizes options for non-posix platforms""" + """Finalize options for non-posix platforms""" if self.user: if self.install_userbase is None: raise DistutilsPlatformError( - "User base directory is not specified") + "user base directory is not specified") self.install_base = self.install_platbase = self.install_userbase self.select_scheme(os.name + "_user") elif self.home is not None: @@ -392,11 +391,11 @@ class install(Command): try: self.select_scheme(os.name) except KeyError: - raise DistutilsPlatformError, \ - "I don't know how to install stuff on '%s'" % os.name + raise DistutilsPlatformError( + "no support for installation on '%s'" % os.name) def dump_dirs(self, msg): - """Dumps the list of user options.""" + """Dump the list of user options.""" log.debug(msg + ":") for opt in self.user_options: opt_name = opt[0] @@ -412,7 +411,7 @@ class install(Command): log.debug(" %s: %s" % (opt_name, val)) def select_scheme(self, name): - """Sets the install directories by applying the install schemes.""" + """Set the install directories by applying the install schemes.""" # it's the caller's problem if they supply a bad name! scheme = get_paths(name, expand=False) for key, value in scheme.items(): @@ -435,15 +434,14 @@ class install(Command): setattr(self, attr, val) def expand_basedirs(self): - """Calls `os.path.expanduser` on install_base, install_platbase and - root.""" + """Call `os.path.expanduser` on install_{base,platbase} and root.""" self._expand_attrs(['install_base', 'install_platbase', 'root']) def expand_dirs(self): - """Calls `os.path.expanduser` on install dirs.""" + """Call `os.path.expanduser` on install dirs.""" self._expand_attrs(['install_purelib', 'install_platlib', 'install_lib', 'install_headers', - 'install_scripts', 'install_data',]) + 'install_scripts', 'install_data']) def convert_paths(self, *names): """Call `convert_path` over `names`.""" @@ -465,9 +463,9 @@ class install(Command): elif len(self.extra_path) == 2: path_file, extra_dirs = self.extra_path else: - raise DistutilsOptionError, \ - ("'extra_path' option must be a list, tuple, or " - "comma-separated string with 1 or 2 elements") + raise DistutilsOptionError( + "'extra_path' option must be a list, tuple, or " + "comma-separated string with 1 or 2 elements") # convert to local form in case Unix notation used (as it # should be in setup scripts) @@ -553,7 +551,6 @@ class install(Command): else: self.warn("path file '%s' not created" % filename) - # -- Reporting methods --------------------------------------------- def get_outputs(self): @@ -608,10 +605,10 @@ class install(Command): # 'sub_commands': a list of commands this command might have to run to # get its work done. See cmd.py for more info. - sub_commands = [('install_lib', has_lib), + sub_commands = [('install_lib', has_lib), ('install_headers', has_headers), ('install_scripts', has_scripts), - ('install_data', has_data), + ('install_data', has_data), # keep install_distinfo last, as it needs the record # with files to be completely generated ('install_distinfo', lambda self: not self.no_distinfo), |
