Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Pig >> mail # dev >> informational: getting jython-2.7-b1 to work


Copy link to this message
-
informational: getting jython-2.7-b1 to work
Hello all,

This is some information that might useful in any future work to
incorporate jython 2.7 once it is out of beta. Jython-2.7b1 deprecates
func_code. I've gotten pig 11.1 to work with jython-2.7b1 by making the
changes listed in the svn diff below. I've run a number of my pig scripts
with this build, and haven't encountered any problems so far.

compile-sources:
       [javac] Compiling 7 source files to
/home/cflynn/pig-release-0.11.1/build/classes
       [javac]
/home/cflynn/pig-release-0.11.1/src/org/apache/pig/scripting/jython/JythonFunction.java:57:
cannot find symbol
       [javac] symbol  : variable func_code
       [javac] location: class org.python.core.PyFunction
       [javac]             num_parameters = ((PyBaseCode)
f.func_code).co_argcount;
       [javac]                                             ^
       [javac]
/home/cflynn/pig-release-0.11.1/src/org/apache/pig/scripting/jython/JythonFunction.java:108:
cannot find symbol
       [javac] symbol  : variable func_code
       [javac] location: class org.python.core.PyFunction
       [javac]             if (tuple == null || (num_parameters == 0 &&
!((PyTableCode)function.func_code).varargs)) {
       [javac]
                    ^
       [javac] 2 errors
BUILD FAILED
cflynn@coyote:~pig-release-0.11.1$ svn diff
Index: src/org/apache/pig/scripting/jython/JythonFunction.java
==================================================================--- src/org/apache/pig/scripting/jython/JythonFunction.java     (revision
1497765)
+++ src/org/apache/pig/scripting/jython/JythonFunction.java     (working
copy)
@@ -54,7 +54,7 @@
         try {
             f = JythonScriptEngine.getFunction(filename, functionName);
             this.function = f;
-            num_parameters = ((PyBaseCode) f.func_code).co_argcount;
+            num_parameters = ((PyBaseCode) f.__code__).co_argcount;
             PyObject outputSchemaDef f.__findattr__("outputSchema".intern());
             if (outputSchemaDef != null) {
                 this.schema Utils.getSchemaFromString(outputSchemaDef.toString());
@@ -105,7 +105,7 @@
     @Override
     public Object exec(Tuple tuple) throws IOException {
         try {
-            if (tuple == null || (num_parameters == 0 &&
!((PyTableCode)function.func_code).varargs)) {
+            if (tuple == null || (num_parameters == 0 &&
!((PyTableCode)function.__code__).varargs)) {
                 // ignore input tuple
                 PyObject out = function.__call__();
                 return JythonUtils.pythonToPig(out);
Index: ivy/libraries.properties
==================================================================--- ivy/libraries.properties    (revision 1497765)
+++ ivy/libraries.properties    (working copy)
@@ -61,7 +61,7 @@
 json-simple.version=1.1
 junit.version=4.11
 jruby.version=1.6.7
-jython.version=2.5.3
+jython.version=2.7-b1
 rhino.version=1.7R2
 antlr.version=3.4
 stringtemplate.version=4.0.4
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB