at master 2.2 kB view raw
1{ 2 stdenv, 3 lib, 4 replaceVars, 5 fetchFromGitHub, 6 buildPythonPackage, 7 setuptools, 8 9 # native dependencies 10 SDL2, 11 SDL2_ttf, 12 SDL2_image, 13 SDL2_gfx, 14 SDL2_mixer, 15 16 # tests 17 numpy, 18 pillow, 19 pytestCheckHook, 20}: 21 22buildPythonPackage rec { 23 pname = "pysdl2"; 24 version = "0.9.17-unstable-2025-04-03"; 25 pyproject = true; 26 27 pythonImportsCheck = [ "sdl2" ]; 28 29 src = fetchFromGitHub { 30 owner = "py-sdl"; 31 repo = "py-sdl2"; 32 rev = "6414ee1c5f4a6eb91b71f5f9e35d469eee395b9f"; 33 hash = "sha256-E6Jpuin4bqDkvFTaZTsTNkNQJd2e5fuTf2oLsQ71uQ0="; 34 }; 35 36 patches = [ 37 (replaceVars ./PySDL2-dll.patch ( 38 (builtins.mapAttrs 39 (_: pkg: "${pkg}/lib/lib${pkg.pname}${stdenv.hostPlatform.extensions.sharedLibrary}") 40 { 41 inherit 42 SDL2_ttf 43 SDL2_image 44 SDL2_gfx 45 SDL2_mixer 46 ; 47 } 48 ) 49 // { 50 # sdl2-compat has the pname sdl2-compat, 51 # but the shared object is named libSDL2.so for compatibility reasons. 52 # This requires making the shared object path for SDL2 not depend on pname. 53 SDL2 = (pkg: "${pkg}/lib/libSDL2${stdenv.hostPlatform.extensions.sharedLibrary}") SDL2; 54 } 55 )) 56 ]; 57 58 build-system = [ setuptools ]; 59 60 buildInputs = [ 61 SDL2 62 SDL2_ttf 63 SDL2_image 64 SDL2_gfx 65 SDL2_mixer 66 ]; 67 68 env = { 69 SDL_VIDEODRIVER = "dummy"; 70 SDL_AUDIODRIVER = "dummy"; 71 SDL_RENDER_DRIVER = "software"; 72 PYTHONFAULTHANDLER = "1"; 73 }; 74 75 nativeCheckInputs = [ 76 numpy 77 pillow 78 pytestCheckHook 79 ]; 80 81 disabledTests = [ 82 # GetPrefPath for OrgName/AppName is None 83 "test_SDL_GetPrefPath" 84 85 # TODO: Remove once sdl2-compat is updated to 2.32.56 86 "test_SDL_SetWindowDisplayMode" 87 "test_SDL_SetWindowFullscreen" 88 "test_SDL_GetPlatform" 89 ]; 90 91 meta = { 92 changelog = "https://github.com/py-sdl/py-sdl2/compare/0.9.17..${src.rev}"; 93 description = "Wrapper around the SDL2 library and as such similar to the discontinued PySDL project"; 94 homepage = "https://github.com/py-sdl/py-sdl2"; 95 license = lib.licenses.publicDomain; 96 maintainers = with lib.maintainers; [ pmiddend ]; 97 }; 98}