Title: Python modules defined with an that are precompiled in a jar do not import.
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.2
Status: pending Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: colinhevans, fwierzbicki, jeff.allen
Priority: low Keywords:

Created on 2008-07-31.17:42:00 by colinhevans, last changed 2018-03-21.21:06:04 by jeff.allen.

File name Uploaded Description Edit Remove jeff.allen, 2018-03-21.21:06:02 Demonstration working in 2.7
msg3375 (view) Author: Colin Evans (colinhevans) Date: 2008-07-31.17:48:47
Here's the setup:

test.jar contents:


>>> import ttt
<single-top>: ttt= 
*sys-package-mgr*: reading cache, '/Users/colin/dev/test.jar'
import: trying source ./ttt
import: trying precompiled with no source./ttt$py.class
import: trying source entry: ttt/ from jar/zip file
import: trying precompiled entry ttt/__init__$py.class from jar/zip file
>>> dir(ttt)
<single-top>: ttt dir 
['__doc__', '__loader__', '__name__', '__path__']

Note - no error message is returned, but the contents of are
not actually imported.  If I omit the __init__$py.class file from the
jar file and only include the source, the module imports correctly.
msg11835 (view) Author: Jeff Allen (jeff.allen) Date: 2018-03-21.21:06:02
I think this works in 2.7.2a1, but have I misunderstood (anyone)?

With the set-up, where each file essentially just prints __file__:

PS iss1090> tree /f /a
Folder PATH listing for volume SYSTEM
Volume serial number is 6076-CBCE

and the attached program, I can create a JAR and access it as I think is intended:

PS iss1090> jython
('jar-source', ['sub'], ['', ''])
('jar-source\\sub', [], ['', ''])
compiling jar-source -> mylib :
compiling jar-source\sub -> mylib :
File Name                                             Modified             Size
mylib/tell$py.class                            2018-03-21 20:31:58         2455
mylib/tell2$py.class                           2018-03-21 20:31:58         2458
mylib/sub/__init__$py.class                    2018-03-21 20:31:58         2461
mylib/sub/tell3$py.class                       2018-03-21 20:31:58         2470
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\tell$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\tell2$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\sub\\__init__$py.class'
Executing module from 'C:\\Users...\\iss1090\\jartest.jar\\mylib\\sub\\tell3$py.class'

This is identical to CPython apart from the full pathname and s/.pyc/$py.class/*. The JAR made has the structure:

PS iss1090> jar -tf jartest.jar

So this looks good to me in 2.7, and I think we will not fix any earlier version. Close belatedly?
Date User Action Args
2018-03-21 21:06:04jeff.allensetstatus: open -> pending
files: +
versions: + Jython 2.7
nosy: + jeff.allen
messages: + msg11835
resolution: fixed
2013-02-26 17:15:53fwierzbickisetnosy: + fwierzbicki
versions: + Jython 2.2, - 2.2.1rc1
2008-12-17 19:46:32fwierzbickisetpriority: low
2008-07-31 17:48:47colinhevanssetmessages: + msg3375
2008-07-31 17:42:00colinhevanscreate