Issue2281

classification
Title: Creating jar file from libraries
Type: behaviour Severity: normal
Components: Library Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: sergei175, zyasoft
Priority: Keywords:

Created on 2015-03-08.15:41:06 by sergei175, last changed 2015-04-11.13:24:36 by zyasoft.

Messages
msg9591 (view) Author: Sergei (sergei175) Date: 2015-03-08.15:41:05
Hello,
 
 I'm not sure is this an issue or not. But I was trying to do something obvious in Jython 2.7b4: Create a jar file "Lib.jar" from the directory "Lib" with PYTHON modules, add it to class path, and run jython as: "java -cp Lib.jar:jython.jar org.python.util.jython" or similar.

It gives an error: "main Exception in thread "main" ImportError: No module named site" I was using in the past this project:
https://github.com/noskcid/Single-Jar-Jython-Further-Example/tree/master/lib

which deploys jython as 2 separate files: core and python libraries in jar file. I've founs this method is very useful: I have 2 compressed files, and I still use "*" to pick up methods of my external java libraries (which is impossible when using jython as a single jar file with python modules inside).

How can I compress "Lib" directory in a jar, and deploy Jython as 2 jar files?

I also think this should be useful option during Jython installation

best, Sergei
msg9592 (view) Author: Jim Baker (zyasoft) Date: 2015-03-09.03:51:22
Please take a look at the Clamp project, which addresses this need:
https://github.com/jythontools/clamp

A related bug is http://bugs.jython.org/issue2143
msg9593 (view) Author: Sergei (sergei175) Date: 2015-03-09.16:02:31
Hello, Jim. thanks.

I've tried to create jython-single.jar using the clamp. 
I did this:

/jython2.7b4/jython setup.py install
/jython2.7b4/jython setup.py clamp
/jython2.7b4/jython setup.py singlejar

Then, in /jython2.7b4/bin directory:

java -jar jython-single.jar

This still gives me the same error:

*sys-package-mgr*: processing new jar, '/jython2.7b4/bin/jython-single.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/resources.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/rt.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/jsse.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/jce.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/charsets.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/jfr.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/sunec.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/zipfs.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/dnsns.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/localedata.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/sunpkcs11.jar'
*sys-package-mgr*: processing new jar, '/opt/jdk1.7.0_75/jre/lib/ext/sunjce_provider.jar'
Exception in thread "main" ImportError: No module named site

Also, java -jar clamp-0.4-single.jar, gives the same error

best, Sergei
msg9595 (view) Author: Jim Baker (zyasoft) Date: 2015-03-09.17:43:18
Not being able to import site.py is most likely related to a problem that was recently observed on jython-dev (http://sourceforge.net/p/jython/mailman/message/33546082/). The cause of this problem that $py.class files are not being created for the Lib/ directory when compiled under ant targets that don't include building the development version, such as the standalone jar.

Note that fixing #2143 also removes this issue, but has been postponed to 2.7.1.

The workaround for the moment is to build Jython from ant (https://wiki.python.org/jython/JythonDeveloperGuide), but we will have this fixed for the release candidate. See #2282
msg9750 (view) Author: Jim Baker (zyasoft) Date: 2015-04-02.20:42:07
Should be fixed now with the recent changes, specifically for #2282 and #2283
History
Date User Action Args
2015-04-11 13:24:36zyasoftsetstatus: pending -> closed
2015-04-02 20:42:07zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg9750
2015-03-09 17:43:18zyasoftsetmessages: + msg9595
2015-03-09 16:02:32sergei175setmessages: + msg9593
2015-03-09 03:51:22zyasoftsetnosy: + zyasoft
messages: + msg9592
2015-03-08 15:41:06sergei175create