[IPython-dev] Jython support in ipython
Fri Oct 22 16:53:35 CDT 2010
As of r7164 of Jython, which will be part of 2.5.2rc2 (and hopefully the
last release candidate for Jython 2.5.2!), we have what looks decent support
for readline emulation for Jython, sufficient to run a minimally modified
version of ipython 0.10.1, including colorization (which is not reproduced
when copied here for whatever reason from my terminal):
Python 2.5.2rc1 (trunk:7162:7163M, Oct 21 2010, 20:58:50)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In : import java
In : java.awt.L
In : java.awt.L
There are of course a number of outstanding issues. Most of these are
because I haven't yet tried to learn the ipython codebase:
1. setup.py has to be modified to support os.name == 'java', otherwise we
get an unsupported OS on install. Running directly with ipython.py is not an
2. Doing something like
In : print java.awt
results in AttributeError: CommandCompiler instance has no attribute
'compiler'. I assume ipython is using the compiler module here to help in
its magic support. Ideally we would be using the ast/_ast modules, both of
which Jython 2.5 supports. I haven't looked at the 0.11 work to see if that
helps here, but this is probably the biggest issue for Jython support.
3. OS integration relies on dispatches against os.name. In Jython, this
will always be 'java', but for the underlying OS, and its resources, we need
to know if its 'nt' or 'posix', which comes from os._name im Jython. I've
previously played with replacing os.name everywhere with an os_name()
function, defined in platutils that does the following. However it's not a
complete fix (colorization is impacted), so it needs to be done more
4. Pretty minor - we only support emulating readline.parse_and_bind("tab:
complete"); other binds are converted to (ignored) warnings. In the future,
we should be enhancing our readline support through the underlying JLine
console so that this is possible. Otherwise, I think the readline emulation
is currently complete.
5. It's not *Python* 2.5.2rc1 (trunk:7162:7163M, Oct 21 2010, 20:58:50),
is it? ;)
My goal in this last phase of work was just to get sufficient
*readline*emulation to run ipython, so this part has been
accomplished. But of course
we should also look at really supporting *ipython* too:
1. Create a jython-ipython fork on github, then make it available from
PyPI. My current plan is to target against the 0.10.1 tag, but if it makes
more sense to go with 0.11 (especially AST support), then please tell me.
More unit tests would be especially a good reason, especially if they use
pexpect. Jython does not directly support pexpect, because we lack access to
pseudo ttys, but we can use such CPython-only modules transparently from
Jython via execnet (
2. Merge this fork back into ipython at some point in the future. Among
other things, the ZMQ work should also be feasible to port to Jython when it
3. Support additional Java integration, such as Swing. Maybe this is a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev