Commit 71aeed6a authored by PJ Eby's avatar PJ Eby

Fix a Windows problem when the Python executable is in a directory with

a ' ' in its name.

--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042359
parent 38aa9be2
...@@ -286,7 +286,7 @@ class easy_install(Command): ...@@ -286,7 +286,7 @@ class easy_install(Command):
def cant_write_to_target(self): def cant_write_to_target(self):
msg = """can't create or remove files in install directory msg = """can't create or remove files in install directory
The following error occurred while trying to add or remove files in the The following error occurred while trying to add or remove files in the
installation directory: installation directory:
...@@ -316,7 +316,7 @@ variable. ...@@ -316,7 +316,7 @@ variable.
For information on other options, you may wish to consult the For information on other options, you may wish to consult the
documentation at: documentation at:
http://peak.telecommunity.com/EasyInstall.html http://peak.telecommunity.com/EasyInstall.html
Please make the appropriate changes for your system and try again. Please make the appropriate changes for your system and try again.
...@@ -341,15 +341,15 @@ Please make the appropriate changes for your system and try again. ...@@ -341,15 +341,15 @@ Please make the appropriate changes for your system and try again.
else: else:
try: try:
f.write("import os;open(%r,'w').write('OK')\n" % (ok_file,)) f.write("import os;open(%r,'w').write('OK')\n" % (ok_file,))
f.close(); f=None f.close(); f=None
executable = sys.executable executable = sys.executable
if os.name=='nt': if os.name=='nt':
dirname,basename = os.path.split(executable) dirname,basename = os.path.split(executable)
alt = os.path.join(dirname,'pythonw.exe') alt = os.path.join(dirname,'pythonw.exe')
if basename.lower()=='python.exe' and os.path.exists(alt): if basename.lower()=='python.exe' and os.path.exists(alt):
# use pythonw.exe to avoid opening a console window # use pythonw.exe to avoid opening a console window
executable = alt executable = alt
if ' ' in executable: executable='"%s"' % executable
from distutils.spawn import spawn from distutils.spawn import spawn
spawn([executable,'-E','-c','pass'],0) spawn([executable,'-E','-c','pass'],0)
...@@ -361,9 +361,9 @@ Please make the appropriate changes for your system and try again. ...@@ -361,9 +361,9 @@ Please make the appropriate changes for your system and try again.
return True return True
finally: finally:
if f: f.close() if f: f.close()
if os.path.exists(ok_file): os.unlink(ok_file) if os.path.exists(ok_file): os.unlink(ok_file)
if os.path.exists(pth_file): os.unlink(pth_file) if os.path.exists(pth_file): os.unlink(pth_file)
log.warn("TEST FAILED: %s does NOT support .pth files", instdir) log.warn("TEST FAILED: %s does NOT support .pth files", instdir)
return False return False
...@@ -1483,7 +1483,7 @@ def main(argv=None, **kw): ...@@ -1483,7 +1483,7 @@ def main(argv=None, **kw):
usage: %(script)s [options] requirement_or_url ... usage: %(script)s [options] requirement_or_url ...
or: %(script)s --help or: %(script)s --help
""" """
def gen_usage (script_name): def gen_usage (script_name):
script = os.path.basename(script_name) script = os.path.basename(script_name)
return USAGE % vars() return USAGE % vars()
...@@ -1495,7 +1495,7 @@ usage: %(script)s [options] requirement_or_url ... ...@@ -1495,7 +1495,7 @@ usage: %(script)s [options] requirement_or_url ...
return f() return f()
finally: finally:
distutils.core.gen_usage = old_gen_usage distutils.core.gen_usage = old_gen_usage
class DistributionWithoutHelpCommands(Distribution): class DistributionWithoutHelpCommands(Distribution):
def _show_help(self,*args,**kw): def _show_help(self,*args,**kw):
with_ei_usage(lambda: Distribution._show_help(self,*args,**kw)) with_ei_usage(lambda: Distribution._show_help(self,*args,**kw))
...@@ -1505,7 +1505,7 @@ usage: %(script)s [options] requirement_or_url ... ...@@ -1505,7 +1505,7 @@ usage: %(script)s [options] requirement_or_url ...
with_ei_usage(lambda: with_ei_usage(lambda:
setup( setup(
script_args = ['-q','easy_install', '-v']+argv, script_args = ['-q','easy_install', '-v']+argv,
distclass=DistributionWithoutHelpCommands, **kw distclass=DistributionWithoutHelpCommands, **kw
) )
) )
......
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