Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Scripting
    • Labels:
      None

      Description

      It seems that currently the python.home property is not set for the PythonInterpreter, which causes the cachedir containing some Java Library stuff caches to be created in the current working directory.

      I think, the PythonScriptEngineFactory should setup the PythonInterpreter with correct setup information by calling the static PythonInterpreter.initialize method before creating the first PythonScriptEngine instance.

        Activity

        Hide
        Aaron Zeckoski added a comment -

        If the issue is cache files related to python then the "python.cachedir" setting might be more important here (though this should get set right if the python.home is set correctly). Since python.home is not always the same on every machine I assume we probably want something like this in the constructor for PythonScriptEngineFactory:
        Properties props = new Properties();
        props.put("python.home", configuredPythonHome);
        PythonInterpreter.initialize(System.getProperties(),
        props, new String[0]);

        I would think it would be ideal to get the configuredPythonHome value from the OSGi configuration.
        If you give me a tip about how to do that I will be happy to submit a patch for this.

        Show
        Aaron Zeckoski added a comment - If the issue is cache files related to python then the "python.cachedir" setting might be more important here (though this should get set right if the python.home is set correctly). Since python.home is not always the same on every machine I assume we probably want something like this in the constructor for PythonScriptEngineFactory: Properties props = new Properties(); props.put("python.home", configuredPythonHome); PythonInterpreter.initialize(System.getProperties(), props, new String [0] ); I would think it would be ideal to get the configuredPythonHome value from the OSGi configuration. If you give me a tip about how to do that I will be happy to submit a patch for this.
        Hide
        Felix Meschberger added a comment -

        Currently the PythonScriptEngineFactory is set up through the standard JSR-223 mechanims listing the factory class in the META-INF/services/javax.scripting.ScriptEngineFactory file. This way, it is not possilbe to inject configuration.

        The easiest to inject configuration is probably to make the PythonScriptEngineFactory a Service Component

        @scr.component...
        @scr.service...

        Then we could define the python.home property as:

        @scr.property name="python.home"

        I would not set an explicit default value, but rather in the activate(ComponentContext ctx) method default the python.home value to a folder inside the bundle's data dir:

        File defaultHome = ctx.getBundleContext().getDataDir("python");

        The default properties would not come from the system but from ComponentContext.getProperties() - this would then also automatically include the python.home property, you just would have to make sure it is set.

        Show
        Felix Meschberger added a comment - Currently the PythonScriptEngineFactory is set up through the standard JSR-223 mechanims listing the factory class in the META-INF/services/javax.scripting.ScriptEngineFactory file. This way, it is not possilbe to inject configuration. The easiest to inject configuration is probably to make the PythonScriptEngineFactory a Service Component @scr.component... @scr.service... Then we could define the python.home property as: @scr.property name="python.home" I would not set an explicit default value, but rather in the activate(ComponentContext ctx) method default the python.home value to a folder inside the bundle's data dir: File defaultHome = ctx.getBundleContext().getDataDir("python"); The default properties would not come from the system but from ComponentContext.getProperties() - this would then also automatically include the python.home property, you just would have to make sure it is set.

          People

          • Assignee:
            Unassigned
            Reporter:
            Felix Meschberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development