Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write python wrapper of a java library

How can we write a python (with CPython) binding to a Java library so that the developers that want to use this java library can use it by writing only python code, not worrying about any Java code?

like image 433
MHardy Avatar asked Jun 19 '12 09:06

MHardy


1 Answers

You could try this way:

  • Use Jython instead of CPython to write Python code http://www.jython.org.
  • Integrate Jython code with Java code through Apache Bean Scripting Framework http://commons.apache.org/bsf/

If you definitely need to use CPython, then Apache Trift could be interesting for you: http://thrift.apache.org/ So you could make additional scalable abstraction layer and integrate your Java code with different languages (not only Python)

If you need a really low-level interface you could look at JNI http://java.sun.com/docs/books/jni/ for investigation. But I think it will take a lot of time to integrate your code with CPython using JNI.

like image 81
Vladislav Bauer Avatar answered Sep 26 '22 21:09

Vladislav Bauer