python3.pkgs.pysdl2: fix build

Update patches after version bump.
This commit is contained in:
Martin Povišer 2020-09-20 00:14:49 +02:00 committed by Jon
parent a7e1ae6b51
commit d82e165609
2 changed files with 60 additions and 80 deletions

View File

@ -1,119 +1,100 @@
diff -ru PySDL2-0.9.6-old/sdl2/dll.py PySDL2-0.9.6/sdl2/dll.py diff -ru PySDL2-0.9.7-old/sdl2/dll.py PySDL2-0.9.7/sdl2/dll.py
--- PySDL2-0.9.6-old/sdl2/dll.py 2018-03-08 10:18:37.583471745 +0100 --- PySDL2-0.9.7-old/sdl2/dll.py 2020-02-15 09:36:29.000000000 +0100
+++ PySDL2-0.9.6/sdl2/dll.py 2018-03-08 10:20:06.705517520 +0100 +++ PySDL2-0.9.7/sdl2/dll.py 2020-09-23 20:24:09.365497270 +0200
@@ -45,29 +45,31 @@ @@ -94,15 +94,16 @@
"""Function wrapper around the different DLL functions. Do not use or """Function wrapper around the different DLL functions. Do not use or
instantiate this one directly from your user code. instantiate this one directly from your user code.
""" """
- def __init__(self, libinfo, libnames, path=None): - def __init__(self, libinfo, libnames, path=None):
- self._dll = None + def __init__(self, libinfo, libfile):
self._dll = None
self._libname = libinfo
self._version = None
- foundlibs = _findlib(libnames, path) - foundlibs = _findlib(libnames, path)
- dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset") - dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
- if len(foundlibs) == 0: - if len(foundlibs) == 0:
- raise RuntimeError("could not find any library for %s (%s)" % - raise RuntimeError("could not find any library for %s (%s)" %
- (libinfo, dllmsg)) - (libinfo, dllmsg))
- for libfile in foundlibs: + #foundlibs = _findlib(libnames, path)
- try: + #dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
- self._dll = CDLL(libfile) + #if len(foundlibs) == 0:
- self._libfile = libfile + # raise RuntimeError("could not find any library for %s (%s)" %
- break + # (libinfo, dllmsg))
- except Exception as exc: + foundlibs = [ libfile ]
- # Could not load the DLL, move to the next, but inform the user for libfile in foundlibs:
- # about something weird going on - this may become noisy, but try:
- # is better than confusing the users with the RuntimeError below self._dll = CDLL(libfile)
- warnings.warn(repr(exc), DLLWarning) @@ -117,9 +118,9 @@
- if self._dll is None: if self._dll is None:
- raise RuntimeError("found %s, but it's not usable for the library %s" % raise RuntimeError("found %s, but it's not usable for the library %s" %
- (foundlibs, libinfo)) (foundlibs, libinfo))
- if path is not None and sys.platform in ("win32",) and \ - if path is not None and sys.platform in ("win32",) and \
- path in self._libfile: - path in self._libfile:
- os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"]) - os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
+ def __init__(self, libfile): + #if path is not None and sys.platform in ("win32",) and \
+ self._dll = CDLL(libfile) + # path in self._libfile:
+ self._libfile = libfile + # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
+ # self._dll = None
+ # foundlibs = _findlib(libnames, path)
+ # dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
+ # if len(foundlibs) == 0:
+ # raise RuntimeError("could not find any library for %s (%s)" %
+ # (libinfo, dllmsg))
+ # for libfile in foundlibs:
+ # try:
+ # self._dll = CDLL(libfile)
+ # self._libfile = libfile
+ # break
+ # except Exception as exc:
+ # # Could not load the DLL, move to the next, but inform the user
+ # # about something weird going on - this may become noisy, but
+ # # is better than confusing the users with the RuntimeError below
+ # warnings.warn(repr(exc), DLLWarning)
+ # if self._dll is None:
+ # raise RuntimeError("found %s, but it's not usable for the library %s" %
+ # (foundlibs, libinfo))
+ # if path is not None and sys.platform in ("win32",) and \
+ # path in self._libfile:
+ # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
def bind_function(self, funcname, args=None, returns=None, optfunc=None): def bind_function(self, funcname, args=None, returns=None, added=None):
"""Binds the passed argument and return value types to the specified """Binds the passed argument and return value types to the specified
@@ -110,7 +112,7 @@ @@ -220,7 +221,7 @@
return return
try: try:
- dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH")) - dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
+ dll = DLL("SDL2") + dll = DLL("SDL2", "@sdl2@")
except RuntimeError as exc: except RuntimeError as exc:
raise ImportError(exc) raise ImportError(exc)
diff -ru PySDL2-0.9.6-old/sdl2/sdlgfx.py PySDL2-0.9.6/sdl2/sdlgfx.py diff -ru PySDL2-0.9.7-old/sdl2/sdlgfx.py PySDL2-0.9.7/sdl2/sdlgfx.py
--- PySDL2-0.9.6-old/sdl2/sdlgfx.py 2018-03-08 10:18:37.585471769 +0100 --- PySDL2-0.9.7-old/sdl2/sdlgfx.py 2020-02-02 11:07:00.000000000 +0100
+++ PySDL2-0.9.6/sdl2/sdlgfx.py 2018-03-08 10:20:06.705517520 +0100 +++ PySDL2-0.9.7/sdl2/sdlgfx.py 2020-09-23 20:23:56.997419129 +0200
@@ -34,8 +34,7 @@ @@ -39,8 +39,7 @@
] ]
try: try:
- dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"], - dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
- os.getenv("PYSDL2_DLL_PATH")) - os.getenv("PYSDL2_DLL_PATH"))
+ dll = DLL("SDL2_gfx") + dll = DLL("SDL2_gfx", "@sdl2_gfx@")
except RuntimeError as exc: except RuntimeError as exc:
raise ImportError(exc) raise ImportError(exc)
diff -ru PySDL2-0.9.6-old/sdl2/sdlimage.py PySDL2-0.9.6/sdl2/sdlimage.py diff -ru PySDL2-0.9.7-old/sdl2/sdlimage.py PySDL2-0.9.7/sdl2/sdlimage.py
--- PySDL2-0.9.6-old/sdl2/sdlimage.py 2018-03-08 10:18:37.585471769 +0100 --- PySDL2-0.9.7-old/sdl2/sdlimage.py 2020-02-02 11:07:00.000000000 +0100
+++ PySDL2-0.9.6/sdl2/sdlimage.py 2018-03-08 10:20:06.705517520 +0100 +++ PySDL2-0.9.7/sdl2/sdlimage.py 2020-09-23 20:23:50.085375658 +0200
@@ -26,8 +26,7 @@ @@ -27,8 +27,7 @@
] ]
try: try:
- dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"], - dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
- os.getenv("PYSDL2_DLL_PATH")) - os.getenv("PYSDL2_DLL_PATH"))
+ dll = DLL("SDL2_image") + dll = DLL("SDL2_image", "@sdl2_image@")
except RuntimeError as exc: except RuntimeError as exc:
raise ImportError(exc) raise ImportError(exc)
diff -ru PySDL2-0.9.6-old/sdl2/sdlmixer.py PySDL2-0.9.6/sdl2/sdlmixer.py diff -ru PySDL2-0.9.7-old/sdl2/sdlmixer.py PySDL2-0.9.7/sdl2/sdlmixer.py
--- PySDL2-0.9.6-old/sdl2/sdlmixer.py 2018-03-08 10:18:37.585471769 +0100 --- PySDL2-0.9.7-old/sdl2/sdlmixer.py 2020-02-02 11:07:00.000000000 +0100
+++ PySDL2-0.9.6/sdl2/sdlmixer.py 2018-03-08 10:20:27.415758478 +0100 +++ PySDL2-0.9.7/sdl2/sdlmixer.py 2020-09-23 20:23:46.117350771 +0200
@@ -50,8 +50,7 @@ @@ -53,8 +53,7 @@
] ]
try: try:
- dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"], - dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
- os.getenv("PYSDL2_DLL_PATH")) - os.getenv("PYSDL2_DLL_PATH"))
+ dll = DLL("SDL2_mixer") + dll = DLL("SDL2_mixer", "@sdl2_mixer@")
except RuntimeError as exc: except RuntimeError as exc:
raise ImportError(exc) raise ImportError(exc)
diff -ru PySDL2-0.9.6-old/sdl2/sdlttf.py PySDL2-0.9.6/sdl2/sdlttf.py diff -ru PySDL2-0.9.7-old/sdl2/sdlttf.py PySDL2-0.9.7/sdl2/sdlttf.py
--- PySDL2-0.9.6-old/sdl2/sdlttf.py 2018-03-08 10:18:37.585471769 +0100 --- PySDL2-0.9.7-old/sdl2/sdlttf.py 2020-02-02 11:07:00.000000000 +0100
+++ PySDL2-0.9.6/sdl2/sdlttf.py 2018-03-08 10:20:06.705517520 +0100 +++ PySDL2-0.9.7/sdl2/sdlttf.py 2020-09-23 20:23:40.069312931 +0200
@@ -38,8 +38,7 @@ @@ -39,8 +39,7 @@
] ]
try: try:
- dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"], - dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
- os.getenv("PYSDL2_DLL_PATH")) - os.getenv("PYSDL2_DLL_PATH"))
+ dll = DLL("SDL2_ttf") + dll = DLL("SDL2_ttf", "@sdl2_ttf@")
except RuntimeError as exc: except RuntimeError as exc:
raise ImportError(exc) raise ImportError(exc)

View File

@ -1,4 +1,4 @@
{ stdenv, lib, fetchPypi, buildPythonPackage, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer }: { stdenv, lib, substituteAll, fetchPypi, buildPythonPackage, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer }:
buildPythonPackage rec { buildPythonPackage rec {
pname = "PySDL2"; pname = "PySDL2";
@ -18,19 +18,18 @@ buildPythonPackage rec {
# which library they want to include. # which library they want to include.
buildInputs = [ SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer ]; buildInputs = [ SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer ];
propagatedBuildInputs = [ SDL2 ]; propagatedBuildInputs = [ SDL2 ];
patches = [ ./PySDL2-dll.patch ]; patches = [
postPatch = '' (substituteAll ({
substituteInPlace sdl2/dll.py --replace \ src = ./PySDL2-dll.patch;
"DLL(\"SDL2\")" "DLL('${SDL2}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary}')" } // builtins.mapAttrs (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}") {
substituteInPlace sdl2/sdlttf.py --replace \ # substituteAll keys must start lowercase
"DLL(\"SDL2_ttf\")" "DLL('${SDL2_ttf}/lib/libSDL2_ttf${stdenv.hostPlatform.extensions.sharedLibrary}')" sdl2 = SDL2;
substituteInPlace sdl2/sdlimage.py --replace \ sdl2_ttf = SDL2_ttf;
"DLL(\"SDL2_image\")" "DLL('${SDL2_image}/lib/libSDL2_image${stdenv.hostPlatform.extensions.sharedLibrary}')" sdl2_image = SDL2_image;
substituteInPlace sdl2/sdlgfx.py --replace \ sdl2_gfx = SDL2_gfx;
"DLL(\"SDL2_gfx\")" "DLL('${SDL2_gfx}/lib/libSDL2_gfx${stdenv.hostPlatform.extensions.sharedLibrary}')" sdl2_mixer = SDL2_mixer;
substituteInPlace sdl2/sdlmixer.py --replace \ }))
"DLL(\"SDL2_mixer\")" "DLL('${SDL2_mixer}/lib/libSDL2_mixer${stdenv.hostPlatform.extensions.sharedLibrary}')" ];
'';
meta = { meta = {
description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project"; description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project";