reverting partially distutils to its 2.6.x state so 2.7a4 looks more like the 2.7b1 in this. the whole revert will occur after a4 is tagged
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 420d7f1..8248089 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -4,27 +4,21 @@
modules (currently limited to C extensions, should accommodate C++
extensions ASAP)."""
+# This module should be kept compatible with Python 2.1.
+
__revision__ = "$Id$"
-import sys, os, re
-from warnings import warn
-
-from distutils.util import get_platform
+import sys, os, string, re
+from types import *
+from site import USER_BASE, USER_SITE
from distutils.core import Command
from distutils.errors import *
-from distutils.ccompiler import customize_compiler
+from distutils.sysconfig import customize_compiler, get_python_version
from distutils.dep_util import newer_group
from distutils.extension import Extension
+from distutils.util import get_platform
from distutils import log
-# this keeps compatibility from 2.3 to 2.5
-if sys.version < "2.6":
- USER_BASE = None
- HAS_USER_SITE = False
-else:
- from site import USER_BASE
- HAS_USER_SITE = True
-
if os.name == 'nt':
from distutils.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -40,7 +34,7 @@
show_compilers()
-class build_ext(Command):
+class build_ext (Command):
description = "build C/C++ extensions (compile/link to build directory)"
@@ -100,55 +94,18 @@
"list of SWIG command line options"),
('swig=', None,
"path to the SWIG executable"),
+ ('user', None,
+ "add user include, library and rpath"),
]
- boolean_options = ['inplace', 'debug', 'force', 'swig-cpp']
-
- if HAS_USER_SITE:
- user_options.append(('user', None,
- "add user include, library and rpath"))
- boolean_options.append('user')
+ boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
help_options = [
('help-compiler', None,
"list available compilers", show_compilers),
]
-
- # making 'compiler' a property to deprecate
- # its usage as something else than a compiler type
- # e.g. like a compiler instance
- def __init__(self, dist):
- self._compiler = None
- Command.__init__(self, dist)
-
- def __setattr__(self, name, value):
- # need this to make sure setattr() (used in distutils)
- # doesn't kill our property
- if name == 'compiler':
- self._set_compiler(value)
- else:
- self.__dict__[name] = value
-
- def _set_compiler(self, compiler):
- if not isinstance(compiler, str) and compiler is not None:
- # we don't want to allow that anymore in the future
- warn("'compiler' specifies the compiler type in build_ext. "
- "If you want to get the compiler object itself, "
- "use 'compiler_obj'", DeprecationWarning)
- self._compiler = compiler
-
- def _get_compiler(self):
- if not isinstance(self._compiler, str) and self._compiler is not None:
- # we don't want to allow that anymore in the future
- warn("'compiler' specifies the compiler type in build_ext. "
- "If you want to get the compiler object itself, "
- "use 'compiler_obj'", DeprecationWarning)
- return self._compiler
-
- compiler = property(_get_compiler, _set_compiler)
-
- def initialize_options(self):
+ def initialize_options (self):
self.extensions = None
self.build_lib = None
self.plat_name = None
@@ -172,7 +129,8 @@
self.user = None
def finalize_options(self):
- _sysconfig = __import__('sysconfig')
+ from distutils import sysconfig
+
self.set_undefined_options('build',
('build_lib', 'build_lib'),
('build_temp', 'build_temp'),
@@ -189,8 +147,8 @@
# Make sure Python's include directories (for Python.h, pyconfig.h,
# etc.) are in the include search path.
- py_include = _sysconfig.get_path('include')
- plat_py_include = _sysconfig.get_path('platinclude')
+ py_include = sysconfig.get_python_inc()
+ plat_py_include = sysconfig.get_python_inc(plat_specific=1)
if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or []
if isinstance(self.include_dirs, str):
@@ -211,13 +169,13 @@
self.libraries = []
if self.library_dirs is None:
self.library_dirs = []
- elif isinstance(self.library_dirs, str):
- self.library_dirs = self.library_dirs.split(os.pathsep)
+ elif type(self.library_dirs) is StringType:
+ self.library_dirs = string.split(self.library_dirs, os.pathsep)
if self.rpath is None:
self.rpath = []
- elif isinstance(self.rpath, str):
- self.rpath = self.rpath.split(os.pathsep)
+ elif type(self.rpath) is StringType:
+ self.rpath = string.split(self.rpath, os.pathsep)
# for extensions under windows use different directories
# for Release and Debug builds.
@@ -268,7 +226,7 @@
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
# building third party extensions
self.library_dirs.append(os.path.join(sys.prefix, "lib",
- "python" + _sysconfig.get_python_version(),
+ "python" + get_python_version(),
"config"))
else:
# building python standard extensions
@@ -276,13 +234,13 @@
# for extensions under Linux or Solaris with a shared Python library,
# Python's library directory must be appended to library_dirs
- _sysconfig.get_config_var('Py_ENABLE_SHARED')
+ sysconfig.get_config_var('Py_ENABLE_SHARED')
if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu')
or sys.platform.startswith('sunos'))
- and _sysconfig.get_config_var('Py_ENABLE_SHARED')):
+ and sysconfig.get_config_var('Py_ENABLE_SHARED')):
if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
# building third party extensions
- self.library_dirs.append(_sysconfig.get_config_var('LIBDIR'))
+ self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
else:
# building python standard extensions
self.library_dirs.append('.')
@@ -294,7 +252,7 @@
if self.define:
defines = self.define.split(',')
- self.define = [(symbol, '1') for symbol in defines]
+ self.define = map(lambda symbol: (symbol, '1'), defines)
# The option for macros to undefine is also a string from the
# option parsing, but has to be a list. Multiple symbols can also
@@ -345,50 +303,38 @@
# Setup the CCompiler object that we'll use to do all the
# compiling and linking
-
- # used to prevent the usage of an existing compiler for the
- # compiler option when calling new_compiler()
- # this will be removed in 3.3 and 2.8
- if not isinstance(self._compiler, str):
- self._compiler = None
-
- self.compiler_obj = new_compiler(compiler=self._compiler,
- verbose=self.verbose,
- dry_run=self.dry_run,
- force=self.force)
-
- # used to keep the compiler object reachable with
- # "self.compiler". this will be removed in 3.3 and 2.8
- self._compiler = self.compiler_obj
-
- customize_compiler(self.compiler_obj)
+ self.compiler = new_compiler(compiler=self.compiler,
+ verbose=self.verbose,
+ dry_run=self.dry_run,
+ force=self.force)
+ customize_compiler(self.compiler)
# If we are cross-compiling, init the compiler now (if we are not
# cross-compiling, init would not hurt, but people may rely on
# late initialization of compiler even if they shouldn't...)
if os.name == 'nt' and self.plat_name != get_platform():
- self.compiler_obj.initialize(self.plat_name)
+ self.compiler.initialize(self.plat_name)
# And make sure that any compile/link-related options (which might
# come from the command-line or from the setup script) are set in
# that CCompiler object -- that way, they automatically apply to
# all compiling and linking done here.
if self.include_dirs is not None:
- self.compiler_obj.set_include_dirs(self.include_dirs)
+ self.compiler.set_include_dirs(self.include_dirs)
if self.define is not None:
# 'define' option is a list of (name,value) tuples
for (name, value) in self.define:
- self.compiler_obj.define_macro(name, value)
+ self.compiler.define_macro(name, value)
if self.undef is not None:
for macro in self.undef:
- self.compiler_obj.undefine_macro(macro)
+ self.compiler.undefine_macro(macro)
if self.libraries is not None:
- self.compiler_obj.set_libraries(self.libraries)
+ self.compiler.set_libraries(self.libraries)
if self.library_dirs is not None:
- self.compiler_obj.set_library_dirs(self.library_dirs)
+ self.compiler.set_library_dirs(self.library_dirs)
if self.rpath is not None:
- self.compiler_obj.set_runtime_library_dirs(self.rpath)
+ self.compiler.set_runtime_library_dirs(self.rpath)
if self.link_objects is not None:
- self.compiler_obj.set_link_objects(self.link_objects)
+ self.compiler.set_link_objects(self.link_objects)
# Now actually compile and link everything.
self.build_extensions()
@@ -500,17 +446,11 @@
self.check_extensions_list(self.extensions)
for ext in self.extensions:
- try:
- self.build_extension(ext)
- except (CCompilerError, DistutilsError, CompileError), e:
- if not ext.optional:
- raise
- self.warn('building extension "%s" failed: %s' %
- (ext.name, e))
+ self.build_extension(ext)
def build_extension(self, ext):
sources = ext.sources
- if sources is None or not isinstance(sources, (list, tuple)):
+ if sources is None or type(sources) not in (ListType, TupleType):
raise DistutilsSetupError, \
("in 'ext_modules' option (extension '%s'), " +
"'sources' must be present and must be " +
@@ -550,13 +490,13 @@
for undef in ext.undef_macros:
macros.append((undef,))
- objects = self.compiler_obj.compile(sources,
- output_dir=self.build_temp,
- macros=macros,
- include_dirs=ext.include_dirs,
- debug=self.debug,
- extra_postargs=extra_args,
- depends=ext.depends)
+ objects = self.compiler.compile(sources,
+ output_dir=self.build_temp,
+ macros=macros,
+ include_dirs=ext.include_dirs,
+ debug=self.debug,
+ extra_postargs=extra_args,
+ depends=ext.depends)
# XXX -- this is a Vile HACK!
#
@@ -577,9 +517,9 @@
extra_args = ext.extra_link_args or []
# Detect target language, if not provided
- language = ext.language or self.compiler_obj.detect_language(sources)
+ language = ext.language or self.compiler.detect_language(sources)
- self.compiler_obj.link_shared_object(
+ self.compiler.link_shared_object(
objects, ext_path,
libraries=self.get_libraries(ext),
library_dirs=ext.library_dirs,
@@ -591,12 +531,14 @@
target_lang=language)
- def swig_sources(self, sources, extension):
+ def swig_sources (self, sources, extension):
+
"""Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
"""
+
new_sources = []
swig_sources = []
swig_targets = {}
@@ -645,7 +587,9 @@
return new_sources
- def find_swig(self):
+ # swig_sources ()
+
+ def find_swig (self):
"""Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.
@@ -674,6 +618,8 @@
("I don't know how to find (much less run) SWIG "
"on platform '%s'") % os.name
+ # find_swig ()
+
# -- Name generators -----------------------------------------------
# (extension names, filenames, whatever)
def get_ext_fullpath(self, ext_name):
@@ -682,9 +628,14 @@
The file is located in `build_lib` or directly in the package
(inplace option).
"""
+ # makes sure the extension name is only using dots
+ all_dots = string.maketrans('/'+os.sep, '..')
+ ext_name = ext_name.translate(all_dots)
+
fullname = self.get_ext_fullname(ext_name)
modpath = fullname.split('.')
- filename = self.get_ext_filename(modpath[-1])
+ filename = self.get_ext_filename(ext_name)
+ filename = os.path.split(filename)[-1]
if not self.inplace:
# no further work needed
@@ -717,18 +668,18 @@
of the file from which it will be loaded (eg. "foo/bar.so", or
"foo\bar.pyd").
"""
- _sysconfig = __import__('sysconfig')
- ext_path = ext_name.split('.')
+ from distutils.sysconfig import get_config_var
+ ext_path = string.split(ext_name, '.')
# OS/2 has an 8 character module (extension) limit :-(
if os.name == "os2":
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
# extensions in debug_mode are named 'module_d.pyd' under windows
- so_ext = _sysconfig.get_config_var('SO')
+ so_ext = get_config_var('SO')
if os.name == 'nt' and self.debug:
- return os.path.join(*ext_path) + '_d' + so_ext
+ return apply(os.path.join, ext_path) + '_d' + so_ext
return os.path.join(*ext_path) + so_ext
- def get_export_symbols(self, ext):
+ def get_export_symbols (self, ext):
"""Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
provided, "init" + module_name. Only relevant on Windows, where
@@ -739,7 +690,7 @@
ext.export_symbols.append(initfunc_name)
return ext.export_symbols
- def get_libraries(self, ext):
+ def get_libraries (self, ext):
"""Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
on Windows and OS/2, we add the Python library (eg. python20.dll).
@@ -751,7 +702,7 @@
# Append '_d' to the python import library on debug builds.
if sys.platform == "win32":
from distutils.msvccompiler import MSVCCompiler
- if not isinstance(self.compiler_obj, MSVCCompiler):
+ if not isinstance(self.compiler, MSVCCompiler):
template = "python%d%d"
if self.debug:
template = template + '_d'
@@ -783,13 +734,14 @@
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]
elif sys.platform[:6] == "atheos":
- _sysconfig = __import__('sysconfig')
+ from distutils import sysconfig
+
template = "python%d.%d"
pythonlib = (template %
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
# Get SHLIBS from Makefile
extra = []
- for lib in _sysconfig.get_config_var('SHLIBS').split():
+ for lib in sysconfig.get_config_var('SHLIBS').split():
if lib.startswith('-l'):
extra.append(lib[2:])
else:
@@ -803,11 +755,13 @@
return ext.libraries
else:
- _sysconfig = __import__('sysconfig')
- if _sysconfig.get_config_var('Py_ENABLE_SHARED'):
+ from distutils import sysconfig
+ if sysconfig.get_config_var('Py_ENABLE_SHARED'):
template = "python%d.%d"
pythonlib = (template %
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
return ext.libraries + [pythonlib]
else:
return ext.libraries
+
+# class build_ext
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index fb17b4f..44c7692 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -2,22 +2,26 @@
Implements the Distutils 'install' command."""
+from distutils import log
+
+# This module should be kept compatible with Python 2.1.
+
__revision__ = "$Id$"
-import sys
-import os
-
-from sysconfig import get_config_vars, get_paths, get_path, get_config_var
-
-from distutils import log
+import sys, os, string
+from types import *
from distutils.core import Command
from distutils.debug import DEBUG
+from distutils.sysconfig import get_config_vars
from distutils.errors import DistutilsPlatformError
from distutils.file_util import write_file
-from distutils.util import convert_path, change_root, get_platform
+from distutils.util import convert_path, subst_vars, change_root
+from distutils.util import get_platform
from distutils.errors import DistutilsOptionError
+from site import USER_BASE
+from site import USER_SITE
-# kept for backward compat, will be removed in 3.2
+
if sys.version < "2.2":
WINDOWS_SCHEME = {
'purelib': '$base',
@@ -95,19 +99,13 @@
},
}
+# The keys to an installation scheme; if any new types of files are to be
+# installed, be sure to add an entry to every installation scheme above,
+# and to SCHEME_KEYS here.
SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
-# end of backward compat
-def _subst_vars(s, local_vars):
- try:
- return s.format(**local_vars)
- except KeyError:
- try:
- return s.format(**os.environ)
- except KeyError, var:
- raise AttributeError('{%s}' % var)
-class install(Command):
+class install (Command):
description = "install everything from build directory"
@@ -119,6 +117,8 @@
"(Unix only) prefix for platform-specific files"),
('home=', None,
"(Unix only) home directory to install under"),
+ ('user', None,
+ "install in user site-package '%s'" % USER_SITE),
# Or, just set the base director(y|ies)
('install-base=', None,
@@ -170,17 +170,12 @@
"filename in which to record list of installed files"),
]
- boolean_options = ['compile', 'force', 'skip-build']
-
- user_options.append(('user', None,
- "install in user site-package '%s'" % \
- get_path('purelib', '%s_user' % os.name)))
- boolean_options.append('user')
+ boolean_options = ['compile', 'force', 'skip-build', 'user']
negative_opt = {'no-compile' : 'compile'}
- def initialize_options(self):
- """Initializes options."""
+ def initialize_options (self):
+
# High-level options: these select both an installation base
# and scheme.
self.prefix = None
@@ -205,8 +200,8 @@
self.install_lib = None # set to either purelib or platlib
self.install_scripts = None
self.install_data = None
- self.install_userbase = get_config_var('userbase')
- self.install_usersite = get_path('purelib', '%s_user' % os.name)
+ self.install_userbase = USER_BASE
+ self.install_usersite = USER_SITE
self.compile = None
self.optimize = None
@@ -256,8 +251,8 @@
# party Python modules on various platforms given a wide
# array of user input is decided. Yes, it's quite complex!)
- def finalize_options(self):
- """Finalizes options."""
+ def finalize_options (self):
+
# 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
@@ -315,10 +310,8 @@
# $platbase in the other installation directories and not worry
# about needing recursive variable expansion (shudder).
- py_version = sys.version.split()[0]
- prefix, exec_prefix, srcdir = get_config_vars('prefix', 'exec_prefix',
- 'srcdir')
-
+ py_version = (string.split(sys.version))[0]
+ (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
self.config_vars = {'dist_name': self.distribution.get_name(),
'dist_version': self.distribution.get_version(),
'dist_fullname': self.distribution.get_fullname(),
@@ -329,11 +322,9 @@
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
'exec_prefix': exec_prefix,
- 'srcdir': srcdir,
+ 'userbase': self.install_userbase,
+ 'usersite': self.install_usersite,
}
-
- self.config_vars['userbase'] = self.install_userbase
- self.config_vars['usersite'] = self.install_usersite
self.expand_basedirs()
self.dump_dirs("post-expand_basedirs()")
@@ -399,27 +390,29 @@
# Punt on doc directories for now -- after all, we're punting on
# documentation completely!
- def dump_dirs(self, msg):
- """Dumps the list of user options."""
- if not DEBUG:
- return
- from distutils.fancy_getopt import longopt_xlate
- log.debug(msg + ":")
- for opt in self.user_options:
- opt_name = opt[0]
- if opt_name[-1] == "=":
- opt_name = opt_name[0:-1]
- if opt_name in self.negative_opt:
- opt_name = self.negative_opt[opt_name]
- opt_name = opt_name.translate(longopt_xlate)
- val = not getattr(self, opt_name)
- else:
- opt_name = opt_name.translate(longopt_xlate)
- val = getattr(self, opt_name)
- log.debug(" %s: %s" % (opt_name, val))
+ # finalize_options ()
- def finalize_unix(self):
- """Finalizes options for posix platforms."""
+
+ def dump_dirs (self, msg):
+ if DEBUG:
+ from distutils.fancy_getopt import longopt_xlate
+ print msg + ":"
+ for opt in self.user_options:
+ opt_name = opt[0]
+ if opt_name[-1] == "=":
+ opt_name = opt_name[0:-1]
+ if opt_name in self.negative_opt:
+ opt_name = string.translate(self.negative_opt[opt_name],
+ longopt_xlate)
+ val = not getattr(self, opt_name)
+ else:
+ opt_name = string.translate(opt_name, longopt_xlate)
+ val = getattr(self, opt_name)
+ print " %s: %s" % (opt_name, val)
+
+
+ def finalize_unix (self):
+
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
@@ -437,10 +430,10 @@
raise DistutilsPlatformError(
"User base directory is not specified")
self.install_base = self.install_platbase = self.install_userbase
- self.select_scheme("posix_user")
+ self.select_scheme("unix_user")
elif self.home is not None:
self.install_base = self.install_platbase = self.home
- self.select_scheme("posix_home")
+ self.select_scheme("unix_home")
else:
if self.prefix is None:
if self.exec_prefix is not None:
@@ -456,10 +449,13 @@
self.install_base = self.prefix
self.install_platbase = self.exec_prefix
- self.select_scheme("posix_prefix")
+ self.select_scheme("unix_prefix")
- def finalize_other(self):
- """Finalizes options for non-posix platforms"""
+ # finalize_unix ()
+
+
+ def finalize_other (self): # Windows and Mac OS for now
+
if self.user:
if self.install_userbase is None:
raise DistutilsPlatformError(
@@ -468,7 +464,7 @@
self.select_scheme(os.name + "_user")
elif self.home is not None:
self.install_base = self.install_platbase = self.home
- self.select_scheme("posix_home")
+ self.select_scheme("unix_home")
else:
if self.prefix is None:
self.prefix = os.path.normpath(sys.prefix)
@@ -480,58 +476,61 @@
raise DistutilsPlatformError, \
"I don't know how to install stuff on '%s'" % os.name
- def select_scheme(self, name):
- """Sets 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():
- if key == 'platinclude':
- key = 'headers'
- value = os.path.join(value, self.distribution.get_name())
- attrname = 'install_' + key
- if hasattr(self, attrname):
- if getattr(self, attrname) is None:
- setattr(self, attrname, value)
+ # finalize_other ()
- def _expand_attrs(self, attrs):
+
+ def select_scheme (self, name):
+ # it's the caller's problem if they supply a bad name!
+ scheme = INSTALL_SCHEMES[name]
+ for key in SCHEME_KEYS:
+ attrname = 'install_' + key
+ if getattr(self, attrname) is None:
+ setattr(self, attrname, scheme[key])
+
+
+ def _expand_attrs (self, attrs):
for attr in attrs:
val = getattr(self, attr)
if val is not None:
if os.name == 'posix' or os.name == 'nt':
val = os.path.expanduser(val)
- val = _subst_vars(val, self.config_vars)
+ val = subst_vars(val, self.config_vars)
setattr(self, attr, val)
- def expand_basedirs(self):
- """Calls `os.path.expanduser` on install_base, install_platbase and
- root."""
- self._expand_attrs(['install_base', 'install_platbase', 'root'])
- def expand_dirs(self):
- """Calls `os.path.expanduser` on install dirs."""
- self._expand_attrs(['install_purelib', 'install_platlib',
- 'install_lib', 'install_headers',
- 'install_scripts', 'install_data',])
+ def expand_basedirs (self):
+ self._expand_attrs(['install_base',
+ 'install_platbase',
+ 'root'])
- def convert_paths(self, *names):
- """Call `convert_path` over `names`."""
+ def expand_dirs (self):
+ self._expand_attrs(['install_purelib',
+ 'install_platlib',
+ 'install_lib',
+ 'install_headers',
+ 'install_scripts',
+ 'install_data',])
+
+
+ def convert_paths (self, *names):
for name in names:
attr = "install_" + name
setattr(self, attr, convert_path(getattr(self, attr)))
- def handle_extra_path(self):
- """Set `path_file` and `extra_dirs` using `extra_path`."""
+
+ def handle_extra_path (self):
+
if self.extra_path is None:
self.extra_path = self.distribution.extra_path
if self.extra_path is not None:
- if isinstance(self.extra_path, str):
- self.extra_path = self.extra_path.split(',')
+ if type(self.extra_path) is StringType:
+ self.extra_path = string.split(self.extra_path, ',')
if len(self.extra_path) == 1:
path_file = extra_dirs = self.extra_path[0]
elif len(self.extra_path) == 2:
- path_file, extra_dirs = self.extra_path
+ (path_file, extra_dirs) = self.extra_path
else:
raise DistutilsOptionError, \
("'extra_path' option must be a list, tuple, or "
@@ -540,6 +539,7 @@
# convert to local form in case Unix notation used (as it
# should be in setup scripts)
extra_dirs = convert_path(extra_dirs)
+
else:
path_file = None
extra_dirs = ''
@@ -549,14 +549,17 @@
self.path_file = path_file
self.extra_dirs = extra_dirs
- def change_roots(self, *names):
- """Change the install direcories pointed by name using root."""
+ # handle_extra_path ()
+
+
+ def change_roots (self, *names):
for name in names:
attr = "install_" + name
setattr(self, attr, change_root(self.root, getattr(self, attr)))
def create_home_path(self):
- """Create directories under ~."""
+ """Create directories under ~
+ """
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
@@ -567,8 +570,8 @@
# -- Command execution methods -------------------------------------
- def run(self):
- """Runs the command."""
+ def run (self):
+
# Obviously have to build before we can install
if not self.skip_build:
self.run_command('build')
@@ -611,8 +614,9 @@
"you'll have to change the search path yourself"),
self.install_lib)
- def create_path_file(self):
- """Creates the .pth file"""
+ # run ()
+
+ def create_path_file (self):
filename = os.path.join(self.install_libbase,
self.path_file + ".pth")
if self.install_path_file:
@@ -625,8 +629,8 @@
# -- Reporting methods ---------------------------------------------
- def get_outputs(self):
- """Assembles the outputs of all the sub-commands."""
+ def get_outputs (self):
+ # Assemble the outputs of all the sub-commands.
outputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
@@ -642,8 +646,7 @@
return outputs
- def get_inputs(self):
- """Returns the inputs of all the sub-commands"""
+ def get_inputs (self):
# XXX gee, this looks familiar ;-(
inputs = []
for cmd_name in self.get_sub_commands():
@@ -652,29 +655,25 @@
return inputs
+
# -- Predicates for sub-command list -------------------------------
- def has_lib(self):
- """Returns true if the current distribution has any Python
+ def has_lib (self):
+ """Return true if the current distribution has any Python
modules to install."""
return (self.distribution.has_pure_modules() or
self.distribution.has_ext_modules())
- def has_headers(self):
- """Returns true if the current distribution has any headers to
- install."""
+ def has_headers (self):
return self.distribution.has_headers()
- def has_scripts(self):
- """Returns true if the current distribution has any scripts to.
- install."""
+ def has_scripts (self):
return self.distribution.has_scripts()
- def has_data(self):
- """Returns true if the current distribution has any data to.
- install."""
+ def has_data (self):
return self.distribution.has_data_files()
+
# '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),
@@ -683,3 +682,5 @@
('install_data', has_data),
('install_egg_info', lambda self:True),
]
+
+# class install