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:
- Python 2.2.x+
- Python 2.3+ is recommended.
- Python 2.2.3+ is required
by OpenGLContext (but not by PyOpenGL)
- Tcl/Tk appropriate for your Python version
- OpenGL 1.1 and GLU (available pre-installed on most modern
machines)
- If your machine is a very old Win95 machine that has never had
an OpenGL game, package, or graphics-card installed it is possible that
you don't have OpenGL installed. You can get it from
Microsoft in this (rare) case. Because of MSDN's rather
capricious content-management system, that link may fail at some point.
Search for OpenGL95.exe on Microsoft's site to find it if this
happens.
- GLUT
3.7+
- Available as an rpm/deb/ebuild for most modern Linux machines
- Note that you will often need the "dev" RPM as well as the
run-time RPM
- Available as a Win32 binary package
- Python
Imaging Library (PIL) any recent version
- Not technically required for PyOpenGL, but you'll almost
certainly need it
- Required for OpenGLContext (for all but the most simplistic of
scenes)
- Numeric
Python (Numpy) v. 23 (for PyOpenGL 2.0.1.08)
- You may use another version of Numeric Python iff you are building from source.
Be very sure that the Numeric Python libs and headers available
during build are for the installed version and that you do not use a
PyOpenGL compiled for one with the other.
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:
- PyDispatcher
- Provides the event-routing and field-watching infrastructure
for the scenegraph
- SimpleParse
2.0 and
- mxTextTools
2.1 (or 2.0.x)
- Provide the VRML97 parser, strongly recommended, but
technically optional
- TTFQuery
and
- FontTools
- Provide access to TrueType fonts stored in the file system,
used by the "toolsfont" and "pygamefont" modules in the scenegraph/text
package. Without these modules, you will not have access to
extruded fonts (toolsfont) or antialiased bitmap fonts (pygamefont)
- wxPython
or
- PyGame
- Additional contexts/windowing environments, only GLUT contexts
are available otherwise.
- PyGame also provides antialiased bitmap fonts, while wxPython
can provide aliased bitmap fonts if necessary
- win32all
- win32ui and win32con provide support for WGL-based polygonal
text, only available for Win32 systems of course. The WGL
polygonal text is not used by the scenegraph engine, so it is not
required for anything save playing with the WGL polygonal text
demonstration module.
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:
- Make the GL, GLU and GLUT headers available to distutils
- On Win32 for MSVC++ (which doesn't really have global
include/lib directories), you can create directories at the same level
as the source root named include and lib (i.e. ..\include and ..\lib
are
searched for the libraries)
- Files are: GL.h, GLAUX.h, GLU.h, glut.h, glsmap.h
- If you're on Win32 and don't have a copy of the headers/libs,
the SGI Win32 OpenGL distribution has base-library headers which can be
used, as does the OpenGL95.exe archive described above
- To build the Togl component for Tkinter from source you will need
to install a Tcl/Tk distribution, we recommend using the distribution
from the Tcl/Tk
project at SourceForge
- Note that most Linux/Unix machines will probably already have
these headers properly installed.
- In particular, the header and library (.h and .lib
respectively) files need to be available to the compiler.
- If your
platform does not have standard include or library directories, you may
want to copy them to the Python/include and Python/libs directories
(respectively).
- Alternately, when building PyOpenGL, specify:
setup.py build_togl
--tk-source=/path/to/source --tcl-source=/path/to/source
to add the library and header directories to the path (new
in PyOpenGL 2.1)
- See platform specific build notes, particularly for Win32
systems!
- If building from CVS (not a source archive, which includes the
wrappers already), install the correct version of SWIG (see table
below) and put the directory with swig.exe on your path where distutils
can
find it. Note that using the incorrect version of SWIG will not
work, and will likely render your wrapper files unusable if you are
using a source archive!
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:[email protected]:/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:[email protected]:/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:
DO NOT DO THIS IF YOU DON'T WANT TO RE-WRAP and
are using a source tarball! The default build command will
regenerate the entire SWIG-based wrapper. If you do not have the
correct SWIG version installed this will mangle the wrappers and make
them unusable! Use the second command when just building the
source tarball.
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.
- Install Java
- Install the Saxon
Java XSLT processor
- Add Saxon install root directory (where saxon.jar is) to the
system environment as SAXON_HOME
- Install the DocBook-XSL
package
- Unpack
as PyOpenGL2\doc\docbook-xsl within the source-tree (this will require
renaming the directory from something like 'docbook-xsl-1.59.1' to
'docbook-xsl')
- Add PyOpenGL2\doc\docbook-xsl to the shell environment as
DOCBOOK_XSL_HOME (note that you still must use the doc\docbook-xsl
directory even with the variable set)
- Install Sun's Resolver
package
- Add the resolver root directory (where the file resolver.jar
is) to the system environment as RESOLVER_HOME
- Download the Oasis
XML Docbook catalog and DTD (optional, but speeds up processing
considerably)
- Expand into the PyOpenGL2\doc\docbook directory
- Create a file named CatalogManager.properties in
PyOpenGL2\doc\docbook with these contents (where catalog.xml is the
filename of the Oasis XML catalog). Note that the
PyOpenGL2\doc\docbook directory is added to the classpath to make this
file available to the resolver. Note also that the
relative-catalogs value seems to be somewhat fickle, you may want to
try "false" if saxon is complaining about missing entity files:
catalogs=catalog.xml
relative-catalogs=true
static-catalog=yes
verbosity=1
- Install the MathML DTD in PyOpenGL2\doc\docbook\mathml\
- Add these declarations to the PyOpenGL2\doc\docbook\catalog.xml
file (the last lets the 4.1.2 documents use the 4.2 DTD), the others
make the various parts of the mathml dtd available:
<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"/>
- Install David Carlisle's MathML XSL stylesheets into
PyOpenGL2\doc\xsl\mathml\
- ctop.xsl,mathml.xsl,pmathml.xsl,pmathmlcss.xsl
- (For HTML Help) Add the directory with the hhc.exe file from the
html help workshop to your path.
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.
- Run setup.py build_doc --formats=html,htmlhelp (warning, this
will take a very long time to complete (figure an
hour or so at least))
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!
- glut-3.7-8.i386.rpm
- glut-devel-3.7-8.i386.rpm
- not available by default, needed to install it.
- python2.2.2-2.2.2-1.src.rpm
- python-2.2.2-7.i386.rpm
- python-devel-2.2.2-7.i386.rpm
- tkinter-2.2.2-7.i386.rpm
- tix-8.2.0b1-74.i386.rpm
- not available by default, is required by tkinter
- Numeric-22.0.tar
- "setup.py build install"
- Note: if you want to build and install PyOpenGL from RPM,
you'll need to install Numeric from RPM as well, which is a fairly
trivial process, simply do a
setup.py bdist_rpm
and then
install the RPM.
- swig-1.3.13.tar
- Just a standard install, not required for packaged
distributions, but required for building from CVS.
- Imaging-1.1.3.tar
- (not actually required for PyOpenGL, may require some
pre-configuration)
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
.
- One solution is link
/usr/X11
to /usr/X11R6
.
- Another solution is to add the X11R6 directories to the
configuration file: config/linux.cfg.
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, MS Toolkit, Python 2.4.0a1, Numeric 23
Win2K (MSVC++ 6)
These are the instructions for "packagers" building PyOpenGL from
source on Win32 systems with Visual C++ from Microsoft:
- VC++ (minimum of VC++ runtime libraries, VC++ build tools, and
the "data access" set, register environmental variables)
- Note: environmental variables must be set to operate
properly. You should be able to type 'cl' on the command line to
invoke the VC++ compiler.
- Put OpenGL, GLU and GLUT headers and libs somewhere they can be
reached:
- Add the directory to the system paths (environment 'INCLUDE'
and 'LIB' respectively)
- In the ../include and ../lib directories respectively
- In the Python/include and Python/libs directories respectively
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
- Install Numeric Python 23 or 21 into your Python installation
- Install Tcl/Tk to acquire the Tcl/Tk header files required for
building
- See note above on OpenGL headers for potential locations for
the headers and libs
- run
python.exe setup.py install
Built on:
- Win2K, VC6 SP5, Python 2.3.4, Numeric 23
- Win2K, VC6 SP5, Python 2.2.2, Numeric 23 & 21
- Win98, VC6 SP5, Python 2.2.1
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:
- build the Mesa package as instructed in the Mesa documentation
- copy the .lib files to a location on your LIB path
- copy the .dll files to your system directory.
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:
- First extract PyOpenGL-2.0.0.44.tar.gz then
mesa-setup-patch.tar.gz from the same folder. This will add a
workaround
to the setup script.
- Comment out the line "#define GLU_VERSION_1_2 1" in the GLU
header "GL/glu.h"
- Upgrade to the SGI GLU library which supports GLU 1.3 and is
available via RPM at the Mesa homepage.
- Upgrade Mesa, also available at the Mesa homepage.