1{
2 stdenv,
3 lib,
4 substituteAll,
5 fetchPypi,
6 buildPythonPackage,
7 SDL2,
8 SDL2_ttf,
9 SDL2_image,
10 SDL2_gfx,
11 SDL2_mixer,
12}:
13
14buildPythonPackage rec {
15 pname = "pysdl2";
16 version = "0.9.16";
17
18 # The tests use OpenGL using find_library, which would have to be
19 # patched; also they seem to actually open X windows and test stuff
20 # like "screensaver disabling", which would have to be cleverly
21 # sandboxed. Disable for now.
22 doCheck = false;
23 pythonImportsCheck = [ "sdl2" ];
24
25 src = fetchPypi {
26 pname = "PySDL2";
27 inherit version;
28 hash = "sha256-ECdAa62+zdMP5W6AClp2rX1ycaOuwLes94DuJqAPLUA=";
29 };
30
31 # Deliberately not in propagated build inputs; users can decide
32 # which library they want to include.
33 buildInputs = [
34 SDL2_ttf
35 SDL2_image
36 SDL2_gfx
37 SDL2_mixer
38 ];
39 propagatedBuildInputs = [ SDL2 ];
40 patches = [
41 (substituteAll (
42 {
43 src = ./PySDL2-dll.patch;
44 }
45 //
46 builtins.mapAttrs
47 (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}")
48 {
49 # substituteAll keys must start lowercase
50 sdl2 = SDL2;
51 sdl2_ttf = SDL2_ttf;
52 sdl2_image = SDL2_image;
53 sdl2_gfx = SDL2_gfx;
54 sdl2_mixer = SDL2_mixer;
55 }
56 ))
57 ];
58
59 meta = {
60 description = "Wrapper around the SDL2 library and as such similar to the discontinued PySDL project";
61 homepage = "https://github.com/marcusva/py-sdl2";
62 license = lib.licenses.publicDomain;
63 maintainers = with lib.maintainers; [ pmiddend ];
64 };
65}