git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #36506 from plapadoo/pysdl2-init

pythonPackages.pysdl2: init at 0.9.6

commitfc1ccb361b6275134153c402698484fb1c135756 authorJörg Thalheim <Mic92@users.noreply.github.com> dateMon 21 May 2018, 13:02 (9 years ago) parent5f6c0ddad399af
3 files changed+162
pkgs/development/python-modules/pysdl2/PySDL2-dll.patch+119 pkgs/development/python-modules/pysdl2/default.nix+41 pkgs/top-level/python-packages.nix+2
pkgs/development/python-modules/pysdl2/PySDL2-dll.patchnew file+119
@@ -0,0 +1,119 @@
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 @@
5+ """Function wrapper around the different DLL functions. Do not use or
6+ instantiate this one directly from your user code.
7+ """
8+- def __init__(self, libinfo, libnames, path=None):
9+- self._dll = None
10+- foundlibs = _findlib(libnames, path)
11+- dllmsg = "PYSDL2_DLL_PATH: %s" % (os.getenv("PYSDL2_DLL_PATH") or "unset")
12+- if len(foundlibs) == 0:
13+- raise RuntimeError("could not find any library for %s (%s)" %
14+- (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))
28+- if path is not None and sys.platform in ("win32",) and \
29+- path in self._libfile:
30+- 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"])
56+
57+ def bind_function(self, funcname, args=None, returns=None, optfunc=None):
58+ """Binds the passed argument and return value types to the specified
59+@@ -110,7 +112,7 @@
60+ return
61+
62+ try:
63+- dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
64++ dll = DLL("SDL2")
65+ except RuntimeError as exc:
66+ raise ImportError(exc)
67+
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 @@
72+ ]
73+
74+ try:
75+- dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
76+- os.getenv("PYSDL2_DLL_PATH"))
77++ dll = DLL("SDL2_gfx")
78+ except RuntimeError as exc:
79+ raise ImportError(exc)
80+
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 @@
85+ ]
86+
87+ try:
88+- dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
89+- os.getenv("PYSDL2_DLL_PATH"))
90++ dll = DLL("SDL2_image")
91+ except RuntimeError as exc:
92+ raise ImportError(exc)
93+
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 @@
98+ ]
99+
100+ try:
101+- dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
102+- os.getenv("PYSDL2_DLL_PATH"))
103++ dll = DLL("SDL2_mixer")
104+ except RuntimeError as exc:
105+ raise ImportError(exc)
106+
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 @@
111+ ]
112+
113+ try:
114+- dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
115+- os.getenv("PYSDL2_DLL_PATH"))
116++ dll = DLL("SDL2_ttf")
117+ except RuntimeError as exc:
118+ raise ImportError(exc)
119+
pkgs/development/python-modules/pysdl2/default.nixnew file+41
@@ -0,0 +1,41 @@
1+{ stdenv, lib, fetchPypi, buildPythonPackage, fetchurl, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer, pyopengl }:
2+
3+buildPythonPackage rec {
4+ pname = "PySDL2";
5+ version = "0.9.6";
6+ # The tests use OpenGL using find_library, which would have to be
7+ # patched; also they seem to actually open X windows and test stuff
8+ # like "screensaver disabling", which would have to be cleverly
9+ # sandboxed. Disable for now.
10+ doCheck = false;
11+
12+ src = fetchPypi {
13+ inherit pname version;
14+ sha256 = "08r1v9wdq8pzds4g3sng2xgh1hlzfs2z7qgy5a6b0xrs96swlamm";
15+ };
16+
17+ # Deliberately not in propagated build inputs; users can decide
18+ # which library they want to include.
19+ buildInputs = [ SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer ];
20+ 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+ '';
34+
35+ meta = {
36+ description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project";
37+ homepage = https://github.com/marcusva/py-sdl2;
38+ license = lib.licenses.publicDomain;
39+ maintainers = with lib.maintainers; [ pmiddend ];
40+ };
41+}
pkgs/top-level/python-packages.nix+2
@@ -18194,6 +18194,8 @@ EOF
1819418194 pyowm = callPackage ../development/python-modules/pyowm { };
1819518195
1819618196 prometheus_client = callPackage ../development/python-modules/prometheus_client { };
18197+
18198+ pysdl2 = callPackage ../development/python-modules/pysdl2 { };
1819718199});
1819818200
1819918201in fix' (extends overrides packages)