[Biopython] Biopython on Jython

Peter biopython at maubp.freeserve.co.uk
Thu Oct 22 05:15:27 EDT 2009


Hi all,

I probably should have started this thread with a more general question,
is anyone other than Kyle interested in running Biopython under Jython?
http://lists.open-bio.org/pipermail/biopython/2009-October/005734.html

Some of the fixes this required are minor things that will also help with
other Python variants like IronPython (e.g. unit tests shouldn't make any
assumptions about the order of dictionary keys), and are worthwhile in
their own right. Others (as discussed below) are less general...

On Thu, Oct 22, 2009 at 5:47 AM, Kyle Ellrott <kellrott at gmail.com> wrote:
>
>> You probably noticed I merged some of your fixes to get (the non C and
>> non NumPy bits of) Biopython to work on Jython, but not all. Could you
>> update your github branch to the trunk at some point? That would help
>> in picking up more of your fixes.
>
> I've tried to keep my branch up to speed with the mainline.  But I didn't
> branch my work from master, so it may harder to extract...

True, but I can probably manage.

>> Many of the issues related to large python methods exceeding JVM size
>> restrictions, something which Jython was going to try and fix in 2.5.1
>> (but didn't seem to be solved in the release candidate I was trying),
>> see e.g. http://bugs.jython.org/issue527524
>> Do you (Kyle) know about more about the Jython plans and if/when they
>> might resolve this? I would prefer to avoid any ugly Jython specific
>> fixes in Biopython - especially if the next release of Jython may
>> resolve many of these points.
>
> One of the main Jython developers pointed this possible solution out to me.
> From his email:
>
>> You may be interested to know that one of the things on my development
>> backlog is to complete a Python bytecode compiler so that we can run
>> arbitrarily long methods. This works because Jython 2.5.0 includes a VM to
>> run Python bytecode (org.python.core.PyBytecode).

That sounds like what I have seen references to online, originally
targeted for Jython 2.5.1 but which seems to have slipped.

>> In a pinch, you could do
>> the same thing too now by creating a .pyc file with CPython instead of the
>> $py.class file, then using "import pycimport" in a startup script to install
>> that as a custom inporter. It's not terribly convenient however for
>> distribution, unfortunately.
>
> It sounds like it would make the Jython BioPython code more 'hacky'.

The pycimport thing does sound messy, I agree.

> I managed to isolate all of the 'large method code' that was in BioPython.
> The easiest way to fix those problems was to take large functions and split
> them into 'a', 'b', 'c', etc,  functions.

Yes, and for things like the unit tests I don't mind this. For some of the
main code, the fix really didn't help with the readability of the code -
which is why I am hoping the Python bytecode compiler in Jython
happens soon.

> One other side project to watch out for is ctypes for Jython.  I've heard
> several of the Jython developers talking about it.  And if they get it to
> work, C modules written for python, wrapped with the ctypes module,
> may be able to work in Jython.

That would be good.

Another issue is NumPy on Jython, where even a slow compatibility
library would be useful to us for getting Bio.PDB to work on Jython.
Things like Bio.Cluster interface with the NumPy C code are of
course not so feasible. I noticed you added something to the
Biopython setup.py on your branch to assume NumPy will not be
available under Jython (and not prompt the user about it being
missing). I should merge that into the trunk...

Peter



More information about the Biopython mailing list