From: <no...@so...> - 2002-04-11 08:09:20
|
Bugs item #542389, was opened at 2002-04-11 11:09 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112867&aid=542389&group_id=12867 Category: Jythonc compiler Group: None Status: Open Resolution: None Priority: 5 Submitted By: Juu (juu) Assigned to: Nobody/Anonymous (nobody) Summary: "cannot import name" and other problems Initial Comment: Here's my story - it's a long one, but I'm running into a lot of problems. I have a 80-module application, written in Jython. Some of the modules contain classes, while some are just a collection of methods. It works fine in the interpreter, but when compiled, it misbehaves. a) JythonC wouldn't compile from inner packages/directories correctly, just from root. As a workaround, I moved my main executable to root. b) I had some "code" and "sys" includes and it wouldn't properly include those modules even with --deep or --all. I placed "import code" and etc. in my main executable (compile root) and it started to work, but now complained about other includes: Java Traceback: at org.python.core.Py.ImportError(Py.java:180) at org.python.core.imp.importFromAs (imp.java:593) at TR$_PyInner.main$1(TR.java:36) at TR$_PyInner.call_function(TR.java:28) at org.python.core.PyTableCode.call (PyTableCode.java:198) at org.python.core.PyCode.call(PyCode.java:13) at org.python.core.imp.createFromCode (imp.java:165) at org.python.core.Py.runMain(Py.java:818) at TR.main(TR.java:54) Traceback (innermost last): File "C:\python\TR.py", line 0, in main ImportError: cannot import name Log c) I finally got it to work by including around 20 includes in my main file. I also made sure that modules in directory "m" never do "from m.SomeClass import SomeClass", but always "from SomeClass import SomeClass". This seemed to help with all the "missing module" problems, but not with all "cannot import name" problems. d) For example, I cannot use my other compiled classes directly: C:\python>run_custom_from_jar.bat juudb.DbResultSet C:\python>java - Dpython.path=C:\programming\jython\lib -c p C:\programming\jython\jython.jar;tr.jar;C:\programming\ java\lib\interclien t.jar juudb.DbResultSet Java Traceback: at org.python.core.Py.ImportError(Py.java:180) at org.python.core.imp.importFromAs (imp.java:593) at juudb.DbResultSet$_PyInner.main$9 (DbResultSet.java:200) at juudb.DbResultSet$_PyInner.call_function (DbResultSet.java:64) at org.python.core.PyTableCode.call (PyTableCode.java:198) at org.python.core.PyCode.call(PyCode.java:13) at org.python.core.imp.createFromCode (imp.java:165) at org.python.core.Py.runMain(Py.java:818) at juudb.DbResultSet.main(DbResultSet.java:217) Traceback (innermost last): File "C:\python\juudb\DbResultSet.py", line 0, in main ImportError: cannot import name LowerDict ------- from java.lang import StringBuffer from juulib.LowerDict import LowerDict from juulib import Log from javax.xml.parsers import DocumentBuilderFactory class DbResultSet: ... more code here ... ------- On the other hand, the class it complains about can be used just fine: C:\python>run_custom_from_jar.bat juulib.LowerDict C:\python>java - Dpython.path=C:\programming\jython\lib -cp C:\programming\jython\jython.jar;tr.jar;C:\programming\ java\lib\interclient.jar juulib.LowerDict -------------- class LowerDict: __vdict = None __vdict_name = locals().keys()[0] def __init__(self, initData = {}): self.__dict__[self.__vdict_name] = {} for i in initData.keys(): self[i] = initData[i] def __getitem__(self, key): return self.__vdict[self.convert(key)] def __setitem__(self, key, value): self.__vdict[self.convert(key)] = value def __delitem__(self, key): del self.__vdict[self.convert(key)] def __setattr__(self, name, value): self.__vdict.name = value def __getattr__(self, name): # print "returning", name return getattr(self.__vdict, name) def __repr__(self): return repr(self.__vdict) def convert(self, what): if isinstance(what, type("")): return what.lower() return what def has_key(self, which): return self.__vdict.has_key(self.convert (which)) ------------ e) I tried to recreate these problems on a smaller scale. I have included the relevant files and have recreated 2 problems for which I see workarounds - the "only compile root classes" (point a) and "misses a module import" (partial points b and c). I haven't recreated that "cannot import name" problem on a smaller scale, but perhaps my description helps anyway. I'm even starting to think that perhaps there's some limit to the depth or width of imports that I'm running into or something. Please let me know if there is anything else I can do to help replicate this. Perhaps I'm simply doing something wrong? ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=112867&aid=542389&group_id=12867 |