at master 2.4 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 fetchFromGitHub, 6 python, 7 buildPythonPackage, 8 setuptools-scm, 9 packaging, 10 aiohttp, 11 requests, 12 13 # native dependencies 14 sdl3, 15 sdl3-ttf, 16 sdl3-image, 17}: 18 19let 20 dochash = 21 if stdenv.hostPlatform.isLinux then 22 "sha256-d2YQUBWRlDROwiDMJ5mQAR9o+cYsbv1jiulsr1SAaik=" 23 else if stdenv.hostPlatform.isDarwin then 24 "sha256-eIzTsn4wYz7TEyWN8QssM7fxpMfz/ENlxDVUMz0Cm4c=" 25 else if stdenv.hostPlatform.isWindows then 26 "sha256-+iagR5jvpHi8WDh4/DO+GDP6jajEpZ6G1ROhM+zkSiw=" 27 else 28 throw "PySDL3 does not support ${stdenv.hostPlatform.uname.system}"; 29 lib_ext = stdenv.hostPlatform.extensions.sharedLibrary; 30in 31buildPythonPackage rec { 32 pname = "pysdl3"; 33 version = "0.9.8b9"; 34 pyproject = true; 35 36 pythonImportsCheck = [ "sdl3" ]; 37 38 src = fetchFromGitHub { 39 owner = "Aermoss"; 40 repo = "PySDL3"; 41 tag = "v${version}"; 42 hash = "sha256-TpfMpp8CGb8lYALCWlMtyucxObDg1VYEvBW+mVHN9JM="; 43 }; 44 45 docfile = fetchurl { 46 url = "https://github.com/Aermoss/PySDL3/releases/download/v${version}/${stdenv.hostPlatform.uname.system}-Docs.py"; 47 hash = "${dochash}"; 48 }; 49 50 postUnpack = '' 51 cp ${docfile} source/sdl3/__doc__.py 52 ''; 53 54 postInstall = '' 55 mkdir $out/${python.sitePackages}/sdl3/bin 56 ln -s ${sdl3}/lib/libSDL3${lib_ext} -t $out/${python.sitePackages}/sdl3/bin 57 ln -s ${sdl3-ttf}/lib/libSDL3_ttf${lib_ext} -t $out/${python.sitePackages}/sdl3/bin 58 ln -s ${sdl3-image}/lib/libSDL3_image${lib_ext} -t $out/${python.sitePackages}/sdl3/bin 59 ''; 60 61 build-system = [ 62 setuptools-scm 63 ]; 64 65 buildInputs = [ 66 sdl3 67 sdl3-ttf 68 sdl3-image 69 ]; 70 71 dependencies = [ 72 packaging 73 aiohttp 74 requests 75 ]; 76 77 # PySDL3 tries to update both itself and SDL binaries at runtime. This hook 78 # sets some env variables to tell it not to do that. 79 setupHook = ./setup-hook.sh; 80 81 env = { 82 SDL_VIDEODRIVER = "dummy"; 83 SDL_AUDIODRIVER = "dummy"; 84 SDL_RENDER_DRIVER = "software"; 85 PYTHONFAULTHANDLER = "1"; 86 }; 87 88 meta = { 89 description = "Pure Python wrapper for SDL3"; 90 homepage = "https://github.com/Aermoss/PySDL3"; 91 license = lib.licenses.mit; 92 maintainers = with lib.maintainers; [ jansol ]; 93 platforms = [ 94 "aarch64-linux" 95 "x86_64-linux" 96 "aarch64-windows" 97 "x86_64-windows" 98 "aarch64-darwin" 99 "x86_64-darwin" 100 ]; 101 }; 102}