diff options
author | PJ Eby <distutils-sig@python.org> | 2006-09-06 21:01:13 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2006-09-06 21:01:13 +0000 |
commit | 243812655538358387c703bbd3789d2df05ca18b (patch) | |
tree | bec5f71614a6fda896eb4c50b8f5ebff6d87f74d /setuptools/command/easy_install.py | |
parent | 7d8ac102b900a1934c9d710b1eea59beb7945f0e (diff) | |
download | external_python_setuptools-243812655538358387c703bbd3789d2df05ca18b.tar.gz external_python_setuptools-243812655538358387c703bbd3789d2df05ca18b.tar.bz2 external_python_setuptools-243812655538358387c703bbd3789d2df05ca18b.zip |
Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable``
contains non-ASCII characters, to prevent deprecation warnings about an
unspecified encoding when the script is run.
(backport from trunk)
--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051791
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-x | setuptools/command/easy_install.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 1696b631..0514adb1 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1408,7 +1408,17 @@ def get_script_header(script_text, executable=sys_executable): options = match.group(1) or '' if options: options = ' '+options - return "#!%(executable)s%(options)s\n" % locals() + hdr = "#!%(executable)s%(options)s\n" % locals() + if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: + # Non-ascii path to sys.executable, use -x to prevent warnings + if options: + if options.strip().startswith('-'): + options = ' -x'+options.strip()[1:] + # else: punt, we can't do it, let the warning happen anyway + else: + options = ' -x' + hdr = "#!%(executable)s%(options)s\n" % locals() + return hdr def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': @@ -1442,7 +1452,6 @@ def is_python(text, filename='<string>'): else: return True - def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ @@ -1465,15 +1474,6 @@ def is_python_script(script_text, filename): return False # Not any Python I can recognize - - - - - - - - - def get_script_args(dist, executable=sys_executable): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) |