From: Kevin M. <kev...@er...> - 2001-09-20 08:00:44
|
Hi, thanks for the input. However, ... test1.py: --------- class gofaster: def __init__(self): print "Zoom" gofaster() Compile: -------- # jythonc -a -p com.ericsson.test1 -j test1.jar test1.py Test: ----- # java -cp test1.jar com.ericsson.test1.test1 Zoom test2.py: --------- import sys sys.add_package("com.ericcson.test1") from com.ericsson.test1 import test1 Compile: -------- # jythonc -a -p com.ericsson.test2 -j test2.jar test2.py MyManifest.txt: -------------- Class-Path: test1.jar Update Jar file: ---------------- # jar -umf MyManifest test2.jar Test: ----- # java -jar test2.jar Java Traceback: at org.python.core.Py.ImportError(Py.java:180) at org.python.core.imp.dottedFind(imp.java:414) at org.python.core.imp.importName(imp.java:436) at org.python.core.imp.importName(imp.java:509) at org.python.core.ImportFunction.load(__builtin__.java:967) at org.python.core.ImportFunction.__call__(__builtin__.java:961) at org.python.core.PyObject.__call__(PyObject.java:250) at org.python.core.__builtin__.__import__(__builtin__.java:921) at org.python.core.imp.importOne(imp.java:518) at com.ericsson.test1.test1$_PyInner.main$1(test1.java:36) at com.ericsson.test1.test1$_PyInner.call_function(test1.java:28) at org.python.core.PyTableCode.call(PyTableCode.java:155) at org.python.core.imp.createFromCode(imp.java:157) at org.python.core.Py.runMain(Py.java:798) at com.ericsson.test1.test1.main(test1.java:54) Traceback (innermost last): File "/home/qkename/jwork/extdirstest/test2.py", line 0, in main ImportError: No module named ericsson Result: ------- The sys.add_package() workaround doesn't work. I wonder how this should work since if as you say, Jython doesn't read the Class-Path field, then it won't be able to find the jar file in the first place. As for the patch. How should this be applied? I did not see any instructions on the webpage about how to do this. Does the workaround above have to be used together with the patch? Much appreciated, Kevin > Hi > > [kevin.mcnamee] > > test2.py: > > --------- > > from com.ericsson.test1 import * > > test1.main([""]) # <--- C style??? > > test1 has no main function defined, OTOH > the top level statements of a module are executed on importing > so no need for that. > > from.com.ericsson.test1 import * > > import * from a java package should not be used in production code, > in particular its support through jythonc is quite fragile, > and does not work with the 1st workaround proposed in the previous > message , I don't rembember for the patch ... > > so a possible test2 is: > > import sys > sys.add_package("com.ericcson.test1") > from com.ericsson.test1 import test1 > # ^ executes the top-level stmts in test1.py > > regards. > > > > > _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 |