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/22 15:49:56 UTC

[1/2] tinkerpop git commit: gremlin_python: generate/build/deps before tests

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 b37015dc1 -> 7d2a1bfb8


gremlin_python: generate/build/deps before tests

Code generation is triggered by Maven before tests are run; dependencies
(currently aenum, requests) are installed, and the generated package is built
into ${project.build.testOutputDirectory}/Lib, which is added to the
classpath for the tests via the python.home property. Jython tests
import the gremlin_python package instead of importing its modules
directly.


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

Branch: refs/heads/TINKERPOP-1278
Commit: df0896c5514254e1250c303713a93df7cb29236d
Parents: 4b6208a
Author: Leifur Halldor Asgeirsson <la...@zerofail.com>
Authored: Wed Jun 22 09:34:41 2016 -0400
Committer: Leifur Halldor Asgeirsson <la...@zerofail.com>
Committed: Wed Jun 22 11:07:21 2016 -0400

----------------------------------------------------------------------
 gremlin-variant/pom.xml                         | 56 ++++++++++++++++++++
 .../gremlin/python/GenerateGremlinPython.java   | 33 ++++++++++++
 gremlin-variant/src/main/jython/setup.py        |  3 +-
 .../gremlin/python/JythonScriptEngineSetup.java | 23 ++------
 4 files changed, 94 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df0896c5/gremlin-variant/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-variant/pom.xml b/gremlin-variant/pom.xml
index 34f181d..8380237 100644
--- a/gremlin-variant/pom.xml
+++ b/gremlin-variant/pom.xml
@@ -100,6 +100,39 @@
         </testResources>
         <plugins>
             <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <version>1.2.1</version>
+                <executions>
+                    <execution>
+                        <id>generatePython</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>java</goal>
+                        </goals>
+                        <configuration>
+                            <mainClass>org.apache.tinkerpop.gremlin.python.GenerateGremlinPython</mainClass>
+                            <arguments>
+                                <argument>${basedir}/src/main/jython/gremlin_python/gremlin_python.py</argument>
+                            </arguments>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>buildPython</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>exec</goal>
+                        </goals>
+                        <configuration>
+                            <executable>python</executable>
+                            <async>true</async>
+                            <workingDirectory>${basedir}/src/main/jython</workingDirectory>
+                            <commandlineArgs>setup.py build --build-lib ${project.build.testOutputDirectory}/Lib</commandlineArgs>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
                 <groupId>org.codehaus.gmavenplus</groupId>
                 <artifactId>gmavenplus-plugin</artifactId>
                 <version>1.2</version>
@@ -132,10 +165,33 @@
                             <goal>jython</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>pythonDependencies</id>
+                        <phase>generate-test-resources</phase>
+                        <goals>
+                            <goal>jython</goal>
+                        </goals>
+                        <configuration>
+                             <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
+                            <libraries>
+                                <param>aenum</param>
+                                <param>requests</param>
+                            </libraries>
+                        </configuration>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <systemPropertyVariables>
+                        <python.home>${project.build.testOutputDirectory}</python.home>
+                    </systemPropertyVariables>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-clean-plugin</artifactId>
                 <version>3.0.0</version>
                 <executions>

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df0896c5/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
new file mode 100644
index 0000000..c7bc40a
--- /dev/null
+++ b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/GenerateGremlinPython.java
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.tinkerpop.gremlin.python;
+
+public class GenerateGremlinPython {
+    public static void main(String[] args) {
+        String dest;
+        if (args.length > 0) {
+            dest = args[0];
+        } else {
+            System.out.println("Usage: java GenerateGremlinPython <path/to/dest>");
+            return;
+        }
+        GremlinPythonGenerator.create(dest);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df0896c5/gremlin-variant/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/jython/setup.py b/gremlin-variant/src/main/jython/setup.py
index d1a0bb1..b0a5913 100644
--- a/gremlin-variant/src/main/jython/setup.py
+++ b/gremlin-variant/src/main/jython/setup.py
@@ -48,6 +48,7 @@ setup(
     description='Gremlin Language Variant for Apache TinkerPop - Gremlin',
     long_description=open("README").read(),
     install_requires=[
-        'aenum'
+        'aenum',
+        'requests'
     ]
 )

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/df0896c5/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
index 799f3b2..608b40f 100644
--- a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/JythonScriptEngineSetup.java
@@ -23,7 +23,6 @@ import org.apache.tinkerpop.gremlin.util.ScriptEngineCache;
 
 import javax.script.ScriptEngine;
 import javax.script.ScriptException;
-import java.io.File;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -35,26 +34,10 @@ public class JythonScriptEngineSetup {
 
     public static void setup() {
         try {
-            final String rootPackageName = (new File("gremlin-variant").exists() ? "gremlin-variant/" : "") + "src/main/jython/";
-            final String gremlinPythonPackageName = rootPackageName + "/gremlin_python";
-            final String gremlinDriverPackageName = rootPackageName + "/gremlin_driver";
-            final String gremlinRESTDriverPackageName = rootPackageName + "/gremlin_rest_driver";
-            final String gremlinPythonModuleName = gremlinPythonPackageName + "/gremlin_python.py";
-            GremlinPythonGenerator.create(gremlinPythonModuleName);
             final ScriptEngine jythonEngine = ScriptEngineCache.get("jython");
-            jythonEngine.eval("import sys");
-            jythonEngine.eval("sys.path.append('" + gremlinPythonPackageName + "')");
-            jythonEngine.eval("sys.path.append('" + gremlinDriverPackageName + "')");
-            jythonEngine.eval("sys.path.append('" + gremlinRESTDriverPackageName + "')");
-            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");
+            jythonEngine.eval("from gremlin_python.gremlin_python import *");
+            jythonEngine.eval("from gremlin_python.gremlin_python import __");
+            jythonEngine.eval("from gremlin_python.groovy_translator import GroovyTranslator");
             jythonEngine.eval("from gremlin_rest_driver import RESTRemoteConnection");
         } catch (final ScriptException e) {
             throw new IllegalStateException(e.getMessage(), e);


[2/2] tinkerpop git commit: Merge branch 'python_test_fix' of https://github.com/leifurhauks/incubator-tinkerpop into TINKERPOP-1278

Posted by ok...@apache.org.
Merge branch 'python_test_fix' of https://github.com/leifurhauks/incubator-tinkerpop into TINKERPOP-1278


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

Branch: refs/heads/TINKERPOP-1278
Commit: 7d2a1bfb82e197a5f9a3c13fec8317b1ef0ec2c4
Parents: b37015d df0896c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Jun 22 09:35:17 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Jun 22 09:35:17 2016 -0600

----------------------------------------------------------------------
 gremlin-variant/pom.xml                         | 56 ++++++++++++++++++++
 .../gremlin/python/GenerateGremlinPython.java   | 33 ++++++++++++
 gremlin-variant/src/main/jython/setup.py        |  3 +-
 .../gremlin/python/JythonScriptEngineSetup.java | 23 ++------
 4 files changed, 94 insertions(+), 21 deletions(-)
----------------------------------------------------------------------