lol

pythonPackages.pysdl2: fix build by fixing patch

The PySDL2-dll.patch did not apply after the last package bump. This
commit both fixes the patch and introduces a pythonImportsCheck.

Closes #193814.

+21 -44
+19 -44
pkgs/development/python-modules/pysdl2/PySDL2-dll.patch
··· 1 1 diff --git a/sdl2/dll.py b/sdl2/dll.py 2 - index 6e30259..12e1f7d 100644 2 + index 2413329..f460bf6 100644 3 3 --- a/sdl2/dll.py 4 4 +++ b/sdl2/dll.py 5 - @@ -145,7 +145,7 @@ class DLL(object): 5 + @@ -235,7 +235,7 @@ class DLL(object): 6 6 """Function wrapper around the different DLL functions. Do not use or 7 7 instantiate this one directly from your user code. 8 8 """ ··· 11 11 self._dll = None 12 12 self._deps = None 13 13 self._libname = libinfo 14 - @@ -157,11 +157,12 @@ class DLL(object): 15 - "SDL2_image": 2001, 16 - "SDL2_gfx": 1003 14 + @@ -247,11 +247,7 @@ class DLL(object): 15 + "SDL2_image": (2, 0, 1), 16 + "SDL2_gfx": (1, 0, 3) 17 17 } 18 18 - foundlibs = _findlib(libnames, path) 19 19 - dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset") 20 20 - if len(foundlibs) == 0: 21 21 - raise RuntimeError("could not find any library for %s (%s)" % 22 22 - (libinfo, dllmsg)) 23 - + #foundlibs = _findlib(libnames, path) 24 - + #dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset") 25 - + #if len(foundlibs) == 0: 26 - + # raise RuntimeError("could not find any library for %s (%s)" % 27 - + # (libinfo, dllmsg)) 28 23 + foundlibs = [ libfile ] 29 24 for libfile in foundlibs: 30 25 try: 31 26 self._dll = CDLL(libfile) 32 - @@ -185,19 +186,19 @@ class DLL(object): 27 + @@ -276,9 +272,6 @@ class DLL(object): 33 28 (foundlibs, libinfo)) 34 29 if _using_ms_store_python(): 35 30 self._deps = _preload_deps(libinfo, self._libfile) 36 31 - if path is not None and sys.platform in ("win32",) and \ 37 32 - path in self._libfile: 38 33 - os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"]) 39 - + #if path is not None and sys.platform in ("win32",) and \ 40 - + # path in self._libfile: 41 - + # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"]) 42 34 43 35 def bind_function(self, funcname, args=None, returns=None, added=None): 44 36 """Binds the passed argument and return value types to the specified 45 - function. If the version of the loaded library is older than the 46 - version where the function was added, an informative exception will 47 - be raised if the bound function is called. 48 - 49 - Args: 50 - funcname (str): The name of the function to bind. 51 - args (List or None, optional): The data types of the C function's 52 - arguments. Should be 'None' if function takes no arguments. 53 - returns (optional): The return type of the bound C function. Should 54 - be 'None' if function returns 'void'. 55 - @@ -288,7 +289,7 @@ def nullfunc(*args): 56 - return 37 + @@ -359,7 +352,7 @@ class DLL(object): 38 + # Once the DLL class is defined, try loading the main SDL2 library 57 39 58 40 try: 59 41 - dll = DLL("SDL2", ["SDL2", "SDL2-2.0", "SDL2-2.0.0"], os.getenv("PYSDL2_DLL_PATH")) ··· 62 44 raise ImportError(exc) 63 45 64 46 diff --git a/sdl2/sdlgfx.py b/sdl2/sdlgfx.py 65 - index 090752e..a8a7488 100644 47 + index 015eeaf..d6ce52f 100644 66 48 --- a/sdl2/sdlgfx.py 67 49 +++ b/sdl2/sdlgfx.py 68 - @@ -50,8 +50,7 @@ __all__ = [ 50 + @@ -27,8 +27,7 @@ __all__ = [ 69 51 70 52 71 53 try: ··· 76 58 raise ImportError(exc) 77 59 78 60 diff --git a/sdl2/sdlimage.py b/sdl2/sdlimage.py 79 - index a6884e8..95d96df 100644 61 + index a702136..dcdea51 100644 80 62 --- a/sdl2/sdlimage.py 81 63 +++ b/sdl2/sdlimage.py 82 - @@ -32,15 +32,14 @@ __all__ = [ 83 - "IMG_LoadXCF_RW", "IMG_LoadWEBP_RW", "IMG_LoadXPM_RW", 84 - "IMG_LoadXV_RW", "IMG_ReadXPMFromArray", 85 - "IMG_GetError", "IMG_SetError", "IMG_SaveJPG", "IMG_SaveJPG_RW", 86 - - 87 - + 88 - # Python Functions 89 - "get_dll_file" 90 - ] 64 + @@ -30,9 +30,7 @@ __all__ = [ 91 65 92 66 93 67 try: 94 - - dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"], 95 - - os.getenv("PYSDL2_DLL_PATH")) 68 + - dll = DLL( 69 + - "SDL2_image", ["SDL2_image", "SDL2_image-2.0"], os.getenv("PYSDL2_DLL_PATH") 70 + - ) 96 71 + dll = DLL("SDL2_image", "@sdl2_image@") 97 72 except RuntimeError as exc: 98 73 raise ImportError(exc) 99 74 100 75 diff --git a/sdl2/sdlmixer.py b/sdl2/sdlmixer.py 101 - index 9ad9b85..1c36289 100644 76 + index 5f2163c..23d95b0 100644 102 77 --- a/sdl2/sdlmixer.py 103 78 +++ b/sdl2/sdlmixer.py 104 - @@ -76,8 +76,7 @@ __all__ = [ 79 + @@ -50,8 +50,7 @@ __all__ = [ 105 80 ] 106 81 107 82 try: ··· 112 87 raise ImportError(exc) 113 88 114 89 diff --git a/sdl2/sdlttf.py b/sdl2/sdlttf.py 115 - index 9c2d951..bd5a16a 100644 90 + index 7c5f7db..61814cd 100644 116 91 --- a/sdl2/sdlttf.py 117 92 +++ b/sdl2/sdlttf.py 118 - @@ -54,8 +54,7 @@ __all__ = [ 93 + @@ -41,8 +41,7 @@ __all__ = [ 119 94 120 95 121 96 try:
+2
pkgs/development/python-modules/pysdl2/default.nix
··· 3 3 buildPythonPackage rec { 4 4 pname = "PySDL2"; 5 5 version = "0.9.14"; 6 + 6 7 # The tests use OpenGL using find_library, which would have to be 7 8 # patched; also they seem to actually open X windows and test stuff 8 9 # like "screensaver disabling", which would have to be cleverly 9 10 # sandboxed. Disable for now. 10 11 doCheck = false; 12 + pythonImportsCheck = [ "sdl2" ]; 11 13 12 14 src = fetchPypi { 13 15 inherit pname version;