Installing (and Building) PyOpenGL

This document describes the process of installing PyOpenGL 3.x.  PyOpenGL 3.x final releases use standard Python distutils, but is compatible with setuptools/distribute's easy_install mechanism.

For the Impatient

For Ubuntu Linux:

# Install standard development tools and language support...
sudo aptitude install gcc freeglut3 libgle3 python-dev python-setuptools python-virtualenv
# Now the "real" packages
sudo aptitude install python-pygame python-numpy python-imaging
# Normally you'll want to set up a "virtualenv" here and activate it *before* doing the easy_install

# For Just PyOpenGL
easy_install PyOpenGL PyOpenGL-accelerate

# Or, for the OpenGLContext testing/demo environment...
easy_install OpenGLContext-full

the recommendation there to use a virtualenv should be considered very strongly, as it allows you to isolate your OpenGL work.  Note, however, that you will often need to use the --no-site-packages flag and then link the system PIL, Pygame and Numpy into the virtualenv's lib/python2.*/site-packages directory.

For Win32, install setuptools or distribute and any dependencies you need (e.g. Numpy, PIL, see below) then:

c:\python26\scripts\easy_install.exe PyOpenGL PyOpenGL-accelerate

# or, for the full OpenGLContext testing/demo environment...
c:\python26\scripts\easy_install.exe OpenGLContext-full

Downloads

As of PyOpenGL 3.0.1, all of our packages are provided via the Python Package Index (PyPI, a.k.a. "The Cheese Shop"):

Older packages can still be downloaded from the SourceForge Downloads page.

Dependencies

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:

Optional PyOpenGL Dependencies:

Deprecated PyOpenGL Dependencies:

Note that Togl support is deprecated, it's there for legacy code (once you install Togl), but you should choose a GUI library that has OpenGL support built-in for any new development.  Togl support has been dropped due the historic headache of maintaining the package.  If you would like to see better Togl support in PyOpenGL, consider volunteering on the mailing list to develop, test and maintain the packaging.

OpenGLContext Dependencies (beyond PyOpenGL)

You ONLY need these packages if you want to use the demo/test package OpenGLContext.  If you just want to use PyOpenGL itself these are not necessary.  You can install most of these dependencies automatically using easy_install OpenGLContext-full

Optional, OpenGLContext dependencies pulled in by OpenGLContext-full (strongly recommended):

Optional Dependencies not pulled in by OpenGLContext-full:

Standard Install (distutils (or setuptools))

PyOpenGL uses standard distutils.  You can download the source packages and install like so:

tar -zxvf PyOpenGL-3.0.0.tar.gz
cd PyOpenGL-3.0.0
python setup.py install

If you prefer to use easy_install, for instance within a virtualenv container, you will need to install setuptools (e.g. by running ez_setup.py), then run:

easy_install PyOpenGL

To update your install to the latest release of PyOpenGL with an easy_install based install:

easy_install -U PyOpenGL

If you want to install your Python egg files in a non-standard location be sure to setup your .pydistutils.cfg to support this before installing the packages.

You may want to uninstall any previous version of PyOpenGL before installing a new version, as there may be conflicts.

If you use setuptools to package your application, you should declare a dependency on "PyOpenGL" to pull in the latest PyOpenGL 3.x release.

Various PyOpenGL 3.0.0 alphas were dependent on setuptools.  This is no longer the case, as setuptools plugin mechanism was causing conflicts with platform packaging tools (py2exe, pyinstaller).

Compiling Accelerator Modules

The OpenGL_accelerate package provides Cython-coded acceleration for the PyOpenGL 3.x branches.  Pre-built packages are provided for Win32 Python. To build the package on Linux machines you will need:

With these, you can install with standard distutils:

python setup.py install

or with easy_install:

easy_install OpenGL_accelerate

BZR (Developer) Install

If you would like to contribute to PyOpenGL development or just need to ride the bleeding edge, you will likely want to work with a source-code checkout.  You will need the Bazaar (bzr) tool to work with the repository:

bzr branch lp:pyopengl OpenGL-ctypes
bzr branch lp:openglcontext OpenGLContext
bzr branch lp:pyvrml97 pyvrml97

You will need to put the "OpenGL", "OpenGLContext" and "vrml" directories inside the top-level directories on your PYTHONPATH via a symlink or a .pth file.  You'll probably also want to add the OpenGL_accelerate and pyvrml97_accelerate packages to that directory (and compile them using python setup.py build_ext --inplace)

To contribute your changes back, either publish your branch publicly (for instance on LaunchPad) or create a "merge directive" to send to pyopengl-devel@lists.sourceforge.net:

bzr send -o my-changes.diff

Note that you'll need to subscribe to pyopengl-devel to post changes to it.  If you prefer you can send them to Mike Fletcher instead.  Please try to include test scripts with your changes so that we can catch regressions in the code-base and I can more readily evaluate the effects of the change.

Building Documentation

The documentation build system is completely rewritten for PyOpenGL 3.x and is far easier to use and faster  (at least a couple of orders of magnitude) than the old Java-based docbook processor.

bzr branch lp:~mcfletch/pyopengl/directdocs
cd directdocs
./samples.py
./references.py
./generate.py
./upload.sh

(The last command will not work unless you happen to be me.) You need the lxml.etree and kid packages installed to run the generator (also bzr, svn, PyOpenGL, cvs, etceteras).

Building Older Releases

If you would like to build the 2.x release of PyOpenGL, you can view the original installation documentation.