Hi Roman,
On Thu, 13 Jan 2011, Roman Chyla wrote:
Your help is great, thanks a lot! Without your detailed instructions,
I would not be able to figure it out - and the last bit with the
python...I should have thought before writing :-)
I call the class EMQL just because I was lazy to change it. But I will
do now that I understand little bit more. What I find very cool is the
fact, that if I build this extension the way you showed me, I can run
java from inside python, but also python from inside Java - and with
one jar and one compiled egg. Very handy. But as you said, evil is in
details, so I expect some bumps.
And about the thing with LFLAGS 'platform Python', also other
platforms will need something similar like Mac? I assume this is a mac
dynamic discovery of the libraries, will anything bad happen if I
changed the path of the Python now when the extension was built?
I don't know, I don't distribute binaries :-)
The 'otool -L' command on the mac will show you what libraries the linker is
going to be looking for for a given shared library. The DYLD_FRAMEWORK_PATH
(?) and DYLD_LIBRARY_PATH env vars may help you in overriding this but I'm
not so sure.
Andi..
Cheers!
roman
On Wed, Jan 12, 2011 at 11:54 PM, Andi Vajda <va...@apache.org> wrote:
Hi Roman,
On Wed, 12 Jan 2011, Roman Chyla wrote:
Thanks for the help, now I was able to run the java and loaded
PythonVM. I then built the python egg, after a bit of fiddling with
parameters, it seems ok. I can import the jcc wrapped python class and
call it:
In [1]: from solrpie_java import emql
Why are you calling your class EMQL ? (this name was just an example culled
from my code).
In [2]: em = emql.Emql()
In [3]: em.javaTestPrint()
java is printing
In [4]: em.pythonTestPrint()
just a test
But I haven't found out how to call the same from java.
Ah, yes, I forgot to tell you how to pull that in.
In Java, you import that 'EMQL' java class and instantiate it by way of the
PythonVM instance's instantiate() call:
import org.blah.blah.EMQL;
import org.apache.jcc.PythonVM;
.............
PythonVM vm = PythonVM.get();
emql = (EMQL) vm.instantiate("jemql.emql", "emql");
... call method on emql instance just created ...
The instantiate("foo", "bar") method in effect asks Python to run
"from foo import bar"
"return bar()"
Andi..