at 23.05-pre 2.2 kB view raw
1{ stdenv, lib, substituteAll, fetchFromGitHub, buildPythonPackage, python, pkg-config, libX11 2, SDL2, SDL2_image, SDL2_mixer, SDL2_ttf, libpng, libjpeg, portmidi, freetype, fontconfig 3, AppKit 4}: 5 6buildPythonPackage rec { 7 pname = "pygame"; 8 version = "2.1.2"; 9 10 src = fetchFromGitHub { 11 owner = pname; 12 repo = pname; 13 rev = version; 14 # Unicode file names lead to different checksums on HFS+ vs. other 15 # filesystems because of unicode normalisation. The documentation 16 # has such files and will be removed. 17 sha256 = "sha256-v1z6caEMJNXqbcbTmFXoy3KQewHiz6qK4vhNU6Qbukk="; 18 postFetch = "rm -rf $out/docs/reST"; 19 }; 20 21 patches = [ 22 # Patch pygame's dependency resolution to let it find build inputs 23 (substituteAll { 24 src = ./fix-dependency-finding.patch; 25 buildinputs_include = builtins.toJSON (builtins.concatMap (dep: [ 26 "${lib.getDev dep}/" 27 "${lib.getDev dep}/include" 28 "${lib.getDev dep}/include/SDL2" 29 ]) buildInputs); 30 buildinputs_lib = builtins.toJSON (builtins.concatMap (dep: [ 31 "${lib.getLib dep}/" 32 "${lib.getLib dep}/lib" 33 ]) buildInputs); 34 }) 35 ]; 36 37 postPatch = '' 38 substituteInPlace src_py/sysfont.py \ 39 --replace 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \ 40 --replace /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list 41 ''; 42 43 nativeBuildInputs = [ 44 pkg-config SDL2 45 ]; 46 47 buildInputs = [ 48 SDL2 SDL2_image SDL2_mixer SDL2_ttf libpng libjpeg 49 portmidi libX11 freetype 50 ] ++ lib.optionals stdenv.isDarwin [ 51 AppKit 52 ]; 53 54 preConfigure = '' 55 ${python.interpreter} buildconfig/config.py 56 ''; 57 58 checkPhase = '' 59 runHook preCheck 60 61 # No audio or video device in test environment 62 export SDL_VIDEODRIVER=dummy 63 export SDL_AUDIODRIVER=disk 64 export SDL_DISKAUDIOFILE=/dev/null 65 66 ${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300 67 68 runHook postCheck 69 ''; 70 pythonImportsCheck = [ "pygame" ]; 71 72 meta = with lib; { 73 description = "Python library for games"; 74 homepage = "https://www.pygame.org/"; 75 license = licenses.lgpl21Plus; 76 maintainers = with maintainers; [ emilytrau ]; 77 platforms = platforms.unix; 78 }; 79}