Development environment

To develop pyglet, you need an environment with at least the following:

  • python 2.7
  • python 3.4 and/or 3.5
  • py.test
  • Your favorite Python editor or IDE

To generate documentation you also need:

To use and test all pyglet functionality you should also have:

Note

The easiest way to keep track of all that is to use pyenv and virtual environments. If you understand those, you don’t need this guide.

But if you’re new to all this, the rest of this guide will get you started.

It is preferred to create a virtual Python environment to develop in. It allows you to easily test on all Python version supported by pyglet, not pollute your local system with pyglet development dependencies and not have your local system interfere with pyglet developement. This section will show you how to set up a virtual environment for developing pyglet.

Linux or Mac OSX

Setting up

Setting up a virtual environment is almost the same for Linux and OS X. First, use your OS’s package manager (apt, brew, etc) to install the following dependencies:

  • Python 2.7
  • Python 3.4 and/or 3.5
  • pip (for each version of Python)
  • Graphviz (if you want to generate documentation)

[Optional] Make sure pip is the latest version (you might need to add sudo):

pip install --upgrade pip

Install virtualenv to create virtual environments (you might need to add sudo):

pip install virtualenv

Make a directory to hold our virtual environments:

mkdir venv

Now repeat the following steps for each version of Python.

Create a virtual environment (substitute the version number for the version of Python you are creating the environment for:

virtualenv -p python2.7 venv/py27

Activate the virtual environment:

. venv/py27/bin/activate

You will see the name of the virtual environment at the start of the command prompt.

Now install required dependencies:

pip install pytest

Install the documentation generator:

pip install sphinx

And optional dependencies:

pip install pytest-cov Pillow

Using

To switch to a virtual environment run the following:

. venv/<name of environment>/bin/activate

E.g.:

. venv/py34/bin/activate

To get out of the virtual environment run:

deactivate

Windows

Setting up

Make sure you download and install:

Pip should installed automatically with the latest Python installers. Make sure you do not choose to not install pip.

Now open a command prompt. Repeat the following steps for each version of Python (replace 2.7 with the version you want to use).

[Optional] Make sure pip is the latest version:

py -2.7 -m pip install --upgrade pip

Install virtualenv to create virtual environments:

py -2.7 -m pip install virtualenv

Make a directory to hold our virtual environments:

md venv

Create a virtual environment (substitute the version number for the version of Python you are creating the environment for:

py -2.7 -m virtualenv venv\py27

Activate the virtual environment:

venv\py27\Scripts\activate

You will see the name of the virtual environment at the start of the command prompt.

Now install required dependencies:

pip install pytest

Install the documentation generator:

pip install sphinx

And optional dependencies:

pip install pytest-cov Pillow

Using

To switch to a virtual environment run the following:

venv\<name of environment>\Scripts\activate

E.g.:

venv\py34\Scripts\activate

To get out of the virtual environment run:

deactivate