From: Andreas M. <am...@fz...> - 2004-05-07 13:46:51
|
Hello, I am looking for a solution to package the Python library files in Lib = in a JAR archive, so that they can be imported from the archive as usual.=20 I have already searched this mailing list and found an article that describes how to do this: http://www.geocrawler.com/archives/3/7017/2001/9/50/6639698/. = Unfortunately, I couldn't put this in action by myself. As described in the article, I packaged the files with javac cvf lib.jar Lib and tried to import them with import sys sys.path.append('lib.jar!Lib') import symbol and got an ImportError. I also tried other combinations (no '!Lib' = suffix in the path, no subdirectory 'Lib' in the archive, ...) without prevail.=20 Are the instructions in the article correct? How can you include the = Python library files as *.py into a JAR archive? If this cannot be done, is it possible to compile them into class files and import these from a JAR archive? The article's author states, that if precompiled, the library = files will not load from a JAR archive.=20 Regards, --=20 Andreas Mayer |
From: Oti <oh...@ya...> - 2004-05-07 16:25:06
|
[ Andreas Mayer ] > I am looking for a solution to package the Python library files in > Lib in a > JAR archive, so that they can be imported from the archive as usual. > > I have already searched this mailing list and found an article that > describes how to do this: > http://www.geocrawler.com/archives/3/7017/2001/9/50/6639698/. > Unfortunately, > I couldn't put this in action by myself. As described in the article, > I > packaged the files with > > javac cvf lib.jar Lib > > and tried to import them with > > import sys > sys.path.append('lib.jar!Lib') > import symbol > > and got an ImportError. I also tried other combinations (no '!Lib' > suffix in > the path, no subdirectory 'Lib' in the archive, ...) without prevail. > > > Are the instructions in the article correct? How can you include the > Python > library files as *.py into a JAR archive? If this cannot be done, is > it > possible to compile them into class files and import these from a JAR > archive? The article's author states, that if precompiled, the > library files > will not load from a JAR archive. Hi Andreas, please try with 'lib.jar/Lib' in sys.path (or -Dpython.path). It works for me. While debugging I verified that corresponding *$py.class files are read from the .jar file, if present. BUT I did not verify that no compile was performed. Best wishes, Oti. |