pygame is
Simple DirectMedia Layer is
Site Swing


Building pygame.
Keeping up with developments.
Buildbots, pygame compiled on every change
Links to individual buildbot pages
Generating docs
Running tests
Code style
Writing tests.
Writing docs.
Documentation Tools

Notes for hacking, developing, and modifying pygame.

Building pygame.

See the wiki page: Compilation to figure out how to compile pygame on different platforms.

Keeping up with developments.

Try and discuss changes on the mailing list.  Especially if you plan to do a big change, let other people know about it on the mailing list.

Most developers are not on irc all of the time - and some never.  So if you need a more realtime chat try and organise a time on the mailing list.  Email lets people communicate in their own time zones.

The svn wiki page has links to various tools... like an rss feed for changes, a web based svn browser, and also links to the build bot.  So you can read the commit logs.

Commit logs are important to keep them short, and also to summarise the changes you have made.

Buildbots, pygame compiled on every change

There is a pygame github mirror of the bitbucket, which is updated every time there is a commit to master.

The set up more buildbots issue tracks developments in the buildbots.

Links to individual buildbot pages

Generating docs


The program runs Sphinx to generate HTML docs and src/docs/{module}_doc.h C headers from reStructuredText source.

The reStructuredText .rst files are stored in the reST/source and reST/source/ref directories.

An online reStructuredText primer can be found at the Python site.

Sphinx specific markup is described in theSphinx Documentation.

The Python Sphinx package itself depends on Docutils, Jinja2, and Pygments.

For Python 2.x, installing Sphinx will also grab and install its dependencies.

Sphinx can be downloaded from PyPi or using easy-install.

For Python 3.x only the latest repository versions work.

Be sure to install Sphinx last so it does not grab the wrong dependency versions:

svn checkout
hg clone pygments
easy_install Jinja2==dev
hg clone sphinx

Running tests

Code style

Try and follow the code style of the particular file you are editing.

Use 4 spaces instead of tabs, and Pep-8 generally.  Make sure your editor doesn't insert tabs.

Try to keep things under 80 characters wide.

Try not to mix in white space commits with other code commits.  This makes reading diffs easier if you separate the whitespace updates from the actual changes.

Writing tests.

Tests are in the test/ directory.

Please see test/README.txt for more of a description on the tests, and the testing framework.

A naming convention is used for all tests. So from the name of a module, class, method, or function, you can find the tests for it.

Each module has a test file.  eg. for pygame.surface there is test/

In that file there are methods for each of the classes, functions and methods. So Surface.blit has a 'test_blit' method.  There can be multiple test methods for each method. eg. 'test_blit_keyword_args' in one of a few tests Surface.blit.  Add extra words at the end of the method name to make multiple tests for the same method.

Methods named with todo at the front "todo_blit" are methods that need to be written. Or finished. By default all of the todo tests are skipped by the test runner.  You can however, make the todo_ tests fail - to see how many more tests need to be finished.

Tests can use tags in order to organise them. There are optionally [modulename] files for each module. A test/ file is used to specify tags for the pygame.surface module. You can use tags to skip tests on different platforms, or to choose different tests to exclude or run.

There are some test related tools + code in test/util/ .

To see if anything in a module is not documented... you can use: python pygame.sprite sprite.doc

To generate some test stubs for your unittests from an existing file... you can do: python midi

Writing docs.

Docs are in the lib/*.doc and src/*.doc files.

It uses a simple text based markup format which doesn't have many tags in it, and is easy to edit in a text editor.

Like source code it should be less than 80 collumns wide... but less than source code. Since it should be well formatted when you do: help(pygame.somemodule). As the help indents things, you might need to use 8-12 characters less per collumn 68 is a safe number. Have a look at your docs in the interpreter to make sure they look ok.

For new functions, or changes to old ones, you should note that the function is new at the bottom of the description... eg. 'New in pygame 1.9.1'

From the .doc files html is generated in the docs/ directory, and code to go in the src/pygamedocs.h file is generated with the script.

Each function, method and object has some documentation for it.

  1. Three line breaks after the previous entry.
  2. There is the object being described. eg 'convert'
  3. Then on the next line is a short one line description. eg 'change the pixel format of an image'
  4. Then multiple lines describing how the method is called with the type of the argument.  eg. 'Surface.convert(Surface): return Surface' 'Surface.convert(masks, flags=0): return Surface'
  5. A line break after these ones.
  6. Then paragraphs of further description.  Describe what it does, and also how to use it.  Explain any quirks, gotchas, or better alternatives.

Here is an example of the Surface.convert documentation. Everything between the quotes.


change the pixel format of an image
Surface.convert(Surface): return Surface
Surface.convert(depth, flags=0): return Surface
Surface.convert(masks, flags=0): return Surface
Surface.convert(): return Surface

Creates a new copy of the Surface with the pixel format changed. The new pixel
format can be determined from another existing Surface. Otherwise depth,
flags, and masks arguments can be used, similar to the pygame.Surface() call.

If no arguments are passed the new Surface will have the same pixel format
as the display Surface. This is always the fastest format for blitting. It
is a good idea to convert all Surfaces before they are blitted many times.

The converted Surface will have no pixel alphas. They will be stripped if
the original had them. See Surface.convert_alpha() for preserving or creating
per-pixel alphas.

Documentation Tools


our projects welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
recent releases
Aug 4, 2015

Jul 30, 2015

Jun 24, 2015

Jun 23, 2015

Jun 21, 2015

Jun 17, 2015

Jun 14, 2015

Jun 8, 2015

Jun 7, 2015

May 31, 2015

May 28, 2015

May 18, 2015

... more!
for pygame related questions, comments, and suggestions, please see help (lists, irc)