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.15";
6
7 # The tests use OpenGL using find_library, which would have to be
8 # patched; also they seem to actually open X windows and test stuff
9 # like "screensaver disabling", which would have to be cleverly
10 # sandboxed. Disable for now.
11 doCheck = false;
12 pythonImportsCheck = [ "sdl2" ];
13
14 src = fetchPypi {
15 inherit pname version;
16 hash = "sha256-kIp946iMKyKiwhppkXxTIVKJW9GkkFJ6Jw7hTK1A5kc=";
17 };
18
19 # Deliberately not in propagated build inputs; users can decide
20 # which library they want to include.
21 buildInputs = [ SDL2_ttf SDL2_image SDL2_gfx SDL2_mixer ];
22 propagatedBuildInputs = [ SDL2 ];
23 patches = [
24 (substituteAll ({
25 src = ./PySDL2-dll.patch;
26 } // builtins.mapAttrs (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}") {
27 # substituteAll keys must start lowercase
28 sdl2 = SDL2;
29 sdl2_ttf = SDL2_ttf;
30 sdl2_image = SDL2_image;
31 sdl2_gfx = SDL2_gfx;
32 sdl2_mixer = SDL2_mixer;
33 }))
34 ];
35
36 meta = {
37 description = "A wrapper around the SDL2 library and as such similar to the discontinued PySDL project";
38 homepage = "https://github.com/marcusva/py-sdl2";
39 license = lib.licenses.publicDomain;
40 maintainers = with lib.maintainers; [ pmiddend ];
41 };
42}