Tackling setup.py - A bug??

R

rh0dium

Hi Folks,

I use p4python for all of my perforce and python related needs. I'm
on a Mac (OSX 10.4). p4python relies on a perforce provided API which
gets compiled when I run the setup.py. The setup.py by default does
not support macs so I figured what better way to spend a night than to
figure out how to add in the neccesary hooks for mac support...

So the problem I am seeing is when I do an import of the module I get
the following error:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.5/site-packages/p4.py", line 17, in
<module>
import P4Client
ImportError: dlopen(/usr/local/lib/python2.5/site-packages/
P4Client.so, 2): Symbol not found: _CFStringCompare
Referenced from: /usr/local/lib/python2.5/site-packages/P4Client.so
Expected in: dynamic lookup

First I figured out how to compile the thing at the command line so it
worked. ( No the default did not - I tried various derivations on it
to no avail. However at long last I was able to manually compile and
link this so it did work. To get it to compile I used the following
two lines (compile / link)
> g++ -c -o build/temp.macosx-10.3-ppc-2.5/P4Clientmodule.o -
DCASE_INSENSITIVE \
-fpascal-strings -isysroot/Developer/SDKs/MacOSX10.4u.sdk -arch
ppc -DCASE_INSENSITIVE \
-O2 -DOS_MACOSX -DOS_MACOSX104 -DOS_MACOSXPPC -DOS_MACOSX104PPC
\
-Ip4api6.1 -I/usr/local/include/python2.5 P4Clientmodule.cc
# Followed by linking using:
> g++ -bundle -undefined dynamic_lookup -Wl,-syslibroot,/
Developer/SDKs/MacOSX10.4u.sdk \
-arch ppc \
-o build/lib.macosx-10.3-ppc-2.5/P4Client.so build/
temp.macosx-10.3-ppc-2.5/P4Clientmodule.o\
-Lp4api6.1 p4api6.1/libclient.a p4api6.1/librpc.a p4api6.1/
libsupp.a -framework Carbon

And this followed by an setup.py install seemed to work just fine. Ok
so now I need to backport these options into setup.py. Here is what I
came up with..

elif os.name == "posix":
setup(name=NAME,
version=VERSION,
description=DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
maintainer=MAINTAINER,
maintainer_email=MAINTAINER_EMAIL,
license=LICENSE,
url=URL,
keywords=KEYWORDS,
classifiers = filter(None, classifiers.split("\n")),
long_description = "\n".join(doclines[2:]),
py_modules=PY_MODULES,
ext_modules=[Extension("P4Client", ["P4Clientmodule.cc"],
include_dirs=[p4_api_dir],
library_dirs=[p4_api_dir],
libraries=["client", "rpc", "supp"], #
P4API libs
extra_compile_args=["-DCASE_INSENSITIVE",
"-fpascal-strings",
"-isysroot/Developer/
SDKs/MacOSX10.4u.sdk",
"-DOS_MACOSX", "-
DOS_MACOSX104",
"-DOS_MACOSXPPC", "-
DOS_MACOSX104PPC" ,"-D%s" % p4_api_ver],
extra_link_args=[ "-Wl,-syslibroot,/
Developer/SDKs/MacOSX10.4u.sdk", "-arch ppc", "-framework Carbon" ],
)])

But low and behold it didn't work... In the course of debugging I
found that the compile works. The linking appears to be a problem.
In the link stage I see the command which is being run looks very
similar to my command

g++ -bundle -undefined dynamic_lookup build/temp.macosx-10.3-ppc-2.5/
P4Clientmodule.o \
-Lp4api6.1 -lclient -lrpc -lsupp -o build/lib.macosx-10.3-ppc-2.5/
P4Client.so \
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -framework
Carbon

Not quite the same but close enough. HERE is where the bug shows
up........
If I rerun this same EXACT command at the command line - followed by a
setup.py install it works.

Can someone with a larger python brain than mine please help me figure
this out? It's bugging the crap out fo me...

ARGGGGHHHHH!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top