Index: setuptools/command/easy_install.py =================================================================== --- setuptools/command/easy_install.py (revision 64985) +++ setuptools/command/easy_install.py (working copy) @@ -1421,6 +1421,8 @@ executable = "python.exe" else: executable = nt_quote_arg(executable) + if sys.platform.startswith('java'): + executable = fix_sh_shebang(executable) 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 @@ -1637,6 +1639,23 @@ import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) sys.argv[0] = argv0; sys.argv.append(argv0); main() +def fix_sh_shebang(executable): + """Fix the shebang line for platforms (Jython) with a .sh + sys.executable. + + Shebang line interpreters can't be other shell scripts, so we prefix + these executables with /usr/bin/env in shebang lines. + """ + try: + fp = open(executable) + magic = fp.read(2) + fp.close() + except (OSError,IOError): + return executable + if magic == '#!': + executable = '/usr/bin/env %s' % executable + return executable + def main(argv=None, **kw): from setuptools import setup