[Distutils] Shebang lines on Jython
Philip Jenvey
pjenvey at underboss.org
Wed Apr 16 20:00:57 CEST 2008
Speaking of shebang lines, there's problems with setuptools shebang
lines on Jython. Unfortunately it's going to require another patch or
two to setuptools.
The problem being that Jython's executable is a .sh or .bat file
(that'll invoke java), and interpreters in shebang lines can't be
interpreter files, i.e. another script. Running a .py script that
shebangs the Jython .sh executable directly will result in something
along the lines of a "test.py: line 2 import command not found" sh
error.
For posix, we'll just need to special case Jython on posix to make a
shebang along the lines of:
#!/usr/bin/env /opt/local/bin/jython
Windows isn't as easy. setuptools' launcher.c similarly can't use
a .bat file as the interpreter. A workaround would be to use cmd.exe /
c in the same way we'll use /usr/bin/env on posix. launcher.c
currently can't handle this, though, the problem being it can't
correctly quote the cmd.exe /c line correctly.
With:
#!c:\windows\system32\cmd.exe /c c:\jython2.2\jython.bat
launcher.c ends up calling:
"c:\windows\system32\cmd.exe" "/c" "c:\jython2.2\jython.bat" "c:
\scripts\myscript-script.py"
when we need:
"c:\windows\system32\cmd.exe" /c ""c:\jython2.2\jython.bat" "c:
\scripts\myscript-script.py""
which is another set of quotes around the entire /c arg, and yes no
quotes around /c (I have no idea why "/c" doesn't work).
I guess we would have to patch launcher.c to deal with this special
situation or make a custom version for Jython. That's pretty awful --
might anyone have a simpler way of handling this?
--
Philip Jenvey
More information about the Distutils-SIG
mailing list