we would like to integrate the Jython interpreter into our Eclipse RCP based solution and we need to access the OSGi bundles (e.g. everything from Activator.getContext().getBundles() ) from there.
How could I pass these bundles to a Jython PythonInterpreter object python.path property, so I can import these classes from the Jython code?
(I get similar error messages when I try to import packages e.g.:
from org.eclipse.chemclipse.msd.converter.chromatogram import ChromatogramConverterMSD)
ImportError: cannot import name ChromatogramConverterMSD
I managed to find a solution after working on this issue for days.
First we need a
ClassLoaderwhich can load OSGi bundles if necessary:Then the
PythonInterpreterneeds to know about thisClassLoader. The best is to set up the environment for thePythonInterpreterbefore. The following class does the job:The
JythonEnvironmentclass needs to know about the bundle. The best if that one can be received through theActivator.Hope this answer will save time, if someone else needs to integrate Jython into an Eclipse RCP based solution.