Kaydet (Commit) 379a02ff authored tarafından Greg Ward's avatar Greg Ward

Changed all paths in the INSTALL_SCHEMES dict to Unix syntax, and added

'convert_paths()' method to convert them all to the local syntax (backslash
or colon or whatever) at the appropriate time.

Added SCHEME_KEYS to get rid of one hard-coded list of attributes (in
'select_scheme()').

Default 'install_path_file' to true, and never set it false (it's just
there in case some outsider somewhere wants to disable installation of the
.pth file for whatever reason).

Toned down the warning emitted when 'install_path_file' is false, since we
no longer know why it might be false.

Added 'warn_dir' flag to suppress warning when installing to a directory
not in sys.path (again, we never set this false -- it's there for outsiders
to use, specifically the "bdist_*" commands).

Pulled the loop of 'change_root()' calls out to new method 'change_roots()'.

Comment updates/deletions/additions.
üst 7ec05354
...@@ -33,19 +33,24 @@ INSTALL_SCHEMES = { ...@@ -33,19 +33,24 @@ INSTALL_SCHEMES = {
'nt': { 'nt': {
'purelib': '$base', 'purelib': '$base',
'platlib': '$base', 'platlib': '$base',
'headers': '$base\\Include\\$dist_name', 'headers': '$base/Include/$dist_name',
'scripts': '$base\\Scripts', 'scripts': '$base/Scripts',
'data' : '$base', 'data' : '$base',
}, },
'mac': { 'mac': {
'purelib': '$base:Lib:site-packages', 'purelib': '$base/Lib/site-packages',
'platlib': '$base:Lib:site-packages', 'platlib': '$base/Lib/site-packages',
'headers': '$base:Include:$dist_name', 'headers': '$base/Include/$dist_name',
'scripts': '$base:Scripts', 'scripts': '$base/Scripts',
'data' : '$base', 'data' : '$base',
} }
} }
# 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')
class install (Command): class install (Command):
...@@ -130,14 +135,24 @@ class install (Command): ...@@ -130,14 +135,24 @@ class install (Command):
# These two are for putting non-packagized distributions into their # These two are for putting non-packagized distributions into their
# own directory and creating a .pth file if it makes sense. # own directory and creating a .pth file if it makes sense.
# 'extra_path' comes from the setup file; 'install_path_file' is # 'extra_path' comes from the setup file; 'install_path_file' can
# set only if we determine that it makes sense to install a path # be turned off if it makes no sense to install a .pth file. (But
# file. # better to install it uselessly than to guess wrong and not
# install it when it's necessary and would be used!) Currently,
# 'install_path_file' is always true unless some outsider meddles
# with it.
self.extra_path = None self.extra_path = None
self.install_path_file = 0 self.install_path_file = 1
# 'force' forces installation, even if target files are not
# out-of-date. 'skip_build' skips running the "build" command,
# handy if you know it's not necessary. 'warn_dir' (which is *not*
# a user option, it's just there so the bdist_* commands can turn
# it off) determines whether we warn about installing to a
# directory not in sys.path.
self.force = 0 self.force = 0
self.skip_build = 0 self.skip_build = 0
self.warn_dir = 1
# These are only here as a conduit from the 'build' command to the # These are only here as a conduit from the 'build' command to the
# 'install_*' commands that do the real work. ('build_base' isn't # 'install_*' commands that do the real work. ('build_base' isn't
...@@ -256,6 +271,12 @@ class install (Command): ...@@ -256,6 +271,12 @@ class install (Command):
else: else:
self.install_lib = self.install_purelib self.install_lib = self.install_purelib
# Convert directories from Unix /-separated syntax to the local
# convention.
self.convert_paths('lib', 'purelib', 'platlib',
'scripts', 'data', 'headers')
# Well, we're not actually fully completely finalized yet: we still # Well, we're not actually fully completely finalized yet: we still
# have to deal with 'extra_path', which is the hack for allowing # have to deal with 'extra_path', which is the hack for allowing
# non-packagized module distributions (hello, Numerical Python!) to # non-packagized module distributions (hello, Numerical Python!) to
...@@ -267,11 +288,8 @@ class install (Command): ...@@ -267,11 +288,8 @@ class install (Command):
# If a new root directory was supplied, make all the installation # If a new root directory was supplied, make all the installation
# dirs relative to it. # dirs relative to it.
if self.root is not None: if self.root is not None:
for name in ('libbase', 'lib', 'purelib', 'platlib', self.change_roots('libbase', 'lib', 'purelib', 'platlib',
'scripts', 'data', 'headers'): 'scripts', 'data', 'headers')
attr = "install_" + name
new_val = change_root (self.root, getattr (self, attr))
setattr (self, attr, new_val)
self.dump_dirs ("after prepending root") self.dump_dirs ("after prepending root")
...@@ -324,22 +342,11 @@ class install (Command): ...@@ -324,22 +342,11 @@ class install (Command):
self.prefix = os.path.normpath (sys.prefix) self.prefix = os.path.normpath (sys.prefix)
self.exec_prefix = os.path.normpath (sys.exec_prefix) self.exec_prefix = os.path.normpath (sys.exec_prefix)
self.install_path_file = 1
else: else:
if self.exec_prefix is None: if self.exec_prefix is None:
self.exec_prefix = self.prefix self.exec_prefix = self.prefix
# XXX since we don't *know* that a user-supplied prefix really
# points to another Python installation, we can't be sure that
# writing a .pth file there will actually work -- so we don't
# try. That is, we only set 'install_path_file' if the user
# didn't supply prefix. There are certainly circumstances
# under which we *should* install a .pth file when the user
# supplies a prefix, namely when that prefix actually points to
# another Python installation. Hmmm.
self.install_base = self.prefix self.install_base = self.prefix
self.install_platbase = self.exec_prefix self.install_platbase = self.exec_prefix
self.select_scheme ("unix_prefix") self.select_scheme ("unix_prefix")
...@@ -351,10 +358,6 @@ class install (Command): ...@@ -351,10 +358,6 @@ class install (Command):
if self.prefix is None: if self.prefix is None:
self.prefix = os.path.normpath (sys.prefix) self.prefix = os.path.normpath (sys.prefix)
self.install_path_file = 1
# XXX same caveat regarding 'install_path_file' as in
# 'finalize_unix()'.
self.install_base = self.install_platbase = self.prefix self.install_base = self.install_platbase = self.prefix
try: try:
...@@ -369,7 +372,7 @@ class install (Command): ...@@ -369,7 +372,7 @@ class install (Command):
def select_scheme (self, name): def select_scheme (self, name):
# it's the caller's problem if they supply a bad name! # it's the caller's problem if they supply a bad name!
scheme = INSTALL_SCHEMES[name] scheme = INSTALL_SCHEMES[name]
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'): for key in SCHEME_KEYS:
attrname = 'install_' + key attrname = 'install_' + key
if getattr(self, attrname) is None: if getattr(self, attrname) is None:
setattr(self, attrname, scheme[key]) setattr(self, attrname, scheme[key])
...@@ -399,6 +402,12 @@ class install (Command): ...@@ -399,6 +402,12 @@ class install (Command):
'install_data',]) '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): def handle_extra_path (self):
if self.extra_path is None: if self.extra_path is None:
...@@ -433,6 +442,12 @@ class install (Command): ...@@ -433,6 +442,12 @@ class install (Command):
# handle_extra_path () # 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 run (self): def run (self):
# Obviously have to build before we can install # Obviously have to build before we can install
...@@ -458,13 +473,14 @@ class install (Command): ...@@ -458,13 +473,14 @@ class install (Command):
"writing list of installed files to '%s'" % "writing list of installed files to '%s'" %
self.record) self.record)
normalized_path = map (os.path.normpath, sys.path) normalized_path = map(os.path.normpath, sys.path)
if (not (self.path_file and self.install_path_file) and if (self.warn_dir and
os.path.normpath (self.install_lib) not in normalized_path): not (self.path_file and self.install_path_file) and
self.warn (("modules installed to '%s', which is not in " + os.path.normpath(self.install_lib) not in normalized_path):
"Python's module search path (sys.path) -- " + self.warn(("modules installed to '%s', which is not in " +
"you'll have to change the search path yourself") % "Python's module search path (sys.path) -- " +
self.install_lib) "you'll have to change the search path yourself") %
self.install_lib)
# run () # run ()
...@@ -516,10 +532,7 @@ class install (Command): ...@@ -516,10 +532,7 @@ class install (Command):
(filename, [self.extra_dirs]), (filename, [self.extra_dirs]),
"creating %s" % filename) "creating %s" % filename)
else: else:
self.warn (("path file '%s' not created for alternate or custom " + self.warn("path file '%s' not created" % filename)
"installation (path files only work with standard " +
"installations)") %
filename)
# 'sub_commands': a list of commands this command might have to run to # 'sub_commands': a list of commands this command might have to run to
# get its work done. See cmd.py for more info. # get its work done. See cmd.py for more info.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment