I am writing a package in python that talks to an ldap server. I want it to work in CPython and Jython. To get it to work with CPython, I have successfully coded against python-ldap. However, to get it working with Jython, I must use a java jar.
How can I distribute the jar file with my package, so that if it can “import java”, it knows its jython, and dynamically adds the java jar to the path, and utilizies it. However, if that fails, it knows its CPython and uses the python-ldap libraries.
Any ideas?
Just add your jar to sys.path, like this:
It couldn’t get more simple than that 🙂
In your case you probably want to use the path of your package to find the jar:
Hope that helps!