January 16th, 2012
Pyglet is a technology to write cross-platform OpenGL games and applications in Python. If you go to the pyglet site, you will find installers for Mac OS X and Windows. The current Mac version of the installer, 1.1.4, uses Carbon, which means it doesn’t work with 64-bit applications. Not working with 64-bit applications is a problem if you’re running Mac OS X 10.6 and later. Version 1.2 uses Cocoa and works with 64-bit applications, but an installer is not currently available because 1.2 is still in development. Until an installer for 1.2 becomes available, you will have to install pyglet from source code to use version 1.2.
The source code for pyglet is in a Mercurial repository. If you do not have Mercurial installed on your computer, you must install it to be able to install pyglet 1.2. Installers for Mac OS X and Windows are available at the Mercurial site.
Cloning the pyglet repository gives you a copy of the source code so you can install pyglet. Launch the Terminal application, navigate to where you want the source code to reside, and run the following command:
hg clone https://pyglet.googlecode.com/hg/ pyglet
There is a space before pyglet in the last part of the URL. You should see a pyglet folder after cloning the repository.
After cloning the repository, it’s time to install pyglet. In the Terminal application go to the pyglet folder and run the following command:
python setup.py install
Now pyglet should be installed and you can start coding.
Installing pyglet alone has one limitation. It can play only uncompressed audio files. To play compressed audio files, such as MP3 and Ogg Vorbis files, with pyglet, you must install the AVbin library, which is what pyglet uses to play compressed audio. There are multiple versions available for Mac OS X, Windows, and Linux on the AVbin download page. Those of you running Mac OS X 10.6 and later should download a version that supports 64-bit Intel.
After downloading AVbin, you must install it from the Terminal application. Navigate to the avbin folder (the latest name of the folder on Mac OS X is avbin-darwin-x86-64-v8) and enter the following command:
sudo bash install.sh
Running the installation script installs AVbin and lets you play compressed audio files with pyglet.