Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 167 lines 3.9 kB view raw
1{ 2 stdenv, 3 lib, 4 substituteAll, 5 fetchFromGitHub, 6 buildPythonPackage, 7 pythonOlder, 8 python, 9 pkg-config, 10 setuptools, 11 cython, 12 ninja, 13 meson-python, 14 15 AppKit, 16 fontconfig, 17 freetype, 18 libjpeg, 19 libpng, 20 libX11, 21 portmidi, 22 SDL2, 23 SDL2_image, 24 SDL2_mixer, 25 SDL2_ttf, 26 numpy, 27 28 pygame-gui, 29}: 30 31buildPythonPackage rec { 32 pname = "pygame-ce"; 33 version = "2.5.2"; 34 pyproject = true; 35 36 disabled = pythonOlder "3.8"; 37 38 src = fetchFromGitHub { 39 owner = "pygame-community"; 40 repo = "pygame-ce"; 41 rev = "refs/tags/${version}"; 42 hash = "sha256-9e02ZfBfk18jsVDKKhMwEJiTGMG7VdBEgVh4unMJguY="; 43 # Unicode file cause different checksums on HFS+ vs. other filesystems 44 postFetch = "rm -rf $out/docs/reST"; 45 }; 46 47 patches = [ 48 (substituteAll { 49 src = ./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 # Skip tests that should be disabled without video driver 65 ./skip-surface-tests.patch 66 ]; 67 68 postPatch = 69 '' 70 # cython was pinned to fix windows build hangs (pygame-community/pygame-ce/pull/3015) 71 substituteInPlace pyproject.toml \ 72 --replace-fail '"meson<=1.5.1",' '"meson",' \ 73 --replace-fail '"ninja<=1.11.1.1",' "" \ 74 --replace-fail '"cython<=3.0.11",' '"cython",' \ 75 --replace-fail '"sphinx<=7.2.6",' "" 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 105 SDL2_mixer 106 SDL2_ttf 107 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ AppKit ]; 108 109 nativeCheckInputs = [ 110 numpy 111 ]; 112 113 preConfigure = '' 114 ${python.pythonOnBuildForHost.interpreter} -m buildconfig.config 115 ''; 116 117 env = 118 { 119 SDL_CONFIG = "${SDL2.dev}/bin/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 ''; 131 132 checkPhase = '' 133 runHook preCheck 134 ${python.interpreter} -m pygame.tests -v --exclude opengl,timing --time_out 300 135 runHook postCheck 136 ''; 137 138 pythonImportsCheck = [ 139 "pygame" 140 "pygame.camera" 141 "pygame.colordict" 142 "pygame.cursors" 143 "pygame.freetype" 144 "pygame.ftfont" 145 "pygame.locals" 146 "pygame.midi" 147 "pygame.pkgdata" 148 "pygame.sndarray" # requires numpy 149 "pygame.sprite" 150 "pygame.surfarray" 151 "pygame.sysfont" 152 "pygame.version" 153 ]; 154 155 passthru.tests = { 156 inherit pygame-gui; 157 }; 158 159 meta = { 160 description = "Pygame Community Edition (CE) - library for multimedia application built on SDL"; 161 homepage = "https://pyga.me/"; 162 changelog = "https://github.com/pygame-community/pygame-ce/releases/tag/${version}"; 163 license = lib.licenses.lgpl21Plus; 164 maintainers = [ lib.maintainers.pbsds ]; 165 platforms = lib.platforms.unix; 166 }; 167}