Commit c8c09bf0 authored by Jim Fulton's avatar Jim Fulton

Stop using os.spawn (and _safe_arg where it isn't needed).

parent b47bf7d8
...@@ -77,7 +77,7 @@ def _get_version(executable): ...@@ -77,7 +77,7 @@ def _get_version(executable):
try: try:
return _versions[executable] return _versions[executable]
except KeyError: except KeyError:
cmd = _safe_arg(executable) + ' -V' cmd = executable + ' -V'
p = subprocess.Popen(cmd, p = subprocess.Popen(cmd,
shell=True, shell=True,
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
...@@ -137,10 +137,13 @@ if is_win32: ...@@ -137,10 +137,13 @@ if is_win32:
else: else:
_safe_arg = str _safe_arg = str
_easy_install_cmd = _safe_arg( def call_subprocess(args, **kw):
'from setuptools.command.easy_install import main; main()' if subprocess.call(args, **kw) != 0:
) raise Exception(
"Failed to run command:\n%s"
% repr(args)[1:-1])
_easy_install_cmd = 'from setuptools.command.easy_install import main; main()'
class Installer: class Installer:
...@@ -301,36 +304,26 @@ class Installer: ...@@ -301,36 +304,26 @@ class Installer:
try: try:
path = setuptools_loc path = setuptools_loc
args = ('-c', _easy_install_cmd, '-mUNxd', _safe_arg(tmp)) args = [self._executable, '-c', _easy_install_cmd, '-mUNxd', tmp]
if self._always_unzip: if self._always_unzip:
args += ('-Z', ) args.append('-Z')
level = logger.getEffectiveLevel() level = logger.getEffectiveLevel()
if level > 0: if level > 0:
args += ('-q', ) args.append('-q')
elif level < 0: elif level < 0:
args += ('-v', ) args.append('-v')
args += (_safe_arg(spec), ) args.append(spec)
if level <= logging.DEBUG: if level <= logging.DEBUG:
logger.debug('Running easy_install:\n%s "%s"\npath=%s\n', logger.debug('Running easy_install:\n%s "%s"\npath=%s\n',
self._executable, '" "'.join(args), path) self._executable, '" "'.join(args), path)
if is_jython:
extra_env = dict(os.environ, PYTHONPATH=path)
else:
args += (dict(os.environ, PYTHONPATH=path), )
sys.stdout.flush() # We want any pending output first sys.stdout.flush() # We want any pending output first
if is_jython: exit_code = subprocess.call(
exit_code = subprocess.Popen( list(args),
[_safe_arg(self._executable)] + list(args), env=dict(os.environ, PYTHONPATH=path))
env=extra_env).wait()
else:
exit_code = os.spawnle(
os.P_WAIT, self._executable, _safe_arg (self._executable),
*args)
dists = [] dists = []
env = pkg_resources.Environment( env = pkg_resources.Environment(
...@@ -873,26 +866,18 @@ def develop(setup, dest, ...@@ -873,26 +866,18 @@ def develop(setup, dest,
tmp3 = tempfile.mkdtemp('build', dir=dest) tmp3 = tempfile.mkdtemp('build', dir=dest)
undo.append(lambda : shutil.rmtree(tmp3)) undo.append(lambda : shutil.rmtree(tmp3))
args = [ args = [executable, tsetup, '-q', 'develop', '-mxN', '-d', tmp3]
zc.buildout.easy_install._safe_arg(tsetup),
'-q', 'develop', '-mxN',
'-d', _safe_arg(tmp3),
]
log_level = logger.getEffectiveLevel() log_level = logger.getEffectiveLevel()
if log_level <= 0: if log_level <= 0:
if log_level == 0: if log_level == 0:
del args[1] del args[2]
else: else:
args[1] == '-v' args[2] == '-v'
if log_level < logging.DEBUG: if log_level < logging.DEBUG:
logger.debug("in: %r\n%s", directory, ' '.join(args)) logger.debug("in: %r\n%s", directory, ' '.join(args))
if is_jython: call_subprocess(args)
assert subprocess.Popen([_safe_arg(executable)] + args).wait() == 0
else:
assert os.spawnl(os.P_WAIT, executable, _safe_arg(executable),
*args) == 0
return _copyeggs(tmp3, dest, '.egg-link', undo) return _copyeggs(tmp3, dest, '.egg-link', undo)
...@@ -1257,13 +1242,10 @@ def redo_pyc(egg): ...@@ -1257,13 +1242,10 @@ def redo_pyc(egg):
logger.warning("Couldn't compile %s", filepath) logger.warning("Couldn't compile %s", filepath)
else: else:
# Recompile under other optimization. :) # Recompile under other optimization. :)
args = [_safe_arg(sys.executable)] args = [sys.executable]
if __debug__: if __debug__:
args.append('-O') args.append('-O')
args.extend(['-m', 'py_compile', _safe_arg(filepath)]) args.extend(['-m', 'py_compile', filepath])
if is_jython: call_subprocess(args)
subprocess.call([sys.executable, args])
else:
os.spawnv(os.P_WAIT, sys.executable, args)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment