From: Dave K. <dku...@re...> - 2007-09-25 18:38:37
|
I have some questions about the use of jar files with jython. I'm using jython 2.2.1rc1. Suppose I copy jython.jar: $ cp ../jython2.2.1rc1/jython.jar application.jar Suppose testfuture.py contains: # testfuture.py #from __future__ import generators import sys print 'sys.version:', sys.version print 'sys.path:', sys.path Then I run: $ java -jar application.jar testfuture.py *sys-package-mgr*: can't create package cache dir, '/home/dkuhlman/a1/ Python/Jython/Test/application.jar/cachedir/packages' sys.version: 2.2.1rc1 sys.path: ['', '/home/dkuhlman/a1/Python/Jython/Test/application.jar/Lib', '__classpath__'] Good. Now I uncomment the import from __future__, then run it again and I see: $ java -jar application.jar testfuture.py *sys-package-mgr*: can't create package cache dir, '/home/dkuhlman/a1/ Python/Jython/Test/application.jar/cachedir/packages' Traceback (innermost last): File "testfuture.py", line 2, in ? ImportError: no module named __future__ And, if I rename testfuture.py to __run__.py and add it at the root of application.jar, then run jython instead of java, I see the following: ~/a1/Python/Jython/Test [145] jython -jar application.jar sys.version: 2.2.1rc1 sys.path: ['', '/home/dkuhlman/a1/Python/Jython/jython2.2.1rc1/Lib', '__classpath__'] The __future__ error has gone away. But, sys.path is now wrong. It should contain '/home/dkuhlman/a1/Python/Jython/Test/application.jar/Lib' as before, shouldn't it? It seems to me that there is a bug there. But, I'm unsure, because I do not know what java/jython is supposed to do or is trying to do. I've come across the above in trying to use Greg Moore's article on distributing Jython applications at: http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts Am I trying to do something that I should not be doing? If so, how do I deploy an application in a jar file? Dave |