Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(127)

Side by Side Diff: Lib/distutils/spawn.py

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/distutils/core.py ('k') | Lib/distutils/sysconfig.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """distutils.spawn 1 """distutils.spawn
2 2
3 Provides the 'spawn()' function, a front-end to various platform- 3 Provides the 'spawn()' function, a front-end to various platform-
4 specific functions for launching another program in a sub-process. 4 specific functions for launching another program in a sub-process.
5 Also provides the 'find_executable()' to search the path for a given 5 Also provides the 'find_executable()' to search the path for a given
6 executable name. 6 executable name.
7 """ 7 """
8 8
9 __revision__ = "$Id$" 9 __revision__ = "$Id$"
10 10
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 rc = os.spawnv(os.P_WAIT, executable, cmd) 88 rc = os.spawnv(os.P_WAIT, executable, cmd)
89 except OSError as exc: 89 except OSError as exc:
90 # this seems to happen when the command isn't found 90 # this seems to happen when the command isn't found
91 raise DistutilsExecError( 91 raise DistutilsExecError(
92 "command '%s' failed: %s" % (cmd[0], exc.args[-1])) 92 "command '%s' failed: %s" % (cmd[0], exc.args[-1]))
93 if rc != 0: 93 if rc != 0:
94 # and this reflects the command running but failing 94 # and this reflects the command running but failing
95 log.debug("command '%s' failed with exit status %d" % (cmd[0], rc)) 95 log.debug("command '%s' failed with exit status %d" % (cmd[0], rc))
96 raise DistutilsExecError( 96 raise DistutilsExecError(
97 "command '%s' failed with exit status %d" % (cmd[0], rc)) 97 "command '%s' failed with exit status %d" % (cmd[0], rc))
98
99 if sys.platform == 'darwin':
100 from distutils import sysconfig
101 _cfg_target = None
102 _cfg_target_split = None
103 98
104 def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0): 99 def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
105 log.info(' '.join(cmd)) 100 log.info(' '.join(cmd))
106 if dry_run: 101 if dry_run:
107 return 102 return
108 exec_fn = search_path and os.execvp or os.execv 103 exec_fn = search_path and os.execvp or os.execv
109 exec_args = [cmd[0], cmd]
110 if sys.platform == 'darwin':
111 global _cfg_target, _cfg_target_split
112 if _cfg_target is None:
113 _cfg_target = sysconfig.get_config_var(
114 'MACOSX_DEPLOYMENT_TARGET') or ''
115 if _cfg_target:
116 _cfg_target_split = [int(x) for x in _cfg_target.split('.')]
117 if _cfg_target:
118 # ensure that the deployment target of build process is not less
119 # than that used when the interpreter was built. This ensures
120 # extension modules are built with correct compatibility values
121 cur_target = os.environ.get('MACOSX_DEPLOYMENT_TARGET', _cfg_target)
122 if _cfg_target_split > [int(x) for x in cur_target.split('.')]:
123 my_msg = ('$MACOSX_DEPLOYMENT_TARGET mismatch: '
124 'now "%s" but "%s" during configure'
125 % (cur_target, _cfg_target))
126 raise DistutilsPlatformError(my_msg)
127 env = dict(os.environ,
128 MACOSX_DEPLOYMENT_TARGET=cur_target)
129 exec_fn = search_path and os.execvpe or os.execve
130 exec_args.append(env)
131 pid = os.fork() 104 pid = os.fork()
132 if pid == 0: # in the child 105 if pid == 0: # in the child
133 try: 106 try:
134 exec_fn(*exec_args) 107 exec_fn(cmd[0], cmd)
135 except OSError as e: 108 except OSError as e:
136 sys.stderr.write("unable to execute %s: %s\n" 109 sys.stderr.write("unable to execute %s: %s\n"
137 % (cmd[0], e.strerror)) 110 % (cmd[0], e.strerror))
138 os._exit(1) 111 os._exit(1)
139 112
140 sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0]) 113 sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
141 os._exit(1) 114 os._exit(1)
142 else: # in the parent 115 else: # in the parent
143 # Loop until the child either exits or is terminated by a signal 116 # Loop until the child either exits or is terminated by a signal
144 # (ie. keep waiting if it's merely stopped) 117 # (ie. keep waiting if it's merely stopped)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 160
188 if not os.path.isfile(executable): 161 if not os.path.isfile(executable):
189 for p in paths: 162 for p in paths:
190 f = os.path.join(p, executable) 163 f = os.path.join(p, executable)
191 if os.path.isfile(f): 164 if os.path.isfile(f):
192 # the file exists, we have a shot at spawn working 165 # the file exists, we have a shot at spawn working
193 return f 166 return f
194 return None 167 return None
195 else: 168 else:
196 return executable 169 return executable
OLDNEW
« no previous file with comments | « Lib/distutils/core.py ('k') | Lib/distutils/sysconfig.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+