at 22.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.0"; 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-Pe7BJ+8rXw+hhRv64fI+79gJcU1npQFFAXxECx2+Trw="; 18 extraPostFetch = "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 ]) buildInputs); 29 buildinputs_lib = builtins.toJSON (builtins.concatMap (dep: [ 30 "${lib.getLib dep}/" 31 "${lib.getLib dep}/lib" 32 ]) buildInputs); 33 }) 34 ]; 35 36 postPatch = '' 37 substituteInPlace src_py/sysfont.py \ 38 --replace 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \ 39 --replace /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list 40 ''; 41 42 nativeBuildInputs = [ 43 pkg-config SDL2 44 ]; 45 46 buildInputs = [ 47 SDL2 SDL2_image SDL2_mixer SDL2_ttf libpng libjpeg 48 portmidi libX11 freetype 49 ] ++ lib.optionals stdenv.isDarwin [ 50 AppKit 51 ]; 52 53 preConfigure = '' 54 ${python.interpreter} buildconfig/config.py 55 ''; 56 57 checkPhase = '' 58 runHook preCheck 59 60 # No audio or video device in test environment 61 export SDL_VIDEODRIVER=dummy 62 export SDL_AUDIODRIVER=disk 63 export SDL_DISKAUDIOFILE=/dev/null 64 65 ${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300 66 67 runHook postCheck 68 ''; 69 pythonImportsCheck = [ "pygame" ]; 70 71 meta = with lib; { 72 description = "Python library for games"; 73 homepage = "https://www.pygame.org/"; 74 license = licenses.lgpl21Plus; 75 maintainers = with maintainers; [ angustrau ]; 76 platforms = platforms.unix; 77 }; 78}