OS/2 patches by Andrew I MacIntyre for distutils.

Closes patch #435381.
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 07dc814..5b6016e 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -38,6 +38,8 @@
         _spawn_posix(cmd, search_path, verbose, dry_run)
     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, \
               "don't know how to spawn programs on platform '%s'" % os.name
@@ -88,6 +90,33 @@
                   "command '%s' failed with exit status %d" % (cmd[0], rc)
 
 
+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,
                   verbose=0,
@@ -154,7 +183,7 @@
         path = os.environ['PATH']
     paths = string.split(path, os.pathsep)
     (base, ext) = os.path.splitext(executable)
-    if (sys.platform == 'win32') and (ext != '.exe'):
+    if (sys.platform == 'win32' or os.name == 'os2') and (ext != '.exe'):
         executable = executable + '.exe'
     if not os.path.isfile(executable):
         for p in paths: