如何在Mac OS X上构建和安装P4Python?
我在为Intel的Mac OS X 10.5.5构建P4Python时遇到了问题。
这是我所做的步骤:
- 我从http://filehost.perforce.com/perforce/r07.3/tools/下载了p4python.tgz,并解压到了“P4Python-2007.3”文件夹里。
- 我从http://filehost.perforce.com/perforce/r07.3/bin.macosx104x86/下载了p4api.tar,并解压到了“p4api-2007.3.143793”文件夹里。
- 我把“p4api-2007.3.143793”文件夹放进了“P4Python-2007.3”文件夹,并编辑了setup.cfg文件,把“p4_api=./p4api-2007.3.143793”这行设置好。
我在setup.py文件中添加了这一行:'extra_link_args = ["-framework", "Carbon"]',添加的位置在:
elif unameOut[0] == "Darwin": unix = "MACOSX" release = "104" platform = self.architecture(unameOut[4])
我运行了
python setup.py build
,结果是:
$ python setup.py build
API Release 2007.3
running build
running build_py
running build_ext
building 'P4API' extension
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 -DOS_MACOSXX86 -DOS_MACOSX104X86
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*, 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
which gcc
命令返回的是 /usr/bin/gcc,而 gcc -v
返回的是:
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
--enable-languages=c,objc,c++,obj-c++
--program-transform-name=/^[cg][^.-]*$/s/$/-4.0/
--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
返回的是 Python 2.4.3。
3 个回答
1
根据这个链接 http://bugs.mymediasystem.org/?do=details&task_id=676 的内容,Py_ssize_t 是在 Python 2.5 版本中新增的,所以在 Python 2.4 版本中是不能直接使用的(除非进行一些修改)。
你可以选择安装或编译自己的 Python 2.5 或 2.6 版本,或者想办法修改 P4Python,或者寻找其他的 Python-Perforce 库作为替代。
1
新版2008.1将会使用Python 2.4来构建。
我之前在我的P4Python页面上发布了实现这个所需的一些小改动,但这些改动已经被合并到官方版本中了。
罗伯特