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