You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/06/16 16:04:11 UTC

tinkerpop git commit: If PYTHONPATH is set, then add it to Jython sys.path. This is important for external libraries like the new enum library.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 8ee29044d -> 146f47602


If PYTHONPATH is set, then add it to Jython sys.path. This is important for external libraries like the new enum library.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/146f4760
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/146f4760
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/146f4760

Branch: refs/heads/TINKERPOP-1278
Commit: 146f47602d4fcf86edb4f989d6359cad0913c7b5
Parents: 8ee2904
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Jun 16 10:04:06 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Jun 16 10:04:06 2016 -0600

----------------------------------------------------------------------
 .../apache/tinkerpop/gremlin/python/PythonProvider.java   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/146f4760/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
index f100c9c..cfbb3d1 100644
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/PythonProvider.java
@@ -47,7 +47,12 @@ public class PythonProvider extends VariantGraphProvider {
             jythonEngine.eval("import sys");
             jythonEngine.eval("sys.path.append('" + gremlinPythonPackageName + "')");
             jythonEngine.eval("sys.path.append('" + gremlinDriverPackageName + "')");
-            jythonEngine.eval("sys.path.append('/Library/Python/2.7/site-packages')"); // TODO: require PYTHONPATH
+            final String pythonPath = null == System.getenv("JYTHONPATH") ? System.getenv("PYTHONPATH") : System.getenv("JYTHONPATH");
+            if (null != pythonPath) {
+                for (final String path : pythonPath.split(":")) {
+                    jythonEngine.eval("sys.path.append('" + path + "')");
+                }
+            }
             jythonEngine.eval("from gremlin_python import *");
             jythonEngine.eval("from gremlin_python import __");
             jythonEngine.eval("from groovy_translator import GroovyTranslator");
@@ -62,7 +67,8 @@ public class PythonProvider extends VariantGraphProvider {
         try {
             if (importStatics)
                 ScriptEngineCache.get("jython").eval("for k in statics:\n  globals()[k] = statics[k]");
-            // else globals()[k] = None
+            else
+                ScriptEngineCache.get("jython").eval("for k in statics:\n  if k in globals():\n    del globals()[k]");
         } catch (final ScriptException e) {
             throw new IllegalStateException(e.getMessage(), e);
         }