Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 169 lines 4.0 kB view raw
1{ 2 stdenv, 3 lib, 4 replaceVars, 5 fetchFromGitHub, 6 buildPythonPackage, 7 pythonOlder, 8 python, 9 pkg-config, 10 setuptools, 11 cython, 12 ninja, 13 meson-python, 14 15 fontconfig, 16 freetype, 17 libjpeg, 18 libpng, 19 libX11, 20 portmidi, 21 SDL2, 22 SDL2_image, 23 SDL2_mixer, 24 SDL2_ttf, 25 numpy, 26 27 pygame-gui, 28}: 29 30buildPythonPackage rec { 31 pname = "pygame-ce"; 32 version = "2.5.3"; 33 pyproject = true; 34 35 disabled = pythonOlder "3.8"; 36 37 src = fetchFromGitHub { 38 owner = "pygame-community"; 39 repo = "pygame-ce"; 40 tag = version; 41 hash = "sha256-Vl9UwCknbMHdsB1wwo/JqybWz3UbAMegIcO0GpiCxig="; 42 # Unicode files cause different checksums on HFS+ vs. other filesystems 43 postFetch = "rm -rf $out/docs/reST"; 44 }; 45 46 patches = [ 47 (replaceVars ./fix-dependency-finding.patch { 48 buildinputs_include = builtins.toJSON ( 49 builtins.concatMap (dep: [ 50 "${lib.getDev dep}/" 51 "${lib.getDev dep}/include" 52 "${lib.getDev dep}/include/SDL2" 53 ]) buildInputs 54 ); 55 buildinputs_lib = builtins.toJSON ( 56 builtins.concatMap (dep: [ 57 "${lib.getLib dep}/" 58 "${lib.getLib dep}/lib" 59 ]) buildInputs 60 ); 61 }) 62 # https://github.com/libsdl-org/sdl2-compat/issues/476 63 ./skip-rle-tests.patch 64 ]; 65 66 postPatch = 67 '' 68 # cython was pinned to fix windows build hangs (pygame-community/pygame-ce/pull/3015) 69 substituteInPlace pyproject.toml \ 70 --replace-fail '"meson<=1.7.0",' '"meson",' \ 71 --replace-fail '"meson-python<=0.17.1",' '"meson-python",' \ 72 --replace-fail '"ninja<=1.12.1",' "" \ 73 --replace-fail '"cython<=3.0.11",' '"cython",' \ 74 --replace-fail '"sphinx<=8.1.3",' "" \ 75 --replace-fail '"sphinx-autoapi<=3.3.2",' "" 76 substituteInPlace buildconfig/config_{unix,darwin}.py \ 77 --replace-fail 'from distutils' 'from setuptools._distutils' 78 substituteInPlace src_py/sysfont.py \ 79 --replace-fail 'path="fc-list"' 'path="${fontconfig}/bin/fc-list"' \ 80 --replace-fail /usr/X11/bin/fc-list ${fontconfig}/bin/fc-list 81 '' 82 + lib.optionalString stdenv.hostPlatform.isDarwin '' 83 # flaky 84 rm test/system_test.py 85 substituteInPlace test/meson.build \ 86 --replace-fail "'system_test.py'," "" 87 ''; 88 89 nativeBuildInputs = [ 90 pkg-config 91 cython 92 setuptools 93 ninja 94 meson-python 95 ]; 96 97 buildInputs = [ 98 freetype 99 libX11 100 libjpeg 101 libpng 102 portmidi 103 SDL2 104 (SDL2_image.override { enableSTB = false; }) 105 SDL2_mixer 106 SDL2_ttf 107 ]; 108 109 nativeCheckInputs = [ 110 numpy 111 ]; 112 113 preConfigure = '' 114 ${python.pythonOnBuildForHost.interpreter} -m buildconfig.config 115 ''; 116 117 env = 118 { 119 SDL_CONFIG = lib.getExe' (lib.getDev SDL2) "sdl2-config"; 120 } 121 // lib.optionalAttrs stdenv.cc.isClang { 122 NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-function-pointer-types"; 123 }; 124 125 preCheck = '' 126 export HOME=$(mktemp -d) 127 # No audio or video device in test environment 128 export SDL_VIDEODRIVER=dummy 129 export SDL_AUDIODRIVER=disk 130 # traceback for segfaults 131 export PYTHONFAULTHANDLER=1 132 ''; 133 134 checkPhase = '' 135 runHook preCheck 136 ${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300 137 runHook postCheck 138 ''; 139 140 pythonImportsCheck = [ 141 "pygame" 142 "pygame.camera" 143 "pygame.colordict" 144 "pygame.cursors" 145 "pygame.freetype" 146 "pygame.ftfont" 147 "pygame.locals" 148 "pygame.midi" 149 "pygame.pkgdata" 150 "pygame.sndarray" # requires numpy 151 "pygame.sprite" 152 "pygame.surfarray" 153 "pygame.sysfont" 154 "pygame.version" 155 ]; 156 157 passthru.tests = { 158 inherit pygame-gui; 159 }; 160 161 meta = { 162 description = "Pygame Community Edition (CE) - library for multimedia application built on SDL"; 163 homepage = "https://pyga.me/"; 164 changelog = "https://github.com/pygame-community/pygame-ce/releases/tag/${src.tag}"; 165 license = lib.licenses.lgpl21Plus; 166 maintainers = [ lib.maintainers.pbsds ]; 167 platforms = lib.platforms.unix; 168 }; 169}