On Fri, 4 Sep 2009, Ralph Seward wrote:

I wanted to confirm this before I replied. Here is what I have
discovered re: the platform detection problem.

If I go to http://python.org/download/ and get the Python 2.6.2 Mac
Installer Disk Image
(http://python.org/ftp/python/2.6.2/python-2.6.2-macosx2009-04-16.dmg),
then open the installer, it installs Python 2.6 with no apparent
problem.

However, it also creates a Makefile at
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/config/Makefile
wherein the following line is included:
MACOSX_DEPLOYMENT_TARGET=10.3

As it turns out, Python distutils.sysconfig.py calls a function,
parse_makefile() that pulls most of its values from this makefile. So,
the end result is that in Python:
from distutils.sysconfig import get_config_vars
cfgvars = get_config_vars()
cfgvars['MACOSX_DEPLOYMENT_TARGET']
'10.3'

and:
from distutils.util import get_platform
get_platform()
'macosx-10.3-fat'

I am at a loss to explain who is at fault here but the .dmg is a prime
suspect. Nonetheless a really simple solution is to edit the Makefile
and change the 10.3 to 10.5 (or whatever is appropriate for your
system) as in:
MACOSX_DEPLOYMENT_TARGET=10.5

now:
get_platform()
'macosx-10.5-fat'

Yes, that makes sense. A patch could be written that tests for this environment variable and tunes the use of -Wl,-rpath accordingly.

This solves the first problem, but make still hangs, now with the following:

g++ -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -g
-bundle -undefined dynamic_lookup
build/temp.macosx-10.5-fat-2.6/build/_lucene/__init__.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/__wrap01__.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/__wrap02__.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/__wrap03__.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/functions.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/JArray.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/JObject.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/lucene.o
build/temp.macosx-10.5-fat-2.6/build/_lucene/types.o

-L/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
-ljcc -o build/lib.macosx-10.5-fat-2.6/lucene/_lucene.so -framework
JavaVM -Wl,-S -Wl,-rpath
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
ld: library not found for -ljcc

Note the value of the -L flag. This is where the linker expects libjcc.dylib to be, not in your build directory. After building JCC, did you install it ?
as with:
  $ python setup.py build install

You also don't need to set DYLD_LIBRARY_PATH anymore (which is used for running, not by ld) since you're able to use -Wl,-rpath.

Andi..

collect2: ld returned 1 exit status
ld: library not found for -ljcc
collect2: ld returned 1 exit status
lipo: can't open input file:
/var/folders/7r/7r4PlyAYE0CN5MeqK98dBk+++TQ/-Tmp-//ccexpZmi.out (No
such file or directory)
error: command 'g++' failed with exit status 1
make: *** [compile] Error 1

I added:
export DYLD_LIBRARY_PATH=/Users/ralph/pylucene/jcc/build/lib.macosx-10.5-fat-2.6
to my .profile as this is where libjcc.dylib resides, but this did not
seem to fix the problem.

So, any suggestions?

Ralph

j...@apache.org> wrote:

On Wed, 2 Sep 2009, Ralph Seward wrote:

In Python:

from distutils.util import get_platform
get_platform()

'macosx-10.3-fat'

Apart from the platform detection problem which comes from your setup, there
is a bug in JCC where it adds -Wl,-rpath to the link args without checking
first that the target platform is at least Mac OS X 10.5.
This is around line 1451 in JCC's python.py file.

If you have the logic to check the target OS version, please send in a patch
that fixes this.

Note that if you link the JCC executables without -Wl,-rpath, you'll have to
then set DYLD_LIBRARY_PATH so that libjcc.dylib can be found.
Adding code to emit a warning to that effect in that patch would help too.

Thanks !

Andi..


Ah ha...

On Wed, Sep 2, 2009 at 2:56 PM, Ralph Seward<rj.sew...@gmail.com> wrote:

Hey Andi,

I am attempting to setup PyLucene on a Mac with OS X 10.5 (Leopard)
with Python 2.6 and I am encountering a small problem. I Googled
around and I saw your comment on something similar at
http://www.mail-archive.com/pylucene-...@osafoundation.org/msg02516.html
and I wondered if this was ever sorted out.

I do this:
svn co http://svn.apache.org/repos/asf/lucene/pylucene/trunk pylucene

Checked out revision 810649.

cd pylucene/jcc/
python setup.py build

at which point I get:
running build
running build_py
creating build/lib.macosx-10.3-fat-2.6
creating build/lib.macosx-10.3-fat-2.6/jcc
etc...

which appears to be an incorrect detection of my OS.

then I do:
cd ..
nano Makefile
# Mac OS X  (Python 2.6.2, Java 1.5)
PREFIX_PYTHON=/usr/local
ANT=ant
PYTHON=$(PREFIX_PYTHON)/bin/python
JCC=$(PYTHON) -m jcc.__main__ --shared
NUM_FILES=2
... and save it ...

Then I run:
make
and it seems to be doing OK until it fails with:

ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccmnAMJQ.out (No such file or
directory)
error: command 'g++' failed with exit status 1
make: *** [compile] Error 1

which, if the OS was properly detected, I'm guessing not happen.

So, I was wondering if you had any insight as to the cause or
resolution to this problem.

Thanks in advance.

Ralph


Reply via email to