Issue2143

classification
Title: site-packages support in standalone jar
Type: rfe Severity: major
Components: Core Versions: Jython 2.7
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: nonameentername, zyasoft
Priority: high Keywords: patch

Created on 2014-05-13.22:09:47 by nonameentername, last changed 2014-05-27.16:38:31 by zyasoft.

Files
File name Uploaded Description Edit Remove
patch.diff nonameentername, 2014-05-20.19:55:25
Messages
msg8399 (view) Author: werner (nonameentername) Date: 2014-05-13.22:09:47
site-packages inside a jar does not get imported by jython.

workaround:

import site
from org.python.util import jython
jar_location = jython().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
import site
import os.path
site.addsitedir(os.path.join(jar_location, 'Lib/site-packages'))
msg8400 (view) Author: Jim Baker (zyasoft) Date: 2014-05-13.22:11:35
Thanks for the workaround, this is very helpful for figuring out how to ensure this logic is always available in standalone mode.
msg8454 (view) Author: werner (nonameentername) Date: 2014-05-20.19:55:25
Add site-packages to the sys.path to allow finding site-packages inside a standalone jar
msg8532 (view) Author: Jim Baker (zyasoft) Date: 2014-05-22.01:07:12
More discussion in the duplicate bug #2149
msg8576 (view) Author: Jim Baker (zyasoft) Date: 2014-05-27.16:38:30
One idea I have here is that the built-in open function should be able to take a jar URL to the file in question and this can be resolved automagically against a jar that is on sys.path (including via __classpath__)

This change should then work transparently with normal search path resolution.

It should be fairly easy to test this idea out, given that we can directly take the result of getResourceAsStream and pass it to open.
History
Date User Action Args
2014-05-27 16:38:31zyasoftsetmessages: + msg8576
2014-05-22 01:07:12zyasoftsetmessages: + msg8532
2014-05-20 19:55:25nonameenternamesetfiles: + patch.diff
keywords: + patch
messages: + msg8454
2014-05-13 22:11:35zyasoftsetpriority: high
assignee: zyasoft
resolution: accepted
messages: + msg8400
nosy: + zyasoft
2014-05-13 22:09:47nonameenternamecreate