mirror of https://github.com/python/cpython
Added the "--root" option as a sort of meta-install-base; if supplied,
it is forcibly prepended onto all installation directories, even if they are already absolute. Added 'dump_dirs()' to clean up the debug output a bit.
This commit is contained in:
parent
67f75d4bcb
commit
6a647bb910
|
@ -10,7 +10,7 @@ import sys, os, string
|
||||||
from types import *
|
from types import *
|
||||||
from distutils.core import Command
|
from distutils.core import Command
|
||||||
from distutils import sysconfig
|
from distutils import sysconfig
|
||||||
from distutils.util import write_file, native_path, subst_vars
|
from distutils.util import write_file, native_path, subst_vars, change_root
|
||||||
from distutils.errors import DistutilsOptionError
|
from distutils.errors import DistutilsOptionError
|
||||||
|
|
||||||
INSTALL_SCHEMES = {
|
INSTALL_SCHEMES = {
|
||||||
|
@ -60,6 +60,8 @@ class install (Command):
|
||||||
('install-platbase=', None,
|
('install-platbase=', None,
|
||||||
"base installation directory for platform-specific files " +
|
"base installation directory for platform-specific files " +
|
||||||
"(instead of --exec-prefix or --home)"),
|
"(instead of --exec-prefix or --home)"),
|
||||||
|
('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,
|
('install-purelib=', None,
|
||||||
|
@ -104,6 +106,7 @@ class install (Command):
|
||||||
# the --install-{platlib,purelib,scripts,data} options).
|
# the --install-{platlib,purelib,scripts,data} options).
|
||||||
self.install_base = None
|
self.install_base = None
|
||||||
self.install_platbase = None
|
self.install_platbase = None
|
||||||
|
self.root = None
|
||||||
|
|
||||||
# These options are the actual installation directories; if not
|
# These options are the actual installation directories; if not
|
||||||
# supplied by the user, they are filled in using the installation
|
# supplied by the user, they are filled in using the installation
|
||||||
|
@ -183,17 +186,14 @@ class install (Command):
|
||||||
# install_{purelib,platlib,lib,scripts,data,...}, and the
|
# install_{purelib,platlib,lib,scripts,data,...}, and the
|
||||||
# INSTALL_SCHEME dictionary above. Phew!
|
# INSTALL_SCHEME dictionary above. Phew!
|
||||||
|
|
||||||
from pprint import pprint
|
self.dump_dirs ("pre-finalize_xxx")
|
||||||
print "pre-finalize:"
|
|
||||||
pprint (self.__dict__)
|
|
||||||
|
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
self.finalize_unix ()
|
self.finalize_unix ()
|
||||||
else:
|
else:
|
||||||
self.finalize_other ()
|
self.finalize_other ()
|
||||||
|
|
||||||
print "post-finalize:"
|
self.dump_dirs ("post-finalize_xxx()")
|
||||||
pprint (self.__dict__)
|
|
||||||
|
|
||||||
# Expand configuration variables, tilde, etc. in self.install_base
|
# Expand configuration variables, tilde, etc. in self.install_base
|
||||||
# and self.install_platbase -- that way, we can use $base or
|
# and self.install_platbase -- that way, we can use $base or
|
||||||
|
@ -206,14 +206,14 @@ class install (Command):
|
||||||
}
|
}
|
||||||
self.expand_basedirs ()
|
self.expand_basedirs ()
|
||||||
|
|
||||||
print "post-expand_basedirs:"
|
self.dump_dirs ("post-expand_basedirs()")
|
||||||
pprint (self.__dict__)
|
|
||||||
|
|
||||||
# Now define config vars for the base directories so we can expand
|
# Now define config vars for the base directories so we can expand
|
||||||
# everything else.
|
# everything else.
|
||||||
self.config_vars['base'] = self.install_base
|
self.config_vars['base'] = self.install_base
|
||||||
self.config_vars['platbase'] = self.install_platbase
|
self.config_vars['platbase'] = self.install_platbase
|
||||||
|
|
||||||
|
from pprint import pprint
|
||||||
print "config vars:"
|
print "config vars:"
|
||||||
pprint (self.config_vars)
|
pprint (self.config_vars)
|
||||||
|
|
||||||
|
@ -221,8 +221,7 @@ class install (Command):
|
||||||
# directories.
|
# directories.
|
||||||
self.expand_dirs ()
|
self.expand_dirs ()
|
||||||
|
|
||||||
print "post-expand:"
|
self.dump_dirs ("post-expand_dirs()")
|
||||||
pprint (self.__dict__)
|
|
||||||
|
|
||||||
# Pick the actual directory to install all modules to: either
|
# Pick the actual directory to install all modules to: either
|
||||||
# install_purelib or install_platlib, depending on whether this
|
# install_purelib or install_platlib, depending on whether this
|
||||||
|
@ -242,6 +241,16 @@ class install (Command):
|
||||||
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)
|
self.install_lib = os.path.join (self.install_lib, self.extra_dirs)
|
||||||
|
|
||||||
|
# If a new root directory was supplied, make all the installation
|
||||||
|
# dirs relative to it.
|
||||||
|
if self.root is not None:
|
||||||
|
for name in ('lib', 'purelib', 'platlib', 'scripts', 'data'):
|
||||||
|
attr = "install_" + name
|
||||||
|
new_val = change_root (self.root, getattr (self, attr))
|
||||||
|
setattr (self, attr, new_val)
|
||||||
|
|
||||||
|
self.dump_dirs ("after prepending root")
|
||||||
|
|
||||||
# Find out the build directories, ie. where to install from.
|
# Find out the build directories, ie. where to install from.
|
||||||
self.set_undefined_options ('build',
|
self.set_undefined_options ('build',
|
||||||
('build_base', 'build_base'),
|
('build_base', 'build_base'),
|
||||||
|
@ -253,6 +262,16 @@ class install (Command):
|
||||||
# finalize_options ()
|
# finalize_options ()
|
||||||
|
|
||||||
|
|
||||||
|
# hack for debugging output
|
||||||
|
def dump_dirs (self, msg):
|
||||||
|
from distutils.fancy_getopt import longopt_xlate
|
||||||
|
print msg + ":"
|
||||||
|
for opt in self.user_options:
|
||||||
|
opt_name = string.translate (opt[0][0:-1], longopt_xlate)
|
||||||
|
val = getattr (self, opt_name)
|
||||||
|
print " %s: %s" % (opt_name, val)
|
||||||
|
|
||||||
|
|
||||||
def finalize_unix (self):
|
def finalize_unix (self):
|
||||||
|
|
||||||
if self.install_base is not None or self.install_platbase is not None:
|
if self.install_base is not None or self.install_platbase is not None:
|
||||||
|
@ -339,7 +358,8 @@ class install (Command):
|
||||||
|
|
||||||
def expand_basedirs (self):
|
def expand_basedirs (self):
|
||||||
self._expand_attrs (['install_base',
|
self._expand_attrs (['install_base',
|
||||||
'install_platbase'])
|
'install_platbase',
|
||||||
|
'root'])
|
||||||
|
|
||||||
def expand_dirs (self):
|
def expand_dirs (self):
|
||||||
self._expand_attrs (['install_purelib',
|
self._expand_attrs (['install_purelib',
|
||||||
|
|
Loading…
Reference in New Issue