Installing (and Building) PyOpenGL

This document describes the process of installing PyOpenGL 2.0.1.  Most users should be able to download pre-compiled binary packages for their system (eventually). Those wishing to build from source will need the detailed build instructions below.

Binary-Package Install

PyOpenGL has a number of dependencies which need to be installed before installing PyOpenGL.  This list should point you to everything you need to get ready for running PyOpenGL:

If you use a version other than that used to compile PyOpenGL, you will get bugs and failures in your code!  In particular, PyOpenGL 2.0.0.x releases were all compiled with Numeric Python 19 through 21 (all of which were compatible), as such, those releases will not work with Numeric Python v22, and the Numeric Python versions used for them will not work with PyOpenGL 2.0.1.07.  The PyOpenGL 2.0.1.07 binary was (mistakenly) compiled with NumArray installed, so depends on it as well.  Upshot is that you need to upgrade Numeric Python and PyOpenGL at the same time if you are using the binary builds.

OpenGLContext has a few extra dependencies:

You can download the installers for PyOpenGL and OpenGLContext from the project's download page.  These installers are standard binary installers.  If binary installers are not available, you will have to build PyOpenGL before you can install it.  See the next section for instructions.

If a binary installer for OpenGLContext is not available, you can use the source archive instead.  Simply unzip the archive to a temporary directory.  Switch to the top-level "OpenGLContext-YYY" directory and execute:

python setup.py install

or, for Linux systems where Python 2.2.x is available as python2:

python2 setup.py install

which will install the package.

Building PyOpenGL

This section describes the process of building PyOpenGL from source, either a source distribution, or CVS.  If you are just interested in running PyOpenGL, and there are binary installers available for your platform, see the previous section.

Extra setup steps before building from source:

Note that you can only build on Win32 systems for use with PythonLabs Python by using the Microsoft VC++ compiler.  Mingw32 chokes on trying to link the dlls.

You can find platform-specific build notes at the end of this document.

CVS Access

Getting the PyOpenGL source from CVS instead of a source distribution:

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pyopengl login

Hit <enter> when prompted to give the default null password.  Then checkout the PyOpenGL2 project using the following:

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/pyopengl co PyOpenGL2

To check out the OpenGLContext module, use the same command, but checkout the modules "OpenGLContext" and "vrml".

Build Commands and Rebuilding

Once the system setup is done, and you've got the PyOpenGL source in a directory on disk.  Switch to that directory (PyOpenGL2 if using CVS, PyOpenGL-Y.Y.Y if using a source archive) and run the standard distutils setup:

setup.py build --force install 

which will force a re-wrap, rebuild and install from your local source-tree.  While:

setup.py build_ext --force install

will skip the wrapping stage if possible.

Note that currently we don't include the SWIG wrappers in the CVS repository, so unless you got them from somewhere else, the non-wrapping command won't work until the first command has been run successfully.  The wrappers are very large and change constantly, and unless there is real need for them, we'd rather not clutter up the CVS archive with them.

Note that you can force a single module to rebuild by "touch"-ing the .i file (in PyOpenGL2/interface) which defines the wrapper for that module.  This is useful during development as it allows the first build-line above to go about wrapping and building the single extension with only minimal processing of the rest of the (large) package.

Building Documentation

Building the documentation-set from source uses Java-based DocBook processing scripts, so it can take quite a bit of work to set up properly.  Most developers will never need to do this, but future administrators (such as myself) will likely want some instructions.  Here's the steps.

catalogs=catalog.xml
relative-catalogs=true
static-catalog=yes
verbosity=1
<public publicId="-//W3C//DTD MathML 2.0//EN"
uri="mathml/mathml2.dtd"/>
<public publicId="-//W3C//ENTITIES MathML 2.0 Qualified Names 1.0//EN"
uri="mathml/mathml2-qname-1.mod"/>
<public publicId="-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN"
uri="mathml/xhtml-math11-f.dtd"/>
<public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN"
uri="docbookx.dtd"/>

Note that the HTML-help feature is not likely to work with the new javascript+CSS formatting provided by the MathML stylesheets above.  Expect the results to be either unreadable or simply fail to be generated.

Platform-specific Build Notes

Note: these notes are not necessarily still relevant to the current builds of PyOpenGL, if you find an out-of-date note, please inform the PyOpenGL-devel list. If you have built PyOpenGL on a platform not described here, please let us know, particularly if there are any nonstandard operations required.  The eventual goal is to have the entire build process on most platforms consist of "python setup.py install" once the required dependencies are installed.

RedHat Linux 8.0

Delete any old version of PyOpenGL first!

Mandrake Linux (for PyOpenGL 2.0.0)

Some Mandrake distrubutions don't use /usr/X11 as the X11 directory.  Instead they use /usr/X11R6 and don't provide /usr/X11 as a link to /usr/X11R6.

PyOpenGL 2.0.1.07+ includes the directories in the linux.cfg file already.

Win2K (MS (Free) Toolkit Compiler)

PyOpenGL can be built for Python 2.4a1 with the MS Toolkit Compiler.  You will need to follow the setup instructions for building Python extensions with the compiler, then continue with the setup instructions below for MSVC++6.0).

Built on:

Win2K (MSVC++ 6)

These are the instructions for "packagers" building PyOpenGL from source on Win32 systems with Visual C++ from Microsoft:

Note: the OpenGL/GLU/GLUT headers should be in the subdirectory <path>/GL/*.h, while the libraries should be directly on the LIB path <path>/*.lib

Built on:

Win32 Mesa

Note that this setup has been built, but not tested extensively.  It is not recommended for anyone who isn't ready to fix lots of bugs.

To build PyOpenGL on Win32 linked against the Mesa DLLs:

Change the win32.cfg file to explicitly specify the Mesa versions of the libraries:

[GL]
libs=MesaGL

; a os.pathsep separated list of the libs needed when linking GLU
; the GL libraries are included automatically
[GLU]
libs=MesaGLU

; a os.pathsep separated list of the libs needed when linking GLUT
; the GL and GLU libraries are included automatically
[GLUT]
libs=MesaGlut

and do a setup.py build_ext --force install.

Mesa GLU Headers

Note: most (all) recent Linux distributions will probably already have upgraded Mesa beyond this level, so you quite likely will not need to follow the above instructions.

Mesa users should beware of Mesa versions 3.1 and 3.2 which have GLU headers which declare themselves as GLU 1.2 but are really GLU 1.1 headers. This will make compilation of the GLU module fail. There are four possible workarounds for this: