Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.09 2.5 kB view raw
1{ stdenv 2, buildPythonPackage 3, fetchPypi 4, libGL 5, libGLU 6, xorg 7, future 8, pytest 9, glibc 10, gtk2-x11 11, gdk-pixbuf 12, fontconfig 13, freetype 14, ffmpeg-full 15}: 16 17buildPythonPackage rec { 18 version = "1.4.2"; 19 pname = "pyglet"; 20 21 src = fetchPypi { 22 inherit pname version; 23 sha256 = "1dxxrl4nc7xh3aai1clgzvk48bvd35r7ksirsddz0mwhx7jmm8px"; 24 }; 25 26 # find_library doesn't reliably work with nix (https://github.com/NixOS/nixpkgs/issues/7307). 27 # Even naively searching `LD_LIBRARY_PATH` won't work since `libc.so` is a linker script and 28 # ctypes.cdll.LoadLibrary cannot deal with those. Therefore, just hardcode the paths to the 29 # necessary libraries. 30 postPatch = let 31 ext = stdenv.hostPlatform.extensions.sharedLibrary; 32 in '' 33 cat > pyglet/lib.py <<EOF 34 import ctypes 35 def load_library(*names, **kwargs): 36 for name in names: 37 path = None 38 if name == 'GL': 39 path = '${libGL}/lib/libGL${ext}' 40 elif name == 'GLU': 41 path = '${libGLU}/lib/libGLU${ext}' 42 elif name == 'c': 43 path = '${glibc}/lib/libc${ext}.6' 44 elif name == 'X11': 45 path = '${xorg.libX11}/lib/libX11${ext}' 46 elif name == 'gdk-x11-2.0': 47 path = '${gtk2-x11}/lib/libgdk-x11-2.0${ext}' 48 elif name == 'gdk_pixbuf-2.0': 49 path = '${gdk-pixbuf}/lib/libgdk_pixbuf-2.0${ext}' 50 elif name == 'Xext': 51 path = '${xorg.libXext}/lib/libXext${ext}' 52 elif name == 'fontconfig': 53 path = '${fontconfig.lib}/lib/libfontconfig${ext}' 54 elif name == 'freetype': 55 path = '${freetype}/lib/libfreetype${ext}' 56 elif name[0:2] == 'av' or name[0:2] == 'sw': 57 path = '${ffmpeg-full}/lib/lib' + name + '${ext}' 58 if path is not None: 59 return ctypes.cdll.LoadLibrary(path) 60 raise Exception("Could not load library {}".format(names)) 61 EOF 62 ''; 63 64 propagatedBuildInputs = [ future ]; 65 66 # needs an X server. Keep an eye on 67 # https://bitbucket.org/pyglet/pyglet/issues/219/egl-support-headless-rendering 68 doCheck = false; 69 70 checkInputs = [ 71 pytest 72 ]; 73 74 checkPhase = '' 75 py.test tests/unit tests/integration 76 ''; 77 78 meta = with stdenv.lib; { 79 homepage = "http://www.pyglet.org/"; 80 description = "A cross-platform windowing and multimedia library"; 81 license = licenses.bsd3; 82 platforms = platforms.mesaPlatforms; 83 }; 84}