[Python-checkins] CVS: python/dist/src/Lib/distutils ccompiler.py,1.41,1.42 spawn.py,1.11,1.12 sysconfig.py,1.44,1.45 util.py,1.65,1.66

M.-A. Lemburg lemburg@users.sourceforge.net
Thu, 31 Jan 2002 10:56:31 -0800


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory usw-pr-cvs1:/tmp/cvs-serv11495/Lib/distutils

Modified Files:
	ccompiler.py spawn.py sysconfig.py util.py 
Log Message:
OS/2 patches by Andrew I MacIntyre for distutils.

Closes patch #435381.



Index: ccompiler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -C2 -d -r1.41 -r1.42
*** ccompiler.py	2001/12/06 20:51:35	1.41
--- ccompiler.py	2002/01/31 18:55:31	1.42
***************
*** 847,850 ****
--- 847,851 ----
      # compiler
      ('cygwin.*', 'unix'),
+     ('os2emx', 'emx'),
  
      # OS name mappings
***************
*** 893,896 ****
--- 894,899 ----
                     'mwerks':  ('mwerkscompiler', 'MWerksCompiler',
                                 "MetroWerks CodeWarrior"),
+                    'emx':     ('emxccompiler', 'EMXCCompiler',
+                                "EMX port of GNU C Compiler for OS/2"),
                   }
  

Index: spawn.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/spawn.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** spawn.py	2001/12/06 20:51:35	1.11
--- spawn.py	2002/01/31 18:55:32	1.12
***************
*** 39,42 ****
--- 39,44 ----
      elif os.name == 'nt':
          _spawn_nt(cmd, search_path, verbose, dry_run)
+     elif os.name == 'os2':
+         _spawn_os2(cmd, search_path, verbose, dry_run)
      else:
          raise DistutilsPlatformError, \
***************
*** 89,92 ****
--- 91,121 ----
  
  
+ def _spawn_os2 (cmd,
+                 search_path=1,
+                 verbose=0,
+                 dry_run=0):
+ 
+     executable = cmd[0]
+     #cmd = _nt_quote_args(cmd)
+     if search_path:
+         # either we find one or it stays the same
+         executable = find_executable(executable) or executable 
+     if verbose:
+         print string.join([executable] + cmd[1:], ' ')
+     if not dry_run:
+         # spawnv for OS/2 EMX requires a full path to the .exe
+         try:
+             rc = os.spawnv(os.P_WAIT, executable, cmd)
+         except OSError, exc:
+             # this seems to happen when the command isn't found
+             raise DistutilsExecError, \
+                   "command '%s' failed: %s" % (cmd[0], exc[-1])
+         if rc != 0:
+             # and this reflects the command running but failing
+             print "command '%s' failed with exit status %d" % (cmd[0], rc)
+             raise DistutilsExecError, \
+                   "command '%s' failed with exit status %d" % (cmd[0], rc)
+ 
+ 
  def _spawn_posix (cmd,
                    search_path=1,
***************
*** 155,159 ****
      paths = string.split(path, os.pathsep)
      (base, ext) = os.path.splitext(executable)
!     if (sys.platform == 'win32') and (ext != '.exe'):
          executable = executable + '.exe'
      if not os.path.isfile(executable):
--- 184,188 ----
      paths = string.split(path, os.pathsep)
      (base, ext) = os.path.splitext(executable)
!     if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
          executable = executable + '.exe'
      if not os.path.isfile(executable):

Index: sysconfig.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -d -r1.44 -r1.45
*** sysconfig.py	2001/12/06 20:51:35	1.44
--- sysconfig.py	2002/01/31 18:55:33	1.45
***************
*** 60,63 ****
--- 60,65 ----
      elif os.name == "mac":
          return os.path.join(prefix, "Include")
+     elif os.name == "os2":
+         return os.path.join(prefix, "Include")
      else:
          raise DistutilsPlatformError(
***************
*** 111,114 ****
--- 113,123 ----
              else:
                  return os.path.join(prefix, "Lib", "site-packages")
+ 
+     elif os.name == "os2":
+         if standard_lib:
+             return os.path.join(PREFIX, "Lib")
+         else:
+             return os.path.join(PREFIX, "Lib", "site-packages")
+ 
      else:
          raise DistutilsPlatformError(
***************
*** 387,390 ****
--- 396,416 ----
      g['install_lib'] = os.path.join(EXEC_PREFIX, "Lib")
      g['install_platlib'] = os.path.join(EXEC_PREFIX, "Mac", "Lib")
+ 
+     global _config_vars
+     _config_vars = g
+ 
+ 
+ def _init_os2():
+     """Initialize the module as appropriate for OS/2"""
+     g = {}
+     # set basic install directories
+     g['LIBDEST'] = get_python_lib(plat_specific=0, standard_lib=1)
+     g['BINLIBDEST'] = get_python_lib(plat_specific=1, standard_lib=1)
+ 
+     # XXX hmmm.. a normal install puts include files here
+     g['INCLUDEPY'] = get_python_inc(plat_specific=0)
+ 
+     g['SO'] = '.pyd'
+     g['EXE'] = ".exe"
  
      global _config_vars

Index: util.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** util.py	2001/12/06 20:51:35	1.65
--- util.py	2002/01/31 18:55:48	1.66
***************
*** 118,121 ****
--- 118,127 ----
          return os.path.join(new_root, path)
  
+     elif os.name == 'os2':
+         (drive, path) = os.path.splitdrive(pathname)
+         if path[0] == os.sep:
+             path = path[1:]
+         return os.path.join(new_root, path)
+ 
      elif os.name == 'mac':
          if not os.path.isabs(pathname):