[Python-checkins] CVS: distutils/distutils/command build_py.py,1.24,1.25

Greg Ward python-dev@python.org
Thu, 25 May 2000 17:44:09 -0700


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

Modified Files:
	build_py.py 
Log Message:
Fixed a couple of long-hidden bugs (amazing what you find when you
attempt to verify the bold assertions in the documentation):
  * entries for the "root package" in 'package_dir' didn't work --
    fixed by improving the fall-through code in 'get_package_dir()'
  * __init__.py files weren't installed when modules-in-packages
    were listed individually (ie. in 'py_modules' in the setup script);
    fixed by making 'check_package()' return the name of the __init__
    file if it exists, and making 'find_modules()' add an entry to
    the module list for __init__ if applicable


Index: build_py.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/command/build_py.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** build_py.py	2000/05/25 01:10:04	1.24
--- build_py.py	2000/05/26 00:44:06	1.25
***************
*** 5,9 ****
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: build_py.py,v 1.24 2000/05/25 01:10:04 gward Exp $"
  
  import sys, string, os
--- 5,9 ----
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: build_py.py,v 1.25 2000/05/26 00:44:06 gward Exp $"
  
  import sys, string, os
***************
*** 118,123 ****
                      return apply (os.path.join, tail)
              else:
!                 # arg! everything failed, we might as well have not even
!                 # looked in package_dir -- oh well
                  if tail:
                      return apply (os.path.join, tail)
--- 118,132 ----
                      return apply (os.path.join, tail)
              else:
!                 # Oops, got all the way through 'path' without finding a
!                 # match in package_dir.  If package_dir defines a directory
!                 # for the root (nameless) package, then fallback on it;
!                 # otherwise, we might as well have not consulted
!                 # package_dir at all, as we just use the directory implied
!                 # by 'tail' (which should be the same as the original value
!                 # of 'path' at this point).
!                 pdir = self.package_dir.get('')
!                 if pdir is not None:
!                     tail.insert(0, pdir)
! 
                  if tail:
                      return apply (os.path.join, tail)
***************
*** 146,152 ****
          if package:
              init_py = os.path.join (package_dir, "__init__.py")
!             if not os.path.isfile (init_py):
                  self.warn (("package init file '%s' not found " +
                              "(or not a regular file)") % init_py)
      # check_package ()
  
--- 155,168 ----
          if package:
              init_py = os.path.join (package_dir, "__init__.py")
!             if os.path.isfile (init_py):
!                 return init_py
!             else:
                  self.warn (("package init file '%s' not found " +
                              "(or not a regular file)") % init_py)
+ 
+         # Either not in a package at all (__init__.py not expected), or
+         # __init__.py doesn't exist -- so don't return the filename.
+         return
+                 
      # check_package ()
  
***************
*** 178,181 ****
--- 194,206 ----
  
      def find_modules (self):
+         """Finds individually-specified Python modules, ie. those listed by
+         module name in 'self.modules'.  Returns a list of tuples (package,
+         module_base, filename): 'package' is a tuple of the path through
+         package-space to the module; 'module_base' is the bare (no
+         packages, no dots) module name, and 'filename' is the path to the
+         ".py" file (relative to the distribution root) that implements the
+         module.
+         """
+ 
          # Map package names to tuples of useful info about the package:
          #    (package_dir, checked)
***************
*** 186,190 ****
          packages = {}
  
!         # List of (module, package, filename) tuples to return
          modules = []
  
--- 211,215 ----
          packages = {}
  
!         # List of (package, module, filename) tuples to return
          modules = []
  
***************
*** 206,211 ****
  
              if not checked:
!                 self.check_package (package, package_dir)
                  packages[package] = (package_dir, 1)
  
              # XXX perhaps we should also check for just .pyc files
--- 231,238 ----
  
              if not checked:
!                 init_py = self.check_package (package, package_dir)
                  packages[package] = (package_dir, 1)
+                 if init_py:
+                     modules.append((package, "__init__", init_py))
  
              # XXX perhaps we should also check for just .pyc files
***************
*** 216,220 ****
                  continue
  
!             modules.append ((package, module, module_file))
  
          return modules
--- 243,247 ----
                  continue
  
!             modules.append ((package, module_base, module_file))
  
          return modules