at 25.11-pre 3.6 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchPypi, 6 unzip, 7 pythonOlder, 8 libGL, 9 libGLU, 10 xorg, 11 pytestCheckHook, 12 glibc, 13 gtk2-x11, 14 gdk-pixbuf, 15 fontconfig, 16 freetype, 17 ffmpeg-full, 18 openal, 19 libpulseaudio, 20 mesa, 21}: 22 23buildPythonPackage rec { 24 version = "2.0.10"; 25 format = "setuptools"; 26 pname = "pyglet"; 27 disabled = pythonOlder "3.6"; 28 29 src = fetchPypi { 30 inherit pname version; 31 hash = "sha256-JCvrGzvWfFvr3+W6EexWtpathrUMbn8qMX+NeDJWuck="; 32 extension = "zip"; 33 }; 34 35 # find_library doesn't reliably work with nix (https://github.com/NixOS/nixpkgs/issues/7307). 36 # Even naively searching `LD_LIBRARY_PATH` won't work since `libc.so` is a linker script and 37 # ctypes.cdll.LoadLibrary cannot deal with those. Therefore, just hardcode the paths to the 38 # necessary libraries. 39 postPatch = 40 let 41 ext = stdenv.hostPlatform.extensions.sharedLibrary; 42 in 43 '' 44 cat > pyglet/lib.py <<EOF 45 import ctypes 46 def load_library(*names, **kwargs): 47 for name in names: 48 path = None 49 if name == 'GL': 50 path = '${libGL}/lib/libGL${ext}' 51 elif name == 'EGL': 52 path = '${libGL}/lib/libEGL${ext}' 53 elif name == 'GLU': 54 path = '${libGLU}/lib/libGLU${ext}' 55 elif name == 'c': 56 path = '${glibc}/lib/libc${ext}.6' 57 elif name == 'X11': 58 path = '${xorg.libX11}/lib/libX11${ext}' 59 elif name == 'gdk-x11-2.0': 60 path = '${gtk2-x11}/lib/libgdk-x11-2.0${ext}' 61 elif name == 'gdk_pixbuf-2.0': 62 path = '${gdk-pixbuf}/lib/libgdk_pixbuf-2.0${ext}' 63 elif name == 'Xext': 64 path = '${xorg.libXext}/lib/libXext${ext}' 65 elif name == 'fontconfig': 66 path = '${fontconfig.lib}/lib/libfontconfig${ext}' 67 elif name == 'freetype': 68 path = '${freetype}/lib/libfreetype${ext}' 69 elif name[0:2] == 'av' or name[0:2] == 'sw': 70 path = '${lib.getLib ffmpeg-full}/lib/lib' + name + '${ext}' 71 elif name == 'openal': 72 path = '${openal}/lib/libopenal${ext}' 73 elif name == 'pulse': 74 path = '${libpulseaudio}/lib/libpulse${ext}' 75 elif name == 'Xi': 76 path = '${xorg.libXi}/lib/libXi${ext}' 77 elif name == 'Xinerama': 78 path = '${xorg.libXinerama}/lib/libXinerama${ext}' 79 elif name == 'Xxf86vm': 80 path = '${xorg.libXxf86vm}/lib/libXxf86vm${ext}' 81 if path is not None: 82 return ctypes.cdll.LoadLibrary(path) 83 raise Exception("Could not load library {}".format(names)) 84 EOF 85 ''; 86 87 nativeBuildInputs = [ unzip ]; 88 89 # needs GL set up which isn't really possible in a build environment even in headless mode. 90 # tests do run and pass in nix-shell, however. 91 doCheck = false; 92 93 nativeCheckInputs = [ pytestCheckHook ]; 94 95 preCheck = '' 96 export PYGLET_HEADLESS=True 97 ''; 98 99 # test list taken from .travis.yml 100 disabledTestPaths = [ 101 "tests/base" 102 "tests/interactive" 103 "tests/integration" 104 "tests/unit/text/test_layout.py" 105 ]; 106 107 pythonImportsCheck = [ "pyglet" ]; 108 109 meta = with lib; { 110 homepage = "http://www.pyglet.org/"; 111 description = "Cross-platform windowing and multimedia library"; 112 license = licenses.bsd3; 113 # The patch needs adjusting for non‐Linux platforms. 114 platforms = platforms.linux; 115 }; 116}