[Python-checkins] CVS: distutils/distutils/command install.py,1.46,1.47

Greg Ward python-dev@python.org
Thu, 21 Sep 2000 18:31:11 -0700


Update of /cvsroot/python/distutils/distutils/command
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17565/distutils/command

Modified Files:
	install.py 
Log Message:
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.


Index: install.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/install.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** install.py	2000/09/16 15:06:57	1.46
--- install.py	2000/09/22 01:31:08	1.47
***************
*** 34,51 ****
          'purelib': '$base',
          'platlib': '$base',
!         'headers': '$base\\Include\\$dist_name',
!         'scripts': '$base\\Scripts',
          'data'   : '$base',
          },
      'mac': {
!         'purelib': '$base:Lib:site-packages',
!         'platlib': '$base:Lib:site-packages',
!         'headers': '$base:Include:$dist_name',
!         'scripts': '$base:Scripts',
          'data'   : '$base',
          }
      }
  
  
  class install (Command):
  
--- 34,56 ----
          'purelib': '$base',
          'platlib': '$base',
!         'headers': '$base/Include/$dist_name',
!         'scripts': '$base/Scripts',
          'data'   : '$base',
          },
      'mac': {
!         'purelib': '$base/Lib/site-packages',
!         'platlib': '$base/Lib/site-packages',
!         'headers': '$base/Include/$dist_name',
!         'scripts': '$base/Scripts',
          '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):
  
***************
*** 131,142 ****
          # These two are for putting non-packagized distributions into their
          # own directory and creating a .pth file if it makes sense.
!         # 'extra_path' comes from the setup file; 'install_path_file' is
!         # set only if we determine that it makes sense to install a path
!         # file.
          self.extra_path = None
!         self.install_path_file = 0
  
          self.force = 0
          self.skip_build = 0
  
          # These are only here as a conduit from the 'build' command to the
--- 136,157 ----
          # These two are for putting non-packagized distributions into their
          # own directory and creating a .pth file if it makes sense.
!         # 'extra_path' comes from the setup file; 'install_path_file' can
!         # be turned off if it makes no sense to install a .pth file.  (But
!         # 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.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.skip_build = 0
+         self.warn_dir = 1
  
          # These are only here as a conduit from the 'build' command to the
***************
*** 257,260 ****
--- 272,281 ----
                  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
          # have to deal with 'extra_path', which is the hack for allowing
***************
*** 268,276 ****
          # dirs relative to it.
          if self.root is not None:
!             for name in ('libbase', 'lib', 'purelib', 'platlib',
!                          '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")
--- 289,294 ----
          # dirs relative to it.
          if self.root is not None:
!             self.change_roots('libbase', 'lib', 'purelib', 'platlib',
!                               'scripts', 'data', 'headers')
  
          self.dump_dirs ("after prepending root")
***************
*** 325,329 ****
                  self.prefix = os.path.normpath (sys.prefix)
                  self.exec_prefix = os.path.normpath (sys.exec_prefix)
-                 self.install_path_file = 1
  
              else:
--- 343,346 ----
***************
*** 331,344 ****
                      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_platbase = self.exec_prefix
--- 348,351 ----
***************
*** 352,360 ****
          if self.prefix is None:
              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
          try:
--- 359,363 ----
***************
*** 370,374 ****
          # it's the caller's problem if they supply a bad name!
          scheme = INSTALL_SCHEMES[name]
!         for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
              attrname = 'install_' + key
              if getattr(self, attrname) is None:
--- 373,377 ----
          # 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:
***************
*** 400,403 ****
--- 403,412 ----
  
  
+     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):
  
***************
*** 434,437 ****
--- 443,452 ----
  
  
+     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):
  
***************
*** 459,469 ****
                           self.record)
  
!         normalized_path = map (os.path.normpath, sys.path)
!         if (not (self.path_file and self.install_path_file) and
!             os.path.normpath (self.install_lib) not in normalized_path):
!             self.warn (("modules installed to '%s', which is not in " +
!                         "Python's module search path (sys.path) -- " +
!                         "you'll have to change the search path yourself") %
!                        self.install_lib)
  
      # run ()
--- 474,485 ----
                           self.record)
  
!         normalized_path = map(os.path.normpath, sys.path)
!         if (self.warn_dir and
!             not (self.path_file and self.install_path_file) and
!             os.path.normpath(self.install_lib) not in normalized_path):
!             self.warn(("modules installed to '%s', which is not in " +
!                        "Python's module search path (sys.path) -- " +
!                        "you'll have to change the search path yourself") %
!                       self.install_lib)
  
      # run ()
***************
*** 517,524 ****
                            "creating %s" % filename)
          else:
!             self.warn (("path file '%s' not created for alternate or custom " +
!                         "installation (path files only work with standard " +
!                         "installations)") %
!                        filename)
  
      # 'sub_commands': a list of commands this command might have to run to
--- 533,537 ----
                            "creating %s" % filename)
          else:
!             self.warn("path file '%s' not created" % filename)
  
      # 'sub_commands': a list of commands this command might have to run to