[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Re: Starting the pygame 2 series




 ,--.
|  oo|
|  ~~| o  o  o  o  o  o  o  o  o  o  o
|/\/\|
       pip install pygame==2.0.0.dev12

Locked in or Locked out? That's not going to stop a new pygame coming out.

The main theme of this release is testing. With many new contributors having worked on unit tests, we can be much more confident that many more features will continue to work with our SDL2 based pygame 2 as in pygame 1 which is based on SDL1. But we also have a few new features, and plenty of bug fixes.

Thanks to everyone for their help with this release.

Critical backwards compatibility fixes for pygame 2

First up, some 'critical' improvements that have been made to pygame. 'critical' labeled issues are ones are backwards incompatible issues stopping a pygame 2 release.

We start with some joystick improvements from Daniel Pope @lordmauve. Add SDL2-specific methods to Joystick; rename event fields. Now joysticks(game pads, drum sets, dance mats) can be hot-plugged, and the game will still work properly.

@robertpfeiffer got posting of keydown events working on SDL2. This is part of the android work that has now been merged into the main branch - but it is also a backwards compatibility fix.

Thanks to Dan Lawrence @MyreMylar for fixing segfaults caused when interacting with display surface after quit, which is mainly useful for when writing unit tests or playing with pygame interactively.

Sometimes writing tests for existing functionality finds real issues and bugs. First @tsadama Added unit tests for display.toggle_fullscreen and display.get_active which uncovered an issue with SDL2. Then Dan Lawrence @MyreMylar Fixed get_active() function so it works as described in docs on windows under SDL2..

Tests

Here we see the amount of unit tests left to write to get full coverage of every pygame method. During this release period you can see a lot of things got new tests. During the testing it uncovered a number of real issues, and some of them were even fixed.

pygame version Methods left to test
2.0.0.dev12 81
2.0.0.dev10 127
2.0.0.dev8 143
2.0.0.dev6 147
1.9.6 156
1.9.5 155
1.9.4 189
1.9.3 194
1.9.2 194
1.9.1 232
1.9.0 232
1.8.1 25
1.8.0 0

The count can be found with the following command run in the pygame code base:

grep todo test/*.py | wc -l

'goodfirstissue' is a label applied to issues which would be good for someone who wants to try contributing to a Free, Open Source, or community project (like pygame). A lot of these issues were written up containing unit tests that needed to be finished off.

Unfortunately we will probably run out of things to test in some months. We hope to prepare new types of 'good first issues', and educational material in other areas next. So that there is something else for people who are interested in contributing as a way to learn. Hopefully we can structure it as a learning pathway, with even some advanced topics.

Thanks to Andy Nguyen @anguye13, who worked on a number of tests in the display, image, and surface areas.

Adam Andrews @adamandrews1 worked on the transform, threads parts of the code base. They have also begun work on cleaning up the buffer code, which is in C and kind of complicated. But that work is still waiting, and will likely make it into the next release.

Travis Chang @Reminisque

Dan Lawrence @MyreMylar

@khuang0312

@lkito

Pedro de la Peña @pedrodelapena

@galexandreg continued to

@tsadama

pygame.joystick tests

@raphacosta27 Add unit test: joystick.quit()
Bill @AdditionalPylons Added unit test: JoystickModuleTest.test_get_count

pygame.display tests

Gabriel Moreira @gabsmoreira Add unit test: display.get_driver
@zoldalma999 Adding unit test to display.iconify
@amipy Added a unit test for display.flip()
@DGMcKenney Adds a unit test of the display.set_icon() function.
Grigoris Tsopouridis @gtsopus Add display.set_gamma unit test

pygame.time tests

Ilia Gogotchuri @Gogotchuri Implemented time.Clock.get_fps unit test
Jim Quach @jiquach Add unit test to Clock.get_rawtime
Aaron Li @AaronLi Added test for time.Clock.tick()
Clark Seanor @cruxicheiros Add basic tests for time.Clock.tick_busy_loop

pygame.threads tests

K Duggan @kduggan15 Adds test for threadloop
Michał Górny @mgorny Replace long-deprecated Thread.isAlive() with .is_alive()
Clark Seanor @cruxicheiros threads.tmap() test and and fix. Unsurfaced bug #1768

pygame.Surface tests

@jtoloff unit test for Surface.get_locks function
@41aaronb Added unit test for the surface.lock() function

other tests

Prasanna Venkatesh @hanzohasashi33 math.Vector.scale_to_length docs and add test for display.set_palette()
@zoldalma999 Add unit test to image.get_extended
Nihal Mittal @codescientist703 Added unit test for pygame.cursors.compile
@leopoldwe Add key.get focused unit test

draw

Josip Komljenović @MightyJosip Fixed drawing of ellipse. No more holes.

Old:
Old
New:
New

Scott Noyes @snoyes draw_py._draw_line: Use correct endpoints during swap

Charles @charlesej Fix aatrigon/aapolygon drawing horizontal edges

Math

Daniel Pope @lordmauve Fix OOB access in math.Vector swizzle; add '0' and '1' swizzles

These will be useful to prepare homogenous coordinates for affine transforms by matrix multiplication. Here is a matrix representing a 2x scale + (3, -1) translation:

>>> import numpy as np
>>> from pygame.math import Vector2
>>> v = Vector2(0.5, 0.8)
>>> mat = np.array([
...   [2, 0, 3],
...   [0, 2, -1],
... ])
>>> mat @ v.xy1
array([4. , 0.6])

Community help

A special thanks to all the people who help out others. From making videos, to answering questions, to writing guides. MyreMylar, MichaelCPalmer, jtiai, claudeb, DaFluffyPotato, Rabbid76, The Big Kahuna, sloth, Kingsley, ... and lots of other people.

Special thanks to @Zireael07 for cheering on pull requests that people make 🎉

Type hints, and lint tools

We are down to zero alerts on the LGTM linting tool on python and C/C++. We are now the largest python codebase with zero alerts on the LGTM platform (and also the largest C/C++ codebase with zero alerts). This doesn't mean we have perfect code yet however!

pylint

pylint is another python code quality tool we are using. With which we currently have thousands of reported issues left. Not only can this tool find correctness problems with the code, it can also offer ideas on how to make the code more readable and 'pythonic'. Once we have the files pylint-clean we can use pylint to take some of the load off the code reviewers.

Dan Lawrence @MyreMylar pylint

Charles @charlesej

Josip Komljenović @MightyJosip

Android

Some more of the android branch got merged into the main pygame branch.

@robertpfeiffer

big endian CPU architecture

Thanks to Travis CI, we now have a builder which can test our big endian code. Even though big endian is not very common these days, it's still helpful to support it because it helps shake out some bugs we wouldn't normally see just testing on little endian CPU architectures.

René Dudfield @illume s390x build robot on travis CI for big endian testing
Michał Górny @mgorny Account for big endian support for RGB/BGR images
Dan Lawrence @MyreMylar Remove hard coded RGB bitshifts that don't work with SDL_MapRGB()/SDL_MapRGBA()

image

Sigurður Sveinn Halldórsson @siggisv image.save(namehint='') and image.get_sdl_image_version useful for when saving images to file objects and you want to tell it what format to save in (jpg, png, etc).

>>> file = BytesIO()
>>> pygame.image.save(surface, file, namehint='.png')

Documentation and tutorials

                                       _________________________
                                     =(__    ___       __     __)=
                                       |                       |
                                       |                       |
                                       | python -m pygame.docs |
                                       |                       |
                                       | A number of small     |
                                       | documentation fixes   |
                                       | were made in this     |
                                       | release.              |
                                       |                       |
                                       |__    ___   __    _____|
                                     =(_________________________)=

@Starbuck5 Fix typo in draw.rst

Dan Lawrence @MyreMylar

@wuzh07 Fix typos in draw.rect docs
Gerardo Antonio Hagad @ginohagad Chimp tutorial: Changed the variable "wav" to "fullname".

Evan Kanter @evank28 Updated documentation of blit method
Vicente González Ruiz @vicente-gonzalez-ruiz Update SpriteIntro.rst

Douglas @douglas-cpp Fix grammar in sprite docs

mouse

Dan Lawrence @MyreMylar mouse.get_pressed() supports 5 buttons

Optimizations

@nthykier Add a SSE4.2 optimized version of image_tostring for some 32bit surfaces. The new pygame.image.tostring is up to 8x faster on x86 and x64 systems.

Bug fixes and Cleanups

René Dudfield @illume

Inada Naoki @methane Avoid PEP393 deprecated APIs.
Niels Thykier @nthykier Fix test failure without SDL_AUDIODRIVER set

Jani Tiainen @jtiai Pipenv: Fixed incorrect base class comparison

Christian Clauss @cclauss Travis CI: Test Py38 on Ubuntu Bionic

Dan Lawrence @MyreMylar

Sigurður Sveinn Halldórsson @siggisv Fix pygame.event.custom_type() off by one error.

Josip Komljenović MightyJosip

@Starbuck5 Internal pyinstaller hook to include dynamic libraries on Windows

Gosha Zacharov @Gosha Allow setting several paths in PYGAME_EXTRA_BASE

sprite

Sigurður Sveinn Halldórsson @siggisv Fix and test sprite.collide_circle_ratio
Josip Komljenović @MightyJosip Fix sprite drawing on Renderer

Reviews

Special thanks to @MyreMylar, @MightyJosip, @charlesej, @robertpfeiffer, @illume and @nthykier who have provided plenty of code reviews and testing of other peoples work.

It's vitally important that people volunteering (sometimes for the first time) are treated with respect and in a friendly way. It's also important that everyone in our community should feel free to review code, so we can all learn from one another.

Issue gardening

            ********
        ****************
      *******************
      ********************
       ********************         wWWWw               wWWWw
          \\   //  ********   vVVVv (___) wWWWw         (___)  vVVVv
           \\\//  *******     (___)  ~Y~  (___)  vVVVv   ~Y~   (___)
             \\\////           ~Y~   \|    ~Y~   (___)    |/    ~Y~
              |||//            \|   \ |/   \| /  \~Y~/   \|    \ |/
              |||||           \\|// \\|// \\|/// \\|//  \\|// \\\|///
  ,,,,,,,,,,,//||||\,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This time 4 'critical' backwards compatibility issues were fixed since the last release.