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