在Mac OS X 10.6上安装Pygame和Pymunk

时间:2011-09-30 19:30:51

标签: compilation osx-snow-leopard pygame failed-installation pymunk

我无法为相同版本的python安装Pymunk和Pygame。我已经尝试过二进制文件,源代码安装,fink和Macports,系统python,python 2.6和python 2.7,32位和64位版本。

在某些情况下,pymunk单元测试导致分段错误,在某些情况下我会出现类似Issue 42的症状,而在某些情况下我无法导入pymunk,因为libchipmunk.dylib是一个不兼容的架构。

当我可以安装pymunk时,我无法使用扩展图像(pygame.image.get_extended() == 0)或字体支持来安装或编译pygame,这在很大程度上违背了一起使用pygame和pymunk的目的。在某些版本的python上,例如2.7 64位,我得到了

building 'pygame.imageext' extension
gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch ppc -arch x86_64 -g -O2 -DNDEBUG -g -O3 -Ddarwin -I/Library/Frameworks/SDL.framework/Versions/Current/Headers -I/Library/Frameworks/SDL_image.framework/Versions/Current/Headers -I/usr/local/include -I/usr/local/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/imageext.c -o build/temp.macosx-10.5-fat3-2.7/src/imageext.o
/usr/libexec/gcc/powerpc-apple-darwin10/4.0.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
lipo: can't open input file: /var/tmp//ccuP0D3r.out (No such file or directory)
error: command 'gcc-4.0' failed with exit status 1

导入pygame时,我有时会得到:

from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper

我在Ubuntu或Windows上没有任何问题,所以我认为问题是OS X特有的。

我对makefile和编译标志有些新意,我一直试图将这两个模块设置为三天,所以如果有人能为我提供一个实际适用于他们的详细安装程序,包括相关的.bash_profile和环境变量,我将非常感激。

编辑:我重新安装了python,pygame和chipmunk + pymunk,这是我在Python 2.7(32位)中遇到的错误:

$ python2.7-32 flipper.py 
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
2011-10-03 19:03:08.862 Python[3683:60f] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
Traceback (most recent call last):
  File "flipper.py", line 35, in <module>
    space.add_static(static_lines)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 288, in add_static
    self.add_static(oo)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 285, in add_static
    self._add_static_shape(o)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 327, in _add_static_shape
    assert static_shape._hashid_private not in self._static_shapes, "shape already added to space"
AssertionError: shape already added to space

编辑2:尽管将setup.py文件更改为仅链接32位,但我得到了一些奇怪的行为:

$ sudo python setup.py build_chipmunk
running build_chipmunk
compiling chipmunk...
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/chipmunk.c -o chipmunk_src/chipmunk.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpArbiter.c -o chipmunk_src/cpArbiter.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpArray.c -o chipmunk_src/cpArray.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBB.c -o chipmunk_src/cpBB.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBBTree.c -o chipmunk_src/cpBBTree.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBody.c -o chipmunk_src/cpBody.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpCollision.c -o chipmunk_src/cpCollision.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpHashSet.c -o chipmunk_src/cpHashSet.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpPolyShape.c -o chipmunk_src/cpPolyShape.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpShape.c -o chipmunk_src/cpShape.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpace.c -o chipmunk_src/cpSpace.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceComponent.c -o chipmunk_src/cpSpaceComponent.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceHash.c -o chipmunk_src/cpSpaceHash.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceQuery.c -o chipmunk_src/cpSpaceQuery.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceStep.c -o chipmunk_src/cpSpaceStep.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpatialIndex.c -o chipmunk_src/cpSpatialIndex.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSweep1D.c -o chipmunk_src/cpSweep1D.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpVect.c -o chipmunk_src/cpVect.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpConstraint.c -o chipmunk_src/constraints/cpConstraint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpDampedRotarySpring.c -o chipmunk_src/constraints/cpDampedRotarySpring.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpDampedSpring.c -o chipmunk_src/constraints/cpDampedSpring.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpGearJoint.c -o chipmunk_src/constraints/cpGearJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpGrooveJoint.c -o chipmunk_src/constraints/cpGrooveJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpPinJoint.c -o chipmunk_src/constraints/cpPinJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpPivotJoint.c -o chipmunk_src/constraints/cpPivotJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpRatchetJoint.c -o chipmunk_src/constraints/cpRatchetJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpRotaryLimitJoint.c -o chipmunk_src/constraints/cpRotaryLimitJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpSimpleMotor.c -o chipmunk_src/constraints/cpSimpleMotor.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -arch x86_64 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpSlideJoint.c -o chipmunk_src/constraints/cpSlideJoint.o
cc -dynamiclib -arch i386 chipmunk_src/chipmunk.o chipmunk_src/cpArbiter.o chipmunk_src/cpArray.o chipmunk_src/cpBB.o chipmunk_src/cpBBTree.o chipmunk_src/cpBody.o chipmunk_src/cpCollision.o chipmunk_src/cpHashSet.o chipmunk_src/cpPolyShape.o chipmunk_src/cpShape.o chipmunk_src/cpSpace.o chipmunk_src/cpSpaceComponent.o chipmunk_src/cpSpaceHash.o chipmunk_src/cpSpaceQuery.o chipmunk_src/cpSpaceStep.o chipmunk_src/cpSpatialIndex.o chipmunk_src/cpSweep1D.o chipmunk_src/cpVect.o chipmunk_src/constraints/cpConstraint.o chipmunk_src/constraints/cpDampedRotarySpring.o chipmunk_src/constraints/cpDampedSpring.o chipmunk_src/constraints/cpGearJoint.o chipmunk_src/constraints/cpGrooveJoint.o chipmunk_src/constraints/cpPinJoint.o chipmunk_src/constraints/cpPivotJoint.o chipmunk_src/constraints/cpRatchetJoint.o chipmunk_src/constraints/cpRotaryLimitJoint.o chipmunk_src/constraints/cpSimpleMotor.o chipmunk_src/constraints/cpSlideJoint.o -o pymunk/libchipmunk.dylib

$ python2.7-32
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymunk
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
>>> s = pymunk.Space()
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
>>> c1 = pymunk.Circle(s.static_body, 1)
>>> s.add(c1)
>>> c2 = pymunk.Circle(s.static_body, 2)
>>> s.add(c2) #No error!

$ sudo python setup.py install

$ python2.7-32 unittests.py 
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
testing pymunk version 2.0.0
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
FFFFSegmentation fault

$ python2.7-32 flipper.py 
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
2011-10-04 13:49:45.653 Python[6430:60f] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
Traceback (most recent call last):
  File "flipper.py", line 35, in <module>
    space.add_static(static_lines)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 288, in add_static
    self.add_static(oo)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 285, in add_static
    self._add_static_shape(o)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 327, in _add_static_shape
    assert static_shape._hashid_private not in self._static_shapes, "shape already added to space"
AssertionError: shape already added to space

编辑3:现在为x86构建并链接了Chipmunk,但我遇到了同样的错误:

$sudo python2.7-32 setup.py build_chipmunk
running build_chipmunk
compiling chipmunk...
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/chipmunk.c -o chipmunk_src/chipmunk.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpArbiter.c -o chipmunk_src/cpArbiter.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpArray.c -o chipmunk_src/cpArray.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBB.c -o chipmunk_src/cpBB.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBBTree.c -o chipmunk_src/cpBBTree.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpBody.c -o chipmunk_src/cpBody.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpCollision.c -o chipmunk_src/cpCollision.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpHashSet.c -o chipmunk_src/cpHashSet.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpPolyShape.c -o chipmunk_src/cpPolyShape.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpShape.c -o chipmunk_src/cpShape.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpace.c -o chipmunk_src/cpSpace.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceComponent.c -o chipmunk_src/cpSpaceComponent.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceHash.c -o chipmunk_src/cpSpaceHash.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceQuery.c -o chipmunk_src/cpSpaceQuery.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpaceStep.c -o chipmunk_src/cpSpaceStep.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSpatialIndex.c -o chipmunk_src/cpSpatialIndex.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpSweep1D.c -o chipmunk_src/cpSweep1D.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/cpVect.c -o chipmunk_src/cpVect.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpConstraint.c -o chipmunk_src/constraints/cpConstraint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpDampedRotarySpring.c -o chipmunk_src/constraints/cpDampedRotarySpring.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpDampedSpring.c -o chipmunk_src/constraints/cpDampedSpring.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpGearJoint.c -o chipmunk_src/constraints/cpGearJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpGrooveJoint.c -o chipmunk_src/constraints/cpGrooveJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpPinJoint.c -o chipmunk_src/constraints/cpPinJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpPivotJoint.c -o chipmunk_src/constraints/cpPivotJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpRatchetJoint.c -o chipmunk_src/constraints/cpRatchetJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpRotaryLimitJoint.c -o chipmunk_src/constraints/cpRotaryLimitJoint.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpSimpleMotor.c -o chipmunk_src/constraints/cpSimpleMotor.o
cc -O3 -std=gnu99 -ffast-math -fPIC -DCHIPMUNK_FFI -arch i386 -Ichipmunk_src/include/chipmunk -c chipmunk_src/constraints/cpSlideJoint.c -o chipmunk_src/constraints/cpSlideJoint.o
cc -dynamiclib -arch i386 chipmunk_src/chipmunk.o chipmunk_src/cpArbiter.o chipmunk_src/cpArray.o chipmunk_src/cpBB.o chipmunk_src/cpBBTree.o chipmunk_src/cpBody.o chipmunk_src/cpCollision.o chipmunk_src/cpHashSet.o chipmunk_src/cpPolyShape.o chipmunk_src/cpShape.o chipmunk_src/cpSpace.o chipmunk_src/cpSpaceComponent.o chipmunk_src/cpSpaceHash.o chipmunk_src/cpSpaceQuery.o chipmunk_src/cpSpaceStep.o chipmunk_src/cpSpatialIndex.o chipmunk_src/cpSweep1D.o chipmunk_src/cpVect.o chipmunk_src/constraints/cpConstraint.o chipmunk_src/constraints/cpDampedRotarySpring.o chipmunk_src/constraints/cpDampedSpring.o chipmunk_src/constraints/cpGearJoint.o chipmunk_src/constraints/cpGrooveJoint.o chipmunk_src/constraints/cpPinJoint.o chipmunk_src/constraints/cpPivotJoint.o chipmunk_src/constraints/cpRatchetJoint.o chipmunk_src/constraints/cpRotaryLimitJoint.o chipmunk_src/constraints/cpSimpleMotor.o chipmunk_src/constraints/cpSlideJoint.o -o pymunk/libchipmunk.dylib

$ sudo python2.7-32 setup.py install
running install
running build
running build_py
copying pymunk/libchipmunk.dylib -> build/lib/pymunk
running install_lib
copying build/lib/pymunk/libchipmunk.dylib -> /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk
running install_egg_info
Removing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk-2.0.0-py2.7.egg-info
Writing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk-2.0.0-py2.7.egg-info

$ python2.7-32 flipper.py 
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
2011-10-05 01:15:15.972 Python[3183:60f] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
Traceback (most recent call last):
  File "flipper.py", line 35, in <module>
    space.add_static(static_lines)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 288, in add_static
    self.add_static(oo)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 285, in add_static
    self._add_static_shape(o)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/__init__.py", line 327, in _add_static_shape
    assert static_shape._hashid_private not in self._static_shapes, "shape already added to space"

$ python2.7-32 unittests.py 
Loading chipmunk for Darwin (32bit) [/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib]
testing pymunk version 2.0.0
Initializing cpSpace - Chipmunk v6.0.1 (Debug Enabled)
Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks
FFFFSegmentation fault

编辑4:验证版本和可执行类型:

$ file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib: Mach-O dynamically linked shared library i386
$ file "$( "$(which python2.7-32)" -c "import sys;print(sys.executable)" )"
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python (for architecture i386):   Mach-O executable i386
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python (for architecture x86_64): Mach-O 64-bit executable x86_64
$ python2.7-32 -c "import sys;print('%x'%sys.maxint)"
7fffffff

提前致谢,

Julian Ceipek

1 个答案:

答案 0 :(得分:1)

(我是pymunk的开发者) 我建议你先让pygame工作。当你有pygame处理特定的python版本时,然后移动并尝试让pymunk在同一个版本上工作。

当你尝试使用pymunk时,让它运行的最佳方法是

  1. 直接从svn获取版本(tags / pymunk-2.0.0包含发行版)。不幸的是,2.0.0的zip源代码分发不包含编译所需的花栗鼠源。

  2. 当你拥有包含源代码的pymunk时,请尝试使用build_chipmunk编译chipmunk(确保使用与运行它相同的python版本执行此步骤)

      

    python setup.py build_chipmunk

  3. 希望你现在能够运行pymunk。

  4. 如果这不起作用,那就更棘手了。

    如果您正在尝试某些实验,可以尝试修改安装脚本,以便仅在32位模式下构建chipmunk(默认情况下,它会将32位和64位版本嵌入到OSX上的dylib文件中)。这样你就可以确定它加载了32位版本。

    在setup.py文件中,http://code.google.com/p/pymunk/source/browse/tags/pymunk-2.0.0/setup.py 编辑第53行来自:

    compiler_preargs += ['-arch', 'i386', '-arch', 'x86_64']
    

    进入

    compiler_preargs += ['-arch', 'i386']
    

    您还需要编辑第66行:

    compiler.set_executable('linker_so', ['cc', '-dynamiclib', '-arch', 'i386', '-arch', 'x86_64'])
    

    进入

    compiler.set_executable('linker_so', ['cc', '-dynamiclib', '-arch', 'i386'])
    

    然后运行

    >python2.7-32 setup.py build_chipmunk
    

    要测试它是否有效,你不需要安装整个东西,你可以直接从同一个文件夹中尝试:

    >python
    >>> import pymunk
    >>> s = pymunk.Space()
    >>> c1 = pymunk.Circle(s.static_body, 1)
    >>> s.add(c1)
    >>> c2 - pymunk.Cricle(s.static_body, 2)
    >>> s.add(c2) #this line will fail if it still doesnt work
    

    如果你仍然有问题,那么这个输出会有所帮助(基本上我几乎没有想法......)

    首先,在dylib文件上运行文件工具:

    > file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymunk/libchipmunk.dylib
    

    然后你也可以验证python正在使用的是什么:

    > file "$( "$(which python2.7-32)" -c "import sys;print(sys.executable)" )"
    

    最后验证python版本确实是32位

    > python2.7-32 -c "import sys;print('%x'%sys.maxint)"