git.iko.soy/typeable/nixpkgs
on master help sign in
python3.pkgs.pysdl2: fix build

Update patches after version bump.

commitd82e165609fca694614af53de118e5a42f887c0f authorMartin Povišer <povik@protonmail.com> dateSun 20 Sep 2020, 00:14 (6 years ago) parenta7e1ae6
2 files changed+60−80
pkgs/development/python-modules/pysdl2/PySDL2-dll.patch+47−66 pkgs/development/python-modules/pysdl2/default.nix+13−14
pkgs/development/python-modules/pysdl2/PySDL2-dll.patch+47−66
@@ -1,119 +1,100 @@
1−diff -ru PySDL2-0.9.6-old/sdl2/dll.py PySDL2-0.9.6/sdl2/dll.py
2−--- PySDL2-0.9.6-old/sdl2/dll.py 2018-03-08 10:18:37.583471745 +0100
3−+++ PySDL2-0.9.6/sdl2/dll.py 2018-03-08 10:20:06.705517520 +0100
4−@@ -45,29 +45,31 @@
1+diff -ru PySDL2-0.9.7-old/sdl2/dll.py PySDL2-0.9.7/sdl2/dll.py
2+--- PySDL2-0.9.7-old/sdl2/dll.py 2020-02-15 09:36:29.000000000 +0100
3++++ PySDL2-0.9.7/sdl2/dll.py 2020-09-23 20:24:09.365497270 +0200
4+@@ -94,15 +94,16 @@
55 """Function wrapper around the different DLL functions. Do not use or
66 instantiate this one directly from your user code.
77 """
88- def __init__(self, libinfo, libnames, path=None):
9−- self._dll = None
9++ def __init__(self, libinfo, libfile):
10+ self._dll = None
11+ self._libname = libinfo
12+ self._version = None
1013- foundlibs = _findlib(libnames, path)
1114- dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
1215- if len(foundlibs) == 0:
1316- raise RuntimeError("could not find any library for %s (%s)" %
1417- (libinfo, dllmsg))
15−- for libfile in foundlibs:
16−- try:
17−- self._dll = CDLL(libfile)
18−- self._libfile = libfile
19−- break
20−- except Exception as exc:
21−- # Could not load the DLL, move to the next, but inform the user
22−- # about something weird going on - this may become noisy, but
23−- # is better than confusing the users with the RuntimeError below
24−- warnings.warn(repr(exc), DLLWarning)
25−- if self._dll is None:
26−- raise RuntimeError("found %s, but it's not usable for the library %s" %
27−- (foundlibs, libinfo))
18++ #foundlibs = _findlib(libnames, path)
19++ #dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
20++ #if len(foundlibs) == 0:
21++ # raise RuntimeError("could not find any library for %s (%s)" %
22++ # (libinfo, dllmsg))
23++ foundlibs = [ libfile ]
24+ for libfile in foundlibs:
25+ try:
26+ self._dll = CDLL(libfile)
27+@@ -117,9 +118,9 @@
28+ if self._dll is None:
29+ raise RuntimeError("found %s, but it's not usable for the library %s" %
30+ (foundlibs, libinfo))
2831- if path is not None and sys.platform in ("win32",) and \
2932- path in self._libfile:
3033- os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
31−+ def __init__(self, libfile):
32−+ self._dll = CDLL(libfile)
33−+ self._libfile = libfile
34−+ # self._dll = None
35−+ # foundlibs = _findlib(libnames, path)
36−+ # dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
37−+ # if len(foundlibs) == 0:
38−+ # raise RuntimeError("could not find any library for %s (%s)" %
39−+ # (libinfo, dllmsg))
40−+ # for libfile in foundlibs:
41−+ # try:
42−+ # self._dll = CDLL(libfile)
43−+ # self._libfile = libfile
44−+ # break
45−+ # except Exception as exc:
46−+ # # Could not load the DLL, move to the next, but inform the user
47−+ # # about something weird going on - this may become noisy, but
48−+ # # is better than confusing the users with the RuntimeError below
49−+ # warnings.warn(repr(exc), DLLWarning)
50−+ # if self._dll is None:
51−+ # raise RuntimeError("found %s, but it's not usable for the library %s" %
52−+ # (foundlibs, libinfo))
53−+ # if path is not None and sys.platform in ("win32",) and \
54−+ # path in self._libfile:
55−+ # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
34++ #if path is not None and sys.platform in ("win32",) and \
35++ # path in self._libfile:
36++ # os.environ["PATH"] = "%s;%s" % (path, os.environ["PATH"])
5637
57− def bind_function(self, funcname, args=None, returns=None, optfunc=None):
38+ def bind_function(self, funcname, args=None, returns=None, added=None):
5839 """Binds the passed argument and return value types to the specified
59−@@ -110,7 +112,7 @@
40+@@ -220,7 +221,7 @@
6041 return
6142
6243 try:
6344- dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
64−+ dll = DLL("SDL2")
45++ dll = DLL("SDL2", "@sdl2@")
6546 except RuntimeError as exc:
6647 raise ImportError(exc)
6748
68−diff -ru PySDL2-0.9.6-old/sdl2/sdlgfx.py PySDL2-0.9.6/sdl2/sdlgfx.py
69−--- PySDL2-0.9.6-old/sdl2/sdlgfx.py 2018-03-08 10:18:37.585471769 +0100
70−+++ PySDL2-0.9.6/sdl2/sdlgfx.py 2018-03-08 10:20:06.705517520 +0100
71−@@ -34,8 +34,7 @@
49+diff -ru PySDL2-0.9.7-old/sdl2/sdlgfx.py PySDL2-0.9.7/sdl2/sdlgfx.py
50+--- PySDL2-0.9.7-old/sdl2/sdlgfx.py 2020-02-02 11:07:00.000000000 +0100
51++++ PySDL2-0.9.7/sdl2/sdlgfx.py 2020-09-23 20:23:56.997419129 +0200
52+@@ -39,8 +39,7 @@
7253 ]
7354
7455 try:
7556- dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
7657- os.getenv("PYSDL2_DLL_PATH"))
77−+ dll = DLL("SDL2_gfx")
58++ dll = DLL("SDL2_gfx", "@sdl2_gfx@")
7859 except RuntimeError as exc:
7960 raise ImportError(exc)
8061
81−diff -ru PySDL2-0.9.6-old/sdl2/sdlimage.py PySDL2-0.9.6/sdl2/sdlimage.py
82−--- PySDL2-0.9.6-old/sdl2/sdlimage.py 2018-03-08 10:18:37.585471769 +0100
83−+++ PySDL2-0.9.6/sdl2/sdlimage.py 2018-03-08 10:20:06.705517520 +0100
84−@@ -26,8 +26,7 @@
62+diff -ru PySDL2-0.9.7-old/sdl2/sdlimage.py PySDL2-0.9.7/sdl2/sdlimage.py
63+--- PySDL2-0.9.7-old/sdl2/sdlimage.py 2020-02-02 11:07:00.000000000 +0100
64++++ PySDL2-0.9.7/sdl2/sdlimage.py 2020-09-23 20:23:50.085375658 +0200
65+@@ -27,8 +27,7 @@
8566 ]
8667
8768 try:
8869- dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
8970- os.getenv("PYSDL2_DLL_PATH"))
90−+ dll = DLL("SDL2_image")
71++ dll = DLL("SDL2_image", "@sdl2_image@")
9172 except RuntimeError as exc:
9273 raise ImportError(exc)
9374
94−diff -ru PySDL2-0.9.6-old/sdl2/sdlmixer.py PySDL2-0.9.6/sdl2/sdlmixer.py
95−--- PySDL2-0.9.6-old/sdl2/sdlmixer.py 2018-03-08 10:18:37.585471769 +0100
96−+++ PySDL2-0.9.6/sdl2/sdlmixer.py 2018-03-08 10:20:27.415758478 +0100
97−@@ -50,8 +50,7 @@
75+diff -ru PySDL2-0.9.7-old/sdl2/sdlmixer.py PySDL2-0.9.7/sdl2/sdlmixer.py
76+--- PySDL2-0.9.7-old/sdl2/sdlmixer.py 2020-02-02 11:07:00.000000000 +0100
77++++ PySDL2-0.9.7/sdl2/sdlmixer.py 2020-09-23 20:23:46.117350771 +0200
78+@@ -53,8 +53,7 @@
9879 ]
9980
10081 try:
10182- dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
10283- os.getenv("PYSDL2_DLL_PATH"))
103−+ dll = DLL("SDL2_mixer")
84++ dll = DLL("SDL2_mixer", "@sdl2_mixer@")
10485 except RuntimeError as exc:
10586 raise ImportError(exc)
10687
107−diff -ru PySDL2-0.9.6-old/sdl2/sdlttf.py PySDL2-0.9.6/sdl2/sdlttf.py
108−--- PySDL2-0.9.6-old/sdl2/sdlttf.py 2018-03-08 10:18:37.585471769 +0100
109−+++ PySDL2-0.9.6/sdl2/sdlttf.py 2018-03-08 10:20:06.705517520 +0100
110−@@ -38,8 +38,7 @@
88+diff -ru PySDL2-0.9.7-old/sdl2/sdlttf.py PySDL2-0.9.7/sdl2/sdlttf.py
89+--- PySDL2-0.9.7-old/sdl2/sdlttf.py 2020-02-02 11:07:00.000000000 +0100
90++++ PySDL2-0.9.7/sdl2/sdlttf.py 2020-09-23 20:23:40.069312931 +0200
91+@@ -39,8 +39,7 @@
11192 ]
11293
11394 try:
11495- dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
11596- os.getenv("PYSDL2_DLL_PATH"))
116−+ dll = DLL("SDL2_ttf")
97++ dll = DLL("SDL2_ttf", "@sdl2_ttf@")
11798 except RuntimeError as exc:
11899 raise ImportError(exc)
119100
pkgs/development/python-modules/pysdl2/default.nix+13−14
@@ -1,4 +1,4 @@
1−{ stdenv, lib, fetchPypi, buildPythonPackage, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer }:
1+{ stdenv, lib, substituteAll, fetchPypi, buildPythonPackage, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer }:
22
33buildPythonPackage rec {
44 pname = "PySDL2";
@@ -18,19 +18,18 @@ buildPythonPackage rec {
1818 # which library they want to include.
1919 buildInputs = [ SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer ];
2020 propagatedBuildInputs = [ SDL2 ];
21− patches = [ ./PySDL2-dll.patch ];
22− postPatch = ''
23− substituteInPlace sdl2/dll.py --replace \
24− "DLL(\"SDL2\")" "DLL('${SDL2}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary}')"
25− substituteInPlace sdl2/sdlttf.py --replace \
26− "DLL(\"SDL2_ttf\")" "DLL('${SDL2_ttf}/lib/libSDL2_ttf${stdenv.hostPlatform.extensions.sharedLibrary}')"
27− substituteInPlace sdl2/sdlimage.py --replace \
28− "DLL(\"SDL2_image\")" "DLL('${SDL2_image}/lib/libSDL2_image${stdenv.hostPlatform.extensions.sharedLibrary}')"
29− substituteInPlace sdl2/sdlgfx.py --replace \
30− "DLL(\"SDL2_gfx\")" "DLL('${SDL2_gfx}/lib/libSDL2_gfx${stdenv.hostPlatform.extensions.sharedLibrary}')"
31− substituteInPlace sdl2/sdlmixer.py --replace \
32− "DLL(\"SDL2_mixer\")" "DLL('${SDL2_mixer}/lib/libSDL2_mixer${stdenv.hostPlatform.extensions.sharedLibrary}')"
33− '';
21+ patches = [
22+ (substituteAll ({
23+ src = ./PySDL2-dll.patch;
24+ } // builtins.mapAttrs (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}") {
25+ # substituteAll keys must start lowercase
26+ sdl2 = SDL2;
27+ sdl2_ttf = SDL2_ttf;
28+ sdl2_image = SDL2_image;
29+ sdl2_gfx = SDL2_gfx;
30+ sdl2_mixer = SDL2_mixer;
31+ }))
32+ ];
3433
3534 meta = {
3635 description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project";