2005/06/11

Installing PyOpenGL on Mac OS X 10.4.1

Update 2007/02/26



Mike Fletcher has been working on PyOpenGL 3, which uses ctypes instead of swig. As a result, installation and updating are a lot easier. See the SourceForge project page for more info, but here's a quick summary:

$ sudo easy_install PyOpenGL
Password:
Searching for PyOpenGL
Reading http://cheeseshop.python.org/pypi/PyOpenGL/
Reading http://pyopengl.sourceforge.net/ctypes/
Reading http://sourceforge.net/project/showfiles.php?group_id=5988
Reading http://cheeseshop.python.org/pypi/PyOpenGL/3.0.0a5
Best match: PyOpenGL 3.0.0a6
Downloading http://downloads.sourceforge.net/pyopengl/PyOpenGL-3.0.0a6.zip?modtime=1171556482&big_mirror=0
Processing PyOpenGL-3.0.0a6.zip
Running PyOpenGL-3.0.0a6/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9bs-Ie/PyOpenGL-3.0.0a6/egg-dist-tmp-1Y8vWy
Adding PyOpenGL 3.0.0a6 to easy-install.pth file

Installed /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PyOpenGL-3.0.0a6-py2.5.egg
Processing dependencies for PyOpenGL


You can also install and run the demos:
$ sudo easy_install PyOpenGL-Demo


Once they're installed, how do you get at them?

$ cd /Library/Frameworks/Python.framework/Versions/Current/lib/python2.5/site-packages/PyOpenGL_Demo-3.0.0a6-py2.5.egg/PyOpenGL-Demo/
$ cd redbook
$ python movelight.py


Each demo pops up in its own lovely, top-level window.

Original Post



After upgrading to Mac OS X 10.4.1 I decided to install Python 2.4.1. Python made a framework install with no problem. But I ran into a small problem trying to install PyOpenGL-2.0.1.09.


I kept getting compile errors complaining about an incomplete definition for st_atimespec, et al. (Here comes another batch of extremely long lines...)





In file included from /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/pyport.h:155,
from /Library/Frameworks/Python.framework/Versions/2.4/include/python2.4/Python.h:55,
from src/config.h:1,
from _configtest.c:6:
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:225: error: field 'st_atimespec' has incomplete type
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:226: error: field 'st_mtimespec' has incomplete type
/System/Library/Frameworks/Kernel.framework/Headers/sys/stat.h:227: error: field 'st_ctimespec' has incomplete type





What was odd was that the build process was trying to include sys/stat.h from .../Kernel.framework/Headers, instead of from /usr/include.


I modified config/darwin.cfg and removed /System/Library/Frameworks/Kernel.framework/Headers from the list of include directories, and thereafter PyOpenGL built and installed without error.


The examples ran, too :)


Here's the context diff for config/darwin.cfg. Apologies, again, for the long lines -- I've tried to escape them using trailing backslashes.





*** darwin.cfg.orig Sat Jun 11 12:09:35 2005
--- darwin.cfg.new Sat Jun 11 12:19:42 2005
***************
*** 11,17 ****
[General]
build_togl=0
gl_platform=CGL
! include_dirs=/System/Library/Frameworks/OpenGL.framework/Headers:/System/Library/Frameworks/GLUT.framework/Headers:/System/Library/Frameworks/Kernel.framework/Headers
# Bob's OSX patch, comments out the library directories, adds -framework:GLUT
# for the *general* build parameters? Is that actually needed?
; Should make a 'frameworks= ' option!
--- 11,17 ----
[General]
build_togl=0
gl_platform=CGL
! include_dirs=/System/Library/Frameworks/OpenGL.framework/Headers:/System/Library/Frameworks/GLUT.framework/Headers
# Bob's OSX patch, comments out the library directories, adds -framework:GLUT
# for the *general* build parameters? Is that actually needed?
; Should make a 'frameworks= ' option!



No comments: