Custom JAR using standalone Jython 2.7.2 doesn't obey JYTHONPATH

Pekka Klärck <[email protected]> Fri, 27 Mar 2020 23:59:47 +0200
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CACXFLVebe3os_Eoh25xcNLW0OvEGxmxVuPCOWJm=rOxk+7oZ2A@mail.gmail.com>
Hi,

In the Robot Framework project
(https://github.com/robotframework/robotframework) one of our
distributions is a standalone JAR that is built on top of standalone
Jython. We've earlier used Jython 2.7.0, but there have been lot of
fixes since that and we are now planning to switch to Jython 2.7.2. I
have already changed our build scripts and have been running all our
acceptance tests using the new JAR.

Things have worked pretty well with the new JAR otherwise, but it
seems it doesn't obey JYTHONPATH set externally before execution.
Executing Python code can see the environment variable, but Python
modules in directories listed in it cannot be imported. I just tested
that if I build a JAR from same sources with Jython 2.7.0, JYTHONPATH
works as expected.

The strange thing is that when I tested with the standalone Jython
2.7.2 alone, it did handle JYTHONPATH just fine. This got me thinking
that perhaps we are somehow embedding Jython wrong. Are there some
know changes related to embedding Jython using PythonInterpreter?
Should we perhaps configure it somehow to get JYTHONPATH processed
correctly? The code currently just initialized PythonInterpreter
without any arguments and then calls `interpreter.exec(code)`. You can
find the full code here:
https://github.com/robotframework/robotframework/blob/master/src/java/org/robotframework/RobotRunner.java

One workaround for us is processing JYTHONPATH in our code and I
already tested that it works. If that turns out to be the only
solution, I just need to find a way to do that only when using the JAR
distribution.

Cheers,
    .peke
-- 
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org