about summary refs log tree commit diff
path: root/pkgs/development/python-modules/pysdl2/default.nix
blob: 7854f24654320b77407c312c01e7176e8e0a1946 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  stdenv,
  lib,
  substituteAll,
  fetchPypi,
  buildPythonPackage,
  SDL2,
  SDL2_ttf,
  SDL2_image,
  SDL2_gfx,
  SDL2_mixer,
}:

buildPythonPackage rec {
  pname = "pysdl2";
  version = "0.9.16";

  # The tests use OpenGL using find_library, which would have to be
  # patched; also they seem to actually open X windows and test stuff
  # like "screensaver disabling", which would have to be cleverly
  # sandboxed. Disable for now.
  doCheck = false;
  pythonImportsCheck = [ "sdl2" ];

  src = fetchPypi {
    pname = "PySDL2";
    inherit version;
    hash = "sha256-ECdAa62+zdMP5W6AClp2rX1ycaOuwLes94DuJqAPLUA=";
  };

  # Deliberately not in propagated build inputs; users can decide
  # which library they want to include.
  buildInputs = [
    SDL2_ttf
    SDL2_image
    SDL2_gfx
    SDL2_mixer
  ];
  propagatedBuildInputs = [ SDL2 ];
  patches = [
    (substituteAll (
      {
        src = ./PySDL2-dll.patch;
      }
      //
        builtins.mapAttrs
          (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}")
          {
            # substituteAll keys must start lowercase
            sdl2 = SDL2;
            sdl2_ttf = SDL2_ttf;
            sdl2_image = SDL2_image;
            sdl2_gfx = SDL2_gfx;
            sdl2_mixer = SDL2_mixer;
          }
    ))
  ];

  meta = {
    description = "Wrapper around the SDL2 library and as such similar to the discontinued PySDL project";
    homepage = "https://github.com/marcusva/py-sdl2";
    license = lib.licenses.publicDomain;
    maintainers = with lib.maintainers; [ pmiddend ];
  };
}