Development environment

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

  • Python 3.4+ and Python 2.7
  • 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:

To build packages for distribution you need to install:

It is preferred to create a Python virtual environment to develop in. This allows you to easily test on all Python versions supported by pyglet, not pollute your local system with pyglet development dependencies, and not have your local system interfere with pyglet developement. All dependencies you install while inside an activated virtual environment will remain isolated inside that environment. When you’re finished, you can simply delete it.

This section will show you how to set up and use virtual environments. If you’re already familiar with this, you can probably skip the rest of this page.

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 3.4+ and Python 2.7
  • pip (for each version of Python)
  • Graphviz (if you want to generate documentation)

To create virtual environments, venv is included in the standard library since Python 3.3. For Python 2.7, you will need to install the virtualenv package (you might need to add sudo):

pip install virtualenv

Make a directory somewhere to hold our virtual environments:

mkdir pyglet-venv

Next, we’ll create the virtual environments for each version of python. We’ll put them both inside the “pyglet-venv” folder, to keep things in one place. Remember that the library names are different for Python 2 and 3:

python2 -m virtualenv pyglet-venv/py2
python3 -m venv pyglet-venv/py3

Once the virtual environments have been created, the next step is to activate one of them. You’ll then install the dependencies, which will be isolated inside that virtual environment. Only one can be active at a time, so perform the following steps one one at a time:

Activate whichever virtual environment you wish to use:

. pyglet-venv/py2/bin/activate
# or
. pyglet-venv/py3/bin/activate

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

[Optional] Make sure pip is the latest version:

pip install --upgrade pip

Now install required dependencies:

pip install pytest

Install the documentation generator:

pip install sphinx

And optional dependencies:

pip install pytest-cov Pillow wheel

Finishing

To get out of the virtual environment run:

deactivate

Windows

Setting up

Make sure you download and install:

Pip should be installed by default with the latest Python installers. Make sure you do not uncheck the option. When finished installing, open a command prompt.

To create virtual environments, venv is included in the standard library since Python 3.3. For Python 2.7 only, you will need to install the virtualenv package:

py -2 -m pip install virtualenv

Make a directory somewhere to hold our virtual environments:

md pyglet-venv

Next, we’ll create the virtual environments for each version of python. We’ll put them both inside the “pyglet-venv” folder, to keep things in one place. Remember that the library names are different for Python 2 and 3:

py -2 -m virtualenv pyglet-venv\py2
py -3 -m venv pyglet-venv\py3

Once the virtual environments have been created, the next step is to activate one of them. You’ll then install the dependencies, which will be isolated inside that virtual environment. Only one can be active at a time, so perform the following steps one one at a time.

Activate the virtual environment:

pyglet-venv\py2\Scripts\activate
# or
pyglet-venv\py3\Scripts\activate

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

[Optional] Make sure pip is the latest version:

pip install --upgrade pip

Now install required dependencies:

pip install pytest

Install the documentation generator:

pip install sphinx

And optional dependencies:

pip install pytest-cov Pillow wheel

Finishing

To get out of the virtual environment run:

deactivate