[Distutils] Distutils patch for Python 1.5.1 compatibility

Greg Ward gward@cnri.reston.va.us
Wed, 23 Feb 2000 09:50:01 -0500


--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii

Hi all --

I've gotten enough bug reports about Distutils not working with Python
1.5.1 to finally do something about it.  The result is the attached
patch.  Please give it a try, *especially* if you use Python 1.5.1 (or
older, I suppose).  If this works, I'll release it as Distutils 0.1.4 so
the NumPy and PyFort people can get their jobs done without stumbling
across my bugs.

Oh yeah, you can apply the patch either in the Distutils source tree
(right in Distutils-0.1.3, wherever you put it) or to the installed
version, from the "site-packages" directory.  In either case, apply it
with "patch -p1".  Eg. if Distutils is in the normal Unix
"site-packages", and the patch is in /tmp/distutils-apply.patch, you can
patch the installed version of Distutils with:

    cd /usr/local/lib/python1.5/site-packages
    patch -p1 < /tmp/distutils-apply.patch

And then try building and installing NumPy, or PIL (using the setup
script included with Distutils, that is), or something generated by
PyFort -- whatever.  Please let me know how it goes!

Thanks --

        Greg

--J2SCkAp4GZ/dPZZf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="distutils-apply.patch"

diff -cr ../Distutils-0.1.3/distutils/command/build_ext.py ./distutils/command/build_ext.py
*** ../Distutils-0.1.3/distutils/command/build_ext.py	Sun Jan 30 13:34:12 2000
--- ./distutils/command/build_ext.py	Tue Feb 22 12:35:18 2000
***************
*** 254,259 ****
          if package:
              ext_name = package + '.' + ext_name
          ext_path = string.split (ext_name, '.')
!         return apply (os.path.join, ext_path) + sysconfig.SO
  
  # class BuildExt
--- 254,259 ----
          if package:
              ext_name = package + '.' + ext_name
          ext_path = string.split (ext_name, '.')
!         return apply (os.path.join, tuple (ext_path)) + sysconfig.SO
  
  # class BuildExt
diff -cr ../Distutils-0.1.3/distutils/command/build_py.py ./distutils/command/build_py.py
*** ../Distutils-0.1.3/distutils/command/build_py.py	Sun Jan 30 13:34:13 2000
--- ./distutils/command/build_py.py	Tue Feb 22 12:35:18 2000
***************
*** 102,118 ****
  
          if type (package) is StringType:
              path = string.split (package, '.')
!         elif type (package) in (TupleType, ListType):
!             path = list (package)
!         else:
              raise TypeError, "'package' must be a string, list, or tuple"
  
          if not self.package_dir:
              if path:
!                 return apply (os.path.join, path)
              else:
                  return ''
          else:
              tail = []
              while path:
                  try:
--- 102,119 ----
  
          if type (package) is StringType:
              path = string.split (package, '.')
!         elif type (package) not in (TupleType, ListType):
              raise TypeError, "'package' must be a string, list, or tuple"
  
          if not self.package_dir:
              if path:
!                 return apply (os.path.join, tuple (path))
              else:
                  return ''
          else:
+             if type (path) is not ListType: # must be mutable!
+                 path = list (path) 
+ 
              tail = []
              while path:
                  try:
***************
*** 122,133 ****
                      del path[-1]
                  else:
                      tail.insert (0, pdir)
!                     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)
                  else:
                      return ''
  
--- 123,134 ----
                      del path[-1]
                  else:
                      tail.insert (0, pdir)
!                     return apply (os.path.join, tuple (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, tuple (tail))
                  else:
                      return ''
  
***************
*** 263,269 ****
          outfile_path = list (package)
          outfile_path.append (module + ".py")
          outfile_path.insert (0, self.build_dir)
!         outfile = apply (os.path.join, outfile_path)
  
          dir = os.path.dirname (outfile)
          self.mkpath (dir)
--- 264,270 ----
          outfile_path = list (package)
          outfile_path.append (module + ".py")
          outfile_path.insert (0, self.build_dir)
!         outfile = apply (os.path.join, tuple (outfile_path))
  
          dir = os.path.dirname (outfile)
          self.mkpath (dir)
diff -cr ../Distutils-0.1.3/distutils/command/dist.py ./distutils/command/dist.py
*** ../Distutils-0.1.3/distutils/command/dist.py	Sun Jan 30 15:22:27 2000
--- ./distutils/command/dist.py	Tue Feb 22 12:34:37 2000
***************
*** 346,352 ****
              words = string.split (pattern)
              assert words                # must have something!
              if os.name != 'posix':
!                 words[0] = apply (os.path.join, string.split (words[0], '/'))
  
              # First word is a directory, possibly with include/exclude
              # patterns making up the rest of the line: it's a recursive
--- 346,353 ----
              words = string.split (pattern)
              assert words                # must have something!
              if os.name != 'posix':
!                 words[0] = apply (os.path.join,
!                                   tuple (string.split (words[0], '/')))
  
              # First word is a directory, possibly with include/exclude
              # patterns making up the rest of the line: it's a recursive
diff -cr ../Distutils-0.1.3/distutils/command/install.py ./distutils/command/install.py
*** ../Distutils-0.1.3/distutils/command/install.py	Sun Jan 30 13:34:14 2000
--- ./distutils/command/install.py	Tue Feb 22 12:35:15 2000
***************
*** 202,208 ****
              # local form
              if string.find (extra_dirs, '/') and os.name != "posix":
                  extra_dirs = string.split (extra_dirs, '/')
!                 extra_dirs = apply (os.path.join, extra_dirs)
          else:
              path_file = None
              extra_dirs = ''
--- 202,208 ----
              # local form
              if string.find (extra_dirs, '/') and os.name != "posix":
                  extra_dirs = string.split (extra_dirs, '/')
!                 extra_dirs = apply (os.path.join, tuple (extra_dirs))
          else:
              path_file = None
              extra_dirs = ''
diff -cr ../Distutils-0.1.3/distutils/core.py ./distutils/core.py
*** ../Distutils-0.1.3/distutils/core.py	Sun Jan 30 13:30:32 2000
--- ./distutils/core.py	Tue Feb 22 12:38:15 2000
***************
*** 904,909 ****
--- 904,912 ----
             a message to print if the verbosity level is high enough, and an
             optional verbosity threshold."""
  
+         if type (args) is not TupleType:
+             raise TypeError, "'args' must be a tuple of command arguments"
+ 
          # Generate a message if we weren't passed one
          if msg is None:
              msg = "%s %s" % (func.__name__, `args`)
diff -cr ../Distutils-0.1.3/distutils/util.py ./distutils/util.py
*** ../Distutils-0.1.3/distutils/util.py	Sun Jan 30 14:57:48 2000
--- ./distutils/util.py	Tue Feb 22 12:38:38 2000
***************
*** 170,175 ****
--- 170,178 ----
         'args', but only if it needs to: i.e. if 'dst' does not exist or
         'src' is newer than 'dst'."""
  
+     if type (args) is not TupleType:
+         raise TypeError, "'args' must be a tuple of command arguments"
+ 
      if newer (src, dst):
          if verbose and update_message:
              print update_message

--J2SCkAp4GZ/dPZZf--