[packages/python-pygame] - updated to 2.0.3, build with SDL2 by default

qboosh qboosh at pld-linux.org
Fri Oct 4 19:00:51 CEST 2024


commit de4eebf32c4e7926cc50a66cf3b4ea019567c9b6
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Fri Oct 4 18:41:17 2024 +0200

    - updated to 2.0.3, build with SDL2 by default

 pygame-py2-types.patch | 53 +++++++++++++++++++++++++++++---------------------
 python-pygame.spec     | 36 +++++++++++++++++++++++++++++-----
 x32.patch              | 22 +++++++++++----------
 3 files changed, 74 insertions(+), 37 deletions(-)
---
diff --git a/python-pygame.spec b/python-pygame.spec
index bd76181..ac100bb 100644
--- a/python-pygame.spec
+++ b/python-pygame.spec
@@ -1,24 +1,32 @@
 #
 # Conditional build:
 %bcond_with	apidocs	# Sphinx documentation (encoding errors as of 1.9.6 / Sphinx 1.8)
+%bcond_with	sdl1	# SDL 1.2 instead of 2.0
 
 %define		module	pygame
 
 Summary:	Python modules designed for writing games
 Summary(pl.UTF-8):	Moduły Pythona dla piszących gry
 Name:		python-%{module}
-Version:	1.9.6
+# keep 2.0.x here for python2 support
+Version:	2.0.3
 Release:	1
 License:	LGPL v2.1+
 Group:		Libraries/Python
 Source0:	https://files.pythonhosted.org/packages/source/p/pygame/pygame-%{version}.tar.gz
-# Source0-md5:	36f8817874f9e63acdf12914340b60e9
+# Source0-md5:	04e082d216b3b771b8d52769597b2fb2
 Patch0:		pygame-py2-types.patch
 Patch2:		x32.patch
 URL:		https://www.pygame.org/
+%if %{with sdl1}
 BuildRequires:	SDL-devel
 BuildRequires:	SDL_image-devel
 BuildRequires:	SDL_mixer-devel
+%else
+BuildRequires:	SDL2-devel >= 2.0
+BuildRequires:	SDL2_image-devel >= 2.0
+BuildRequires:	SDL2_mixer-devel >= 2.0
+%endif
 BuildRequires:	SDL_ttf-devel >= 2.0
 BuildRequires:	freetype-devel >= 2.0
 BuildRequires:	libjpeg-devel
@@ -30,6 +38,7 @@ BuildRequires:	python-numpy-devel
 BuildRequires:	rpm-build >= 4.6
 BuildRequires:	rpm-pythonprov
 BuildRequires:	rpmbuild(macros) >= 1.714
+BuildRequires:	sed >= 4.0
 %if %{with apidocs}
 BuildRequires:	sphinx-pdg-2
 %endif
@@ -82,12 +91,21 @@ Przykłady do modułów Pythona pygame.
 %patch0 -p1
 %patch2 -p1
 
+# missing file, required for py2
+touch docs/reST/ext/__init__.py
+
+# encoding marker required for py2
+%{__sed} -i -e '1i # -*- coding: utf-8 -*-' \
+	docs/reST/ext/boilerplate.py
+
 %build
 export PORTMIDI_INC_PORTTIME=1
-%py_build
+%py_build \
+	%{?with_sdl1:-sdl1}
 
 %if %{with apidocs}
-LC_ALL=en.UTF-8 \
+LC_ALL=C.UTF-8 \
+PYTHONIOENCODING=utf-8 \
 sphinx-build-2 -b html docs/reST docs/_build/html
 %endif
 
@@ -113,7 +131,15 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{py_sitedir}/%{module}
 %{py_sitedir}/%{module}/*.ttf
 %attr(755,root,root) %{py_sitedir}/%{module}/*.so
-%{py_sitedir}/%{module}/*.py[co]
+%{py_sitedir}/%{module}/*.py[cio]
+%{py_sitedir}/%{module}/py.typed
+%dir %{py_sitedir}/%{module}/__pyinstaller
+%{py_sitedir}/%{module}/__pyinstaller/*.py[co]
+%dir %{py_sitedir}/%{module}/_sdl2
+%if %{without sdl1}
+%attr(755,root,root) %{py_sitedir}/%{module}/_sdl2/*.so
+%endif
+%{py_sitedir}/%{module}/_sdl2/*.py[cio]
 %dir %{py_sitedir}/%{module}/threads
 %{py_sitedir}/%{module}/threads/*.py[co]
 %{py_sitedir}/pygame-%{version}-py*.egg-info
diff --git a/pygame-py2-types.patch b/pygame-py2-types.patch
index cce99f9..1e9250d 100644
--- a/pygame-py2-types.patch
+++ b/pygame-py2-types.patch
@@ -1,24 +1,33 @@
---- pygame-1.9.6/src_c/font.c.orig	2019-04-25 08:14:17.000000000 +0200
-+++ pygame-1.9.6/src_c/font.c	2024-09-26 19:48:26.221792668 +0200
-@@ -548,8 +548,8 @@ font_metrics(PyObject *self, PyObject *a
-     int advance;
-     PyObject *obj;
-     PyObject *listitem;
--    Uint16* buffer;
--    Uint16 ch;
-+    char* buffer;
-+    char ch;
-     PyObject *temp;
-     int surrogate;
+--- pygame-2.0.3/src_c/font.c.orig	2021-10-31 16:49:23.000000000 +0100
++++ pygame-2.0.3/src_c/font.c	2024-10-04 06:16:51.713822968 +0200
+@@ -745,7 +745,7 @@ font_dealloc(PyFontObject *self)
+         if (self->ttf_init_generation != current_ttf_generation) {
+             // Since TTF_Font is a private structure
+             // it's impossible to access face field in a common way.
+-            int** face_pp = font;
++            int** face_pp = (int**)font;
+             *face_pp = NULL;
+         }
+         TTF_CloseFont(font);
+--- pygame-2.0.3/src_c/_pygame.h.orig	2021-10-31 16:49:23.000000000 +0100
++++ pygame-2.0.3/src_c/_pygame.h	2024-10-04 06:17:00.351563606 +0200
+@@ -250,7 +250,7 @@ typedef enum {
+ #error No support for PEP 3118/Py_TPFLAGS_HAVE_NEWBUFFER. Please use a supported Python version.
+ #endif */
  
---- pygame-1.9.6/src_c/event.c.orig	2019-04-25 08:14:17.000000000 +0200
-+++ pygame-1.9.6/src_c/event.c	2024-09-26 19:57:56.855188202 +0200
-@@ -1718,7 +1718,7 @@ static PyMethodDef _event_methods[] = {
-      "auto initialize for event module"},
- #endif /* IS_SDLv2 */
+-#define RAISE(x, y) (PyErr_SetString((x), (y)), (PyObject *)NULL)
++#define RAISE(x, y) (PyErr_SetString((x), (y)), NULL)
+ #define DEL_ATTR_NOT_SUPPORTED_CHECK(name, value)           \
+     do {                                                    \
+        if (!value) {                                        \
+--- pygame-2.0.3/src_c/transform.c.orig	2021-10-31 16:49:23.000000000 +0100
++++ pygame-2.0.3/src_c/transform.c	2024-10-04 06:24:54.917312357 +0200
+@@ -668,7 +668,7 @@ surf_rotate(PyObject *self, PyObject *ar
+     surf = pgSurface_AsSurface(surfobj);
+     if (surf->w < 1 || surf->h < 1) {
+         Py_INCREF(surfobj);
+-        return surfobj;
++        return (PyObject *)surfobj;
+     }
  
--    {"Event", pg_Event, 3, DOC_PYGAMEEVENTEVENT},
-+    {"Event", (PyCFunction)pg_Event, 3, DOC_PYGAMEEVENTEVENT},
-     {"event_name", event_name, METH_VARARGS, DOC_PYGAMEEVENTEVENTNAME},
- 
-     {"set_grab", set_grab, METH_VARARGS, DOC_PYGAMEEVENTSETGRAB},
+     if (surf->format->BytesPerPixel == 0 || surf->format->BytesPerPixel > 4)
diff --git a/x32.patch b/x32.patch
index 118f4d0..7650f74 100644
--- a/x32.patch
+++ b/x32.patch
@@ -1,17 +1,19 @@
---- pygame-1.9.6/buildconfig/config_unix.py.orig	2019-04-25 08:14:17.000000000 +0200
-+++ pygame-1.9.6/buildconfig/config_unix.py	2024-09-26 19:38:56.998397169 +0200
-@@ -149,11 +149,10 @@ def main(sdl2=False):
+--- pygame-2.0.3/buildconfig/config_unix.py.orig	2024-10-03 22:31:41.481965431 +0200
++++ pygame-2.0.3/buildconfig/config_unix.py	2024-10-04 06:25:17.535875741 +0200
+@@ -136,14 +136,10 @@ def main(sdl2=False):
      #these get prefixes with '/usr' and '/usr/local' or the $LOCALBASE
      if sdl2:
          origincdirs = ['/include', '/include/SDL2']
--        origlibdirs = ['/lib','/lib64','/X11R6/lib',
--                       '/lib/i386-linux-gnu', '/lib/x86_64-linux-gnu']
-+        origlibdirs = ['/lib','/lib64','/libx32']
+-        origlibdirs = ['/lib', '/lib64', '/X11R6/lib',
+-                       '/lib/i386-linux-gnu', '/lib/x86_64-linux-gnu',
+-                       '/lib/arm-linux-gnueabihf/', '/lib/aarch64-linux-gnu/']
+-
++        origlibdirs = ['/lib', '/lib64', '/libx32']
      else:
--        origincdirs = ['/include', '/include/SDL', '/include/SDL']
--        origlibdirs = ['/lib','/lib64','/X11R6/lib']
-+        origincdirs = ['/include', '/include/SDL']
-+        origlibdirs = ['/lib','/lib64','/libx32']
+         origincdirs = ['/include', '/include/SDL', '/include/SDL']
+-        origlibdirs = ['/lib', '/lib64', '/X11R6/lib', '/lib/arm-linux-gnueabihf/',
+-                       '/lib/aarch64-linux-gnu/']
++        origlibdirs = ['/lib', '/lib64', '/libx32']
      if 'ORIGLIBDIRS' in os.environ and os.environ['ORIGLIBDIRS'] != "":
          origlibdirs = os.environ['ORIGLIBDIRS'].split(":")
  
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/python-pygame.git/commitdiff/de4eebf32c4e7926cc50a66cf3b4ea019567c9b6



More information about the pld-cvs-commit mailing list