mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
OS/2 patches by Andrew I MacIntyre for distutils.
Closes patch #435381.
This commit is contained in:
parent
c318260a71
commit
2544f51036
8 changed files with 108 additions and 4 deletions
|
@ -38,6 +38,8 @@ def spawn (cmd,
|
|||
_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 @@ def _spawn_nt (cmd,
|
|||
"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 @@ def find_executable(executable, path=None):
|
|||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue