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