2 messages in com.perforce.p4python[p4python] P4Python build on Mac Os 1...
FromSent OnAttachments
Wilken Rivera04 Apr 2008 08:10 
Sven Erik Knop04 Apr 2008 09:15 
Subject:[p4python] P4Python build on Mac Os 10.5 Intel
From:Sven Erik Knop (skn@perforce.com)
Date:04/04/2008 09:15:55 AM
List:com.perforce.p4python

Hi Wilken,

I assume you are using the P4Python module from the Perforce public depot. You should try to use the officially supported version of P4Python from the Perforce website, which you can find here:

http://www.perforce.com/perforce/loadsupp.html#api

The problem with the line you cannot compile is that it is not 64 bit clean. Py_ssize_t is an int on 32 bit architectures, but a long on 64 bit architectures. You can simply replace the definition of the parameter from

int *

to

Py_ssize_t*

to solve the compilation problem - or, use the officially supported version.

We have tested the official P4Python 2007.3 on Mac OS and it compiles and tests without any problems. You will need the P4API 2007.3 to compile, but you can download this from the Perforce website as well.

Kind regards

Sven Erik

Wilken Rivera wrote:

Hello,

I have been trying to build P4Python on a Intel Core Duo machine running Mas Os 10.5 with the default install of python 2.5.

After downloading the p4api 2007-2 and the latest p4python 1-1 I proceeded to follow the build instructions. Which returned the following two errors on compilation:

P4Clientmodule.cc:344: error: invalid conversion from ?int*? to ?Py_ssize_t*? P4Clientmodule.cc:344: error: initializing argument 2 of ?int PyDict_Next(PyObject*, Py_ssize_t*, PyObject**, PyObject**)?

lipo: can't figure out the architecture type of: /var/folders/ej/ejOGnR1WGCG65nykTZiwDU+++TI/-Tmp-//ccMkcDFQ.out error: command 'gcc' failed with exit status 1

So looking into the output generated by "python setup.py build" I noticed that -arch was being passed two times, -arch ppc and -arch i386, to gcc so I decided to try and run the gcc command manually with only the -arch i386 flag.

gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Ip4api-2007-2 -Ip4api-2007-2/include/p4 -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c P4Clientmodule.cc -o build/temp.macosx-10.3-i386-2.5/P4Clientmodule.o -DOS_DARWIN -DP4_API_VER=2007.2

This seemed to address the "can't figure out the architecture" and failed with "invalid conversion from ?int*? to ?Py_ssize_t*?".

So to address that error I opened the P4Clientmodule.cc source file and changed line 342 from "int pos = 0;" to "Py_ssize_t pos = 0;"

I then tried another manual build via gcc with the command line listed above. This resulted in a successful build.

After the manual build I ran "python setup.py install" and the installation completed as expected.

I am now able to use the p4 module in python.

I would like to know if my changes are legitimate and if my P4 module will work as expected.

Thank you in advance for your help.

Wilken Rivera