Issue1747126
Created on 2007-07-03.13:37:13 by marvingreenberg, last changed 2008-12-30.08:23:43 by cgroves.
| Messages | |||
|---|---|---|---|
| msg1702 (view) | Author: marvin greenberg (marvingreenberg) | Date: 2007-07-03.13:37:13 | |
A simple python package with one module is created:
/Users/mgreenberg/myDir/tena/__init__.py
/Users/mgreenberg/myDir/tena/foo.py
The first listing shows that although /Users/mgreenberg/myDir is in the CLASSPATH, the module tena is not found. The second to last line of the trace seems to indicate that jython is looking in the classpath:
import: trying source __classpath__/tena
But it does not find it. If /Users/mgreenberg/myDir
is explicitly added to the python.path, everything works.
------------ /Users/mgreenberg/myDir is in CLASSPATH, but tena.foo is not found on import -----------
tamale:~/inf/jython mgreenberg$ java -Djython.cachedir=/tmp/cachedir -Dpython.home=/tmp/.install/jython-v2.2.0.rc1 -classpath '/tmp/.install/jython-v2.2.0.rc1/jython.jar:/Users/mgreenberg/myDir' org.python.util.jython -v -v
<snip>
Jython 2.2rc1 on java1.5.0_07
<snip>
Type "copyright", "credits" or "license" for more information.
<file-top>:
>>> import sys,os
<single-top>: os= sys=
>>> sys.path
<single-top>: sys
['', '/tmp/.install/jython-v2.2.0.rc1/Lib', '__classpath__']
>>> import java.lang.System
<single-top>: java=
>>> java.lang.System.getProperty('java.class.path')
<single-top>: java
'/tmp/.install/jython-v2.2.0.rc1/jython.jar:/Users/mgreenberg/myDir:/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Classes/.compatibility/14compatibility.jar'
>>> import tena.foo
<single-top>: tena=
import: trying source /Users/mgreenberg/inf/jython/tena
import: trying precompiled with no source/Users/mgreenberg/inf/jython/tena$py.class
import: trying source /tmp/.install/jython-v2.2.0.rc1/Lib/tena
import: trying precompiled with no source/tmp/.install/jython-v2.2.0.rc1/Lib/tena$py.class
import: trying tena in packagemanager for path None
import: trying tena as java class in syspath loader
import: trying source __classpath__/tena
import: trying precompiled with no source__classpath__/tena$py.class
Traceback (innermost last):
File "<console>", line 1, in ?
ImportError: no module named tena
-------------- When /Users/mgreenberg/myDir explicitly added to python.path, module tena.foo is located ------
java -Dpython.path='/Users/mgreenberg/myDir' -Djython.cachedir=/tmp/cachedir -Dpython.home=/tmp/.install/jython-v2.2.0.rc1 -classpath '/tmp/.install/jython-v2.2.0.rc1/jython.jar:/Users/mgreenberg/myDir' org.python.util.jython -v -v
<snip>
Jython 2.2rc1 on java1.5.0_07
<snip>
Type "copyright", "credits" or "license" for more information.
<file-top>:
>>> import sys,os
<single-top>: os= sys=
>>> sys.path
<single-top>: sys
['', '/tmp/.install/jython-v2.2.0.rc1/Lib', '/Users/mgreenberg/myDir', '__classpath__']
>>> import tena.foo
<single-top>: tena=
import: trying source /Users/mgreenberg/inf/jython/tena
import: trying precompiled with no source/Users/mgreenberg/inf/jython/tena$py.class
import: trying source /tmp/.install/jython-v2.2.0.rc1/Lib/tena
import: trying precompiled with no source/tmp/.install/jython-v2.2.0.rc1/Lib/tena$py.class
import: trying precompiled /Users/mgreenberg/myDir/tena/__init__$py.class
import: 'tena' as /Users/mgreenberg/myDir/tena/__init__.py
import: trying source /Users/mgreenberg/myDir/tena/foo
import: trying precompiled /Users/mgreenberg/myDir/tena/foo$py.class
import: 'tena.foo' as /Users/mgreenberg/myDir/tena/foo.py
>>>
|
|||
| msg1703 (view) | Author: Charlie Groves (cgroves) | Date: 2007-07-15.04:14:40 | |
I thought Jython used to do this, but it turns out it never loaded modules directly from the classpath. The __classpath__ is just for the java loading mechanism. I was going to take care of it for 2.2rc2 when I thought it was a bug, but since it's actually a new feature I'm going to leave it for the future. I definitely plan on adding it though. |
|||
| msg1704 (view) | Author: Samuele Pedroni (pedronis) | Date: 2007-07-18.17:34:47 | |
Indeed this is a new feature, it should be discussed on jython-dev first. One issue is that java loading sematincs always do the union of parallel package directories, python considers only the first hit directory. |
|||
| msg1705 (view) | Author: Charlie Groves (cgroves) | Date: 2007-07-23.05:11:30 | |
See http://www.nabble.com/difference-in-semantics-for-handling-parallel-directories-in-Java-and-Python-tf4119356.html for that conversation. |
|||
| msg3995 (view) | Author: Charlie Groves (cgroves) | Date: 2008-12-30.08:23:43 | |
Fixed in r5816. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2008-12-30 08:23:43 | cgroves | set | messages: + msg3995 |
| 2008-12-30 08:23:37 | cgroves | set | messages: - msg3990 |
| 2008-12-30 08:16:53 | cgroves | set | status: open -> closed resolution: fixed messages: + msg3990 |
| 2007-07-03 13:37:13 | marvingreenberg | create | |
Supported by Python Software Foundation,
Powered by Roundup