Return-Path: Delivered-To: apmail-lucene-pylucene-dev-archive@minotaur.apache.org Received: (qmail 16525 invoked from network); 12 Jan 2011 23:33:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 Jan 2011 23:33:27 -0000 Received: (qmail 46434 invoked by uid 500); 12 Jan 2011 23:33:27 -0000 Delivered-To: apmail-lucene-pylucene-dev-archive@lucene.apache.org Received: (qmail 46378 invoked by uid 500); 12 Jan 2011 23:33:26 -0000 Mailing-List: contact pylucene-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: pylucene-dev@lucene.apache.org Delivered-To: mailing list pylucene-dev@lucene.apache.org Received: (qmail 46370 invoked by uid 99); 12 Jan 2011 23:33:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 23:33:26 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [66.159.224.220] (HELO ovaltofu.org) (66.159.224.220) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jan 2011 23:33:19 +0000 Received: from [192.168.0.10] ([192.168.0.10]) (authenticated bits=0) by ovaltofu.org (8.14.4/8.14.4) with ESMTP id p0CNWqw7027213 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 12 Jan 2011 15:32:54 -0800 (PST) Date: Wed, 12 Jan 2011 15:32:56 -0800 (PST) From: Andi Vajda X-X-Sender: vajda@yuzu.local Reply-To: Andi Vajda To: pylucene-dev@lucene.apache.org Subject: Re: call python from java - what strategy do you use? In-Reply-To: Message-ID: References: User-Agent: Alpine 2.01 (OSX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-80320132-1294875125=:4191" Content-ID: X-Virus-Checked: Checked by ClamAV on apache.org --0-80320132-1294875125=:4191 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT Content-ID: 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 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.. >> > --0-80320132-1294875125=:4191--