| 1 | [](https://pypi.python.org/pypi/pyglet) [](https://pyglet.readthedocs.io) [](https://github.com/pyglet/pyglet/actions/workflows/unittests.yml) |
| 2 | |
| 3 |  |
| 4 | |
| 5 | # pyglet |
| 6 | |
| 7 | *pyglet* is a cross-platform windowing and multimedia library for Python, intended for developing games |
| 8 | and other visually rich applications. It supports Windowing, input event handling, Controllers & Joysticks, |
| 9 | OpenGL graphics, loading images and videos, and playing sounds and music. *pyglet* works on Windows, OS X and Linux. |
| 10 | |
| 11 | > :exclamation: :exclamation: A major pyglet update has just been released (v2.1). This brings many |
| 12 | > new exciting features, but also some necessary breaking changes. If your game/application has suddenly |
| 13 | > stopped working, please read the [migration section in the documentation](https://pyglet.readthedocs.io/en/latest/programming_guide/migration.html) |
| 14 | > The previous version of pyglet is tracked in the `pyglet-2.0-maintenance` branch. |
| 15 | > **If you want to do a pull request for the previous release, please target the appropriate branch**. |
| 16 | |
| 17 | * pyglet [documentation] |
| 18 | * pyglet on [PyPI] |
| 19 | * pyglet [discord] server |
| 20 | * pyglet [mailing list] |
| 21 | * pyglet [issue tracker] |
| 22 | * pyglet [website] |
| 23 | |
| 24 | pyglet has an active developer and user community. If you find a bug or a problem with the documentation, |
| 25 | please [open an issue](https://github.com/pyglet/pyglet/issues). |
| 26 | Anyone is welcome to join our [discord] server where a lot of the development discussion is going on. |
| 27 | It's also a great place to ask for help. |
| 28 | |
| 29 | Some features of pyglet are: |
| 30 | |
| 31 | * **No external dependencies or installation requirements.** For most application and game requirements, *pyglet* |
| 32 | needs nothing else besides Python, simplifying distribution and installation. It's easy to package and distribute |
| 33 | your project with [Nuitka](https://nuitka.net) or [PyInstaller](https://pyinstaller.org). |
| 34 | * **Take advantage of multiple windows and multi-monitor desktops.** *pyglet* allows you to use multiple |
| 35 | platform-native windows, and is fully aware of multi-monitor setups for use with fullscreen games. |
| 36 | * **Load images, sound, music and video in almost any format.** *pyglet* can optionally use FFmpeg to play back |
| 37 | audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as MPEG2, H.264, H.265, WMV and Xvid. |
| 38 | Without FFmpeg, *pyglet* contains built-in support for standard formats such as wav, png, bmp, and others. |
| 39 | * **pyglet is written entirely in pure Python**, and makes use of the *ctypes* module to interface with system |
| 40 | libraries. You can modify the codebase or make a contribution without any second language compilation steps or |
| 41 | compiler setup. Despite being pure Python, *pyglet* has excellent performance thanks to advanced batching for |
| 42 | drawing thousands of objects. |
| 43 | * **pyglet is provided under the BSD open-source license**, allowing you to use it for both commercial and other |
| 44 | open-source projects with very little restriction. |
| 45 | |
| 46 | ## Requirements |
| 47 | |
| 48 | pyglet runs under Python 3.8+. Being written in pure Python, it also works on other Python interpreters such as PyPy. Supported platforms are: |
| 49 | |
| 50 | * Windows 7 or later |
| 51 | * Mac OS X 10.3 or later |
| 52 | * Linux, with the following libraries (most recent distributions will have |
| 53 | these in a default installation): |
| 54 | * OpenGL and GLX |
| 55 | * GDK 2.0+ or Pillow (required for loading images other than PNG and BMP) |
| 56 | * OpenAL or Pulseaudio (required for playing audio) |
| 57 | |
| 58 | **As of pyglet 2.0, OpenGL 3.3+ is required**. |
| 59 | |
| 60 | To play a large variety of compressed audio and video files, |
| 61 | pyglet can optionally take advantage of [FFmpeg](https://ffmpeg.org/). |
| 62 | |
| 63 | ## Installation |
| 64 | |
| 65 | pyglet is installable from PyPI: |
| 66 | |
| 67 | pip install --upgrade --user pyglet |
| 68 | |
| 69 | ## Installation from source |
| 70 | |
| 71 | If you're reading this `README` from a source distribution, you can install pyglet with: |
| 72 | |
| 73 | pip install --upgrade --user . |
| 74 | # or |
| 75 | python setup.py install --user |
| 76 | |
| 77 | You can also install the latest development version directly from Github: |
| 78 | |
| 79 | pip install --upgrade --user https://github.com/pyglet/pyglet/archive/master.zip |
| 80 | |
| 81 | For local development install pyglet in editable mode: |
| 82 | |
| 83 | ```bash |
| 84 | # with pip |
| 85 | pip install -e . |
| 86 | # with setup.py |
| 87 | python setup.py develop |
| 88 | ``` |
| 89 | |
| 90 | There are no compilation steps during the installation; if you prefer, |
| 91 | you can simply add this directory to your `PYTHONPATH` and use pyglet without |
| 92 | installing it. You can also copy pyglet directly into your project folder. |
| 93 | |
| 94 | ## Contributing |
| 95 | |
| 96 | **A good way to start contributing to a component of pyglet is by its documentation**. When studying the code you |
| 97 | are going to work with, also read the associated docs. If you don't understand the code with the help of the docs, |
| 98 | it is a sign that the docs should be improved. If you wish to make large changes to any part of pyglet, it's always |
| 99 | a good idea to reach out for feedback first. This can avoid wasted effort in cases where someone is already working |
| 100 | on something similar, or if your idea can't be accepted for any reason. |
| 101 | |
| 102 | A basic outline of how to a contribution is as follows: |
| 103 | |
| 104 | * Fork the [official repository](https://github.com/pyglet/pyglet/fork). |
| 105 | * In your fork, checkout the branch you wish to contribute to (such as *pyglet-1.5-maintenance*). |
| 106 | * Apply your changes to your fork. |
| 107 | * Submit a [pull request](https://github.com/pyglet/pyglet/pulls) describing the changes you have made. |
| 108 | * Alternatively you can create a patch and submit it to the issue tracker. |
| 109 | |
| 110 | When making a pull request, check that you have addressed its respective documentation, both within the code docstrings |
| 111 | and the programming guide (if applicable). It is very important to all of us that the documentation matches the latest |
| 112 | code and vice versa. |
| 113 | |
| 114 | Consequently, an error in the documentation, either because it is hard to understand or because it doesn't match the |
| 115 | code, is a bug that deserves to be reported on a ticket. |
| 116 | |
| 117 | ## Building Docs |
| 118 | |
| 119 | [Documentation and Type Hints]: https://pyglet.readthedocs.io/en/latest/internal/doc.html |
| 120 | |
| 121 | To get started quickly: |
| 122 | |
| 123 | pip install -r doc/requirements.txt |
| 124 | python make.py docs |
| 125 | |
| 126 | Please check [Documentation and Type Hints][] guide to learn more. |
| 127 | |
| 128 | ## Testing |
| 129 | |
| 130 | pyglet makes use of pytest for its test suite. |
| 131 | |
| 132 | ```bash |
| 133 | pip install -r tests/requirements.txt --user |
| 134 | # Only run unittests |
| 135 | pytest tests/unit |
| 136 | ``` |
| 137 | |
| 138 | Please check the [testing section in the development guide](https://pyglet.readthedocs.io/en/latest/internal/testing.html) |
| 139 | for more information about running and writing tests. |
| 140 | |
| 141 | ## Contact |
| 142 | |
| 143 | pyglet is developed by many individual volunteers, and there is no central point of contact. If you have a question |
| 144 | about developing with pyglet, or you wish to contribute, please join the [discord] server, or [subreddit]. |
| 145 | |
| 146 | For legal issues, please contact [Alex Holkner](mailto:[email protected]). |
| 147 | |
| 148 | [discord]: https://discord.gg/QXyegWe |
| 149 | [subreddit]: https://www.reddit.com/r/pyglet/ |
| 150 | [documentation]: https://pyglet.readthedocs.io |
| 151 | [wiki]: https://github.com/pyglet/pyglet/wiki |
| 152 | [pypi]: https://pypi.org/project/pyglet/ |
| 153 | [website]: http://pyglet.org/ |
| 154 | [issue tracker]: https://github.com/pyglet/pyglet/issues |