I recently managed to compile jython natively on a linux/x86 box using
gcj (http://gc.gnu.org/java) the Gnu native Java compiler. We're
interested in including jython into our RHUG project
(http://sources.redhat.com/rhug) I'm also hoping to hack jythonc to
wrap gcj so that native shared object can be generated from the class
files jythonc emits. These shared object could be loaded by the jython
binary to be executed instead of being interpreted (we can support
both seamlessly.) This would yield to a working native Python
compiler.
I can build SimpleEmbedded and jython as standalone binaries, and they
seem to run:
apbianco@venonat[~/.../jython]: ./test_SimpleEmbedded
Hello, brave new world
sys module
42
x: 4
Goodbye, cruel world
apbianco@venonat[~/.../jython]: ./test_jython
Jython 2.1a3 on java0.0.7 (JIT: null)
>>> print "Hello world"
Hello world
>>> ^D
pystone seems to run and yields to following results:
apbianco@venonat[~/.../jython]: ./test_jython pystone.py
Pystone(1.1) time for 10000 passes = 9.984
This machine benchmarks at 1001.6 pystones/second
It's on a PIII/450 with 384MB of RAM. The jdk1.1.8 interpreted jython
gave roughly 660 (a jdk1.2pre on a slightly faster machine yielded
700), the installed python interpreter (Python 1.5.2) gave 4400.
I built the 2.1a3 and got the sources by first installing it
somewhere. I then imported the content of the install directory where
I wanted my sources to be and worked from there.
The first successful build was based on a week old snapshot (I noted
that while 2.1a3 had only one entry in Lib/test, the snapshot had
several,) I then switched over 2.1a3.
I got interested in running the tests in Lib/test from the snapshot
(using the single entry point testall.py and I ran into the following
problems:
- If I try to run the jython binary outside of Lib/, I
get the following error:
Testing JPython Version 2.1a3
Traceback (innermost last):
File "/home/apbianco/src/rhug/jython/upstream/src/Lib/test-all/testall.py", line 4, in ?
File "/home/apbianco/src/rhug/jython/upstream/src/Lib/test/test_support.py", line 43, in ?
ImportError: no module named javaos
I modified my local registry to set python.path to
/home/apbianco/src/rhug/jython/upstream/src/Lib, and debug shows that
jython successfully reads the local registry.
- If I try to run the jython binary inside Lib/, I get a different
error:
Testing JPython Version 2.1a3
Traceback (innermost last):
File "/home/apbianco/src/rhug/jython/upstream/src/Lib/test-all/testall.py", line 4, in ?
File "/home/apbianco/src/rhug/jython/upstream/src/Lib/test/test_support.py", line 43, in ?
ImportError: cannot import name unlink
So despite the initialization of jython.path, I still can't see some
libraries, I have to start jython right where the libraries are.
And then I hit an error I don't understand. unlink is seemingly
defined to be equivalent to remove in javaos.py. I tried to just
re-define unlink to be like remove, it didn't help. I tried to remove
the mention of `import unlink' in test_support.py:43, it didn't help.
There are still other mysteries to be resolved, like why the -v
command doesn't work with the natively compiled jython, but I would
appreciate if someone could give me some hints on:
- Positioning a path to the Lib/ directory
- What `ImportError: cannot import name unlink' could mean with
regard to the internal jython machinery (we might have compiler or
a runtime bug.)
Thank you.
./A
|