[p4python] P4Python build on Mac Os 10.5 Intel - SOLVED

Daryl Spitzer daryl.spitzer at gmail.com
Fri Oct 3 10:41:25 PDT 2008

Steven (or anyone with experience or interest in building P4Python for
Mac OS X),

I now have an Intel Mac (running Mac OS X 10.5.5) and I'm at a new job
where I'd like to get P4Python working on Mac OS X.

I followed your instructions but I got the following (when I tried
`python setup.py build`):

$ python setup.py build
API Release 2007.3
running build
running build_py
creating build
creating build/lib.darwin-9.5.0-i386-2.4
copying P4.py -> build/lib.darwin-9.5.0-i386-2.4
running build_ext
building 'P4API' extension
creating build/temp.darwin-9.5.0-i386-2.4
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp
-mno-fused-madd -DNDEBUG -g -O3 -Wall -Wstrict-prototypes
-DID_OS="MACOSX104X86" -DID_REL="2007.3" -DID_PATCH="151416"
-DID_API="2007.3" -DID_Y="2008" -DID_M="04" -DID_D="09"
-I./p4api-2007.3.143793 -I./p4api-2007.3.143793/include/p4
-I/build/toolchain/mac32/python-2.4.3/include/python2.4 -c P4API.cpp
-o build/temp.darwin-9.5.0-i386-2.4/P4API.o -DOS_MACOSX -DOS_MACOSX104
cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for C/ObjC but not for C++
P4API.cpp: In function ‘int P4Adapter_init(P4Adapter*, PyObject*,
P4API.cpp:105: error: ‘Py_ssize_t’ was not declared in this scope
P4API.cpp:105: error: expected `;' before ‘pos’
P4API.cpp:107: error: ‘pos’ was not declared in this scope
P4API.cpp: In function ‘PyObject* P4Adapter_run(P4Adapter*, PyObject*)’:
P4API.cpp:177: error: ‘Py_ssize_t’ was not declared in this scope
P4API.cpp:177: error: expected `;' before ‘i’
P4API.cpp:177: error: ‘i’ was not declared in this scope
error: command 'gcc' failed with exit status 1

I got these same errors both before and after I added 'extra_link_args
= ["-framework", "Carbon"]' to setup.py as described in

`which gcc` returns /usr/bin/gcc and `gcc -v` returns:
Using built-in specs.
Target: i686-apple-darwin9
Configured with: /var/tmp/gcc/gcc-5465~16/src/configure
--disable-checking -enable-werror --prefix=/usr --mandir=/share/man
--with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib
--build=i686-apple-darwin9 --with-arch=apple --with-tune=generic
--host=i686-apple-darwin9 --target=i686-apple-darwin9
Thread model: posix
gcc version 4.0.1 (Apple Inc. build 5465)

`python -V` returns Python 2.4.3.

Do you know what's wrong?


On Thu, May 1, 2008 at 2:16 PM,  <Steven.Klass at smsc.com> wrote:
> Hi all,
>         I figured I'd pass along how I was able to compile the latest p4api
> (p4api-2007.3.143793) with the Perforce supported p4python (P4Python-2007.3)
> on Mac OSX 10.5 Intel hardware.  This should work with PPC too but a minor
> tweak (arch) will need to be done.
> So basically here is the problem with compiling on mac OS X.  By default
> python wants to compile universal binaries. I got an email from support that
> warned me this would be a problem.
> Since I'm not too familiar with the inners of compiling c (interaction with
> setup.py) from within python this hack fixes it so P4Python will compile and
> work.
> Normally if you left it alone and ran setup.py you would see the following
> errors upon trying to import P4..
>     Traceback (most recent call last):
>       File "p4test.py", line 6, in <module>
>         import P4
>       File "build/lib.macosx-10.5-i386-2.5/P4.py", line 185, in <module>
>         import P4API
>     ImportError: dlopen(build/lib.macosx-10.5-i386-2.5/P4API.so, 2): Symbol
> not found: ___CFConstantStringClassReference
>       Referenced from:
> /private/tmp/p4/P4Python-2007.3/build/lib.macosx-10.5-i386-2.5/P4API.so
>       Expected in: dynamic lookup
> Corrections made - see the script..
> As you can see arch has been reduced to only look at intel and we removed
> -Wstrict-prototypes as this isn't used for C++
> When you get down to the linking stage things changed.  In addition to
> removing the universal capability we also
> had to put in the Carbon frameworks.
> This script will replace 'python setup.py build'.  I would suggest the
> following process to get P4Python working:
> Get the API Tree and P4Perforce untar / gunzip and put the api tree into
> P4Python-2007.3 directory
>    curl
> http://filehost.perforce.com/perforce/r07.3/bin.macosx104x86/p4api.tar -o
> p4api.tar
>    curl http://filehost.perforce.com/perforce/r07.3/tools/p4python.tgz -o
> p4python.tgz
> Update the setup.cfg to point the p4_api=./p4api-2007.3.143793
> Run a baseline 'python setup.py build'  - This will create all of the
> necessary trees.
> Place this script in the P4Python directory.  Then run this script
> './make.sh'
> Run the install piece 'python setup.py install'
> Note The testharness breaks but that's primarily due to a poor testharness
> ;)
> Cheers
> ---
> Steven M. Klass
> Manager, Design Automation
> Analog/Mixed Signal Tools and Methodologies
> Phone: (480) 225-1112
> Email: steven.klass at smsc.com
> "Daryl Spitzer" <daryl.spitzer at gmail.com>
> Sent by: p4python-bounces at perforce.com
> 05/01/08 09:11 AM
> To
> p4python at perforce.com, sknop at perforce.com
> cc
> Subject
> [p4python] P4Python build on Mac Os 10.5
>  Intel&In-Reply-To=47F64500.80003 at nikondev.com
> Sven Erik,
> You wrote (in
> http://maillist.perforce.com/pipermail/p4python/2008-April/000051.html):
>> 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.
> Did you see my description of my problem in
> http://maillist.perforce.com/pipermail/p4python/2008-April/000052.html?  As
> I wrote in the thread, I contacted Perforce tech support and was told that
> Mac OS X is not supported.  But I thought that since you wrote the above,
> you may be able to diagnose my problem.
> --
> Daryl Spitzer
> _______________________________________________
> p4python mailing list
> p4python at perforce.com
> http://maillist.perforce.com/mailman/listinfo/p4python

More information about the p4python mailing list