From: Stefan R. <Ste...@gm...> - 2017-01-15 21:52:37
|
Thufir, there are basically two options, depending how close Java-intergation of the API you need. -If you have only a specific use-case you can use PythonInterpreter to execute python-code that performs the desired operation. PythonInterpreter-API also allows you to retrieve values for further processing in Java. -If you'd like to have Java-API-like access to a Python-API (e.g. that of nfldb), you need to write a Java-interface that acts like a header to that Python-API, adding Java type-information to it. So far you can only target Python-methods, i.e. no direct field-access. In Jython 2.7.1b3 or newer, use Py.newJ or PyModule.newJ method family to instanciate Python- objects under such Java-interface. Page 45+ of https://arxiv.org/pdf/1607.00825v1.pdf contain examples using that technique (although these are JyNI examples, the principle is applicable to plain Python-code as well). Prior to 2.7.1b3 you would need to write glue-code in Python, that extends your Java-interface. See http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications for further example, especially the approach with glue-code. Given you mention JNI, I wouldn't see how that could help here. nfldb seems to contain no C-part. Feel free to ask again in more detail if you stuck on either approach. Best Stefan > Gesendet: Sonntag, 15. Januar 2017 um 18:45 Uhr > Von: "Thufir Hawat" <haw...@gm...> > An: Jyt...@li... > Betreff: [Jython-users] hook into nfldb with PythonInterpreter? > > I'm very new to Python and Jython, but installed nfldb from > > pip install --user nfldb > > which is on github: > > https://github.com/BurntSushi/nfldb/wiki/More-examples > > > Coming at this from Java, how would I hook into nfldb with Java? Or, > perhaps, run the code in Jython? > > I'm sure there's a general solution or approach, would appreciate any > pointers. Perhaps simply using JNI to leverage the work that's gone into > this library already. > > It looks like probably org.python.util.PythonInterpreter is the best way > to invoke this library? I've seen examples of how to invoke a specific > script, but this API is a bit larger. How would I hook into an API? > > > > > thanks, > > Thufir > > > > > > ------------------------------------------------------------------------------ > Developer Access Program for Intel Xeon Phi Processors > Access to Intel Xeon Phi processor-based developer platforms. > With one year of Intel Parallel Studio XE. > Training and support from Colfax. > Order your platform today. http://sdm.link/xeonphi > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |