Skip to content

BOY jython path handling changed #2541

@kasemir

Description

@kasemir

This idea is including some/path/script1.py, and that script in turn includes other files from the same some/path .

In a workspace location, create sub-folder 'scripts' with two scripts:

# scripts/sub.py
def do_it(widget):
    widget.setPropertyValue("text", "Hello from python!")

and

# scripts/main.py
import sys
print "Path:\n" + "\n".join(sys.path)

from sub import do_it
do_it(widget)

In the parent directory, create a display with a Label.

Add a script to that label, calling scripts/main.py, triggered by loc://init(1).

Execute that display, and label should show "Hello from python!"

Not sure when it changed, but this worked from the beginning of BOY, including versions built from 'master' at the end of July. Also works fine with the Display Builder.

But fails with BOY built right now:

ERROR: Error in scripts/main.py on Label.
..
ImportError: No module named sub

In the successful case, the path printout in main.py includes the scripts folder:

Path:
/home/ky9/Eclipse/CSS/plugins/org.python.jython_2.7.0.release.jar/Lib
/home/ky9/Eclipse/CSS/Lib
__classpath__
__pyclasspath__/
/home/ky9/Eclipse/runtime-sns-css.product/CSS/script_issue/scripts

With the current version of BOY, the path lacks the script directory:

Path:
/home/ky9/git/css_target/plugins/org.python.jython_2.7.1.release.jar/Lib
/home/ky9/Eclipse/4.7.3a/Lib
__classpath__
__pyclasspath__/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions