On Thu, 8 Dec 2011, Andi Vajda wrote:
On Dec 8, 2011, at 9:11, Bill Janssen <jans...@parc.com> wrote:
Andi Vajda <va...@apache.org> wrote:
On Wed, 7 Dec 2011, Bill Janssen wrote:
This part of the PyLucene Makefile is still screwed up:
# Mac OS X 10.5 (32-bit Python 2.5, Java 1.5)
#PREFIX_PYTHON=/usr
#ANT=ant
#PYTHON=$(PREFIX_PYTHON)/bin/python
#JCC=$(PYTHON) -m jcc --shared
#NUM_FILES=4
The way that jcc/__init__.py is now written, there's no way to invoke it
with "-m jcc", even on Python versions where that's supposed to work.
The last line, "_jcc.CLASSPATH = CLASSPATH" will always fail, because "_jcc"
isn't imported anywhere.
I'm a bit confused about how this can or cannot work.
For whatever it's worth, with Python 2.7, running with -m jcc works
fine here.
That being said, I don't see how this statement:
_jcc.CLASSPATH = CLASSPATH
can work at all since there is nothing visibly importing _jcc.
Something puts it there, though, because it works.
Can you shed some light on this ?
... debugging a bit further ... via pdb ...
Apparently, the statement:
from _jcc import initVM
causes the _jcc symbol to appear.
That seems broken. Certainly shouldn't work that way.
This could be a side-effect of setuptools. I vaguely remember someone
saying that this didn't work with distutils only.
Yes, I could see that. setuptools plays all kinds of games to achieve
its ends, some of them broken. Thank heaven for distutils2/packaging.
What ? another 'dist' thing ?
So that leaves us with distutils 1, 2, setuptools and distribute. My
information may be incomplete, out of date or incorrect, of course :-)
If you can reproduce the failure, does adding a line before if __name__ ...:
import _jcc
solve the problem for you ?
No, I get an import error there -- apparently the relative import isn't
seen/found:
Traceback (most recent call last):
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/runpy.py",
line 95, in run_module
filename, loader, alter_sys)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/runpy.py",
line 52, in _run_module_code
mod_name, mod_fname, mod_loader)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/runpy.py",
line 32, in _run_code
exec code in run_globals
File
"/Library/Python/2.5/site-packages/JCC-2.12-py2.5-macosx-10.5-i386.egg/jcc/__init__.py",
line 31, in <module>
import _jcc
ImportError: No module named _jcc
make: *** [compile] Error 255
But using
import jcc._jcc
does work. Wonder if that works on Python 2.7, too?
Let me give this a try....
It seems that adding, before if __name__ == '__main__':
from jcc import _jcc
works just fine on 2.7 and 2.6 as well.
Speaking of which, I don't see when __name__ would be == '__main__'. I tried
various combinations with pdb and __name__ is always == 'jcc'.
If that makes sense to you as well, I can change that block to just say:
from _jcc import initVM
I'm prepared to roll an rc3 if you confirm that these changes (see
below) work for you too.
Andi..
import os, sys
if sys.platform == 'win32':
if '--find-jvm-dll' in sys.argv:
from windows import add_jvm_dll_directory_to_path
add_jvm_dll_directory_to_path()
from jcc.config import SHARED
if SHARED:
path = os.environ['Path'].split(os.pathsep)
eggpath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
if eggpath not in path:
path.insert(0, eggpath)
os.environ['Path'] = os.pathsep.join(path)
from jcc import _jcc
from _jcc import initVM
CLASSPATH=os.path.join(os.path.abspath(os.path.dirname(__file__)), "classes")
_jcc.CLASSPATH = CLASSPATH