1{ stdenv, lib, substituteAll, fetchPypi, buildPythonPackage, SDL2, SDL2_ttf, SDL2_image, SDL2_gfx, SDL2_mixer }:
2
3buildPythonPackage rec {
4 pname = "PySDL2";
5 version = "0.9.9";
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 = "45879ae588038d7cf7cb0289ae47af60722b394d0efa527bf4327103dc4dc918";
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 = [
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 ];
33
34 meta = {
35 description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project";
36 homepage = "https://github.com/marcusva/py-sdl2";
37 license = lib.licenses.publicDomain;
38 maintainers = with lib.maintainers; [ pmiddend ];
39 };
40}