20 buildPythonPackage rec {
23 disabled = pythonOlder "3.6";
26 inherit pname version;
27 hash = "sha256-JCvrGzvWfFvr3+W6EexWtpathrUMbn8qMX+NeDJWuck=";
31 # find_library doesn't reliably work with nix (https://github.com/NixOS/nixpkgs/issues/7307).
32 # Even naively searching `LD_LIBRARY_PATH` won't work since `libc.so` is a linker script and
33 # ctypes.cdll.LoadLibrary cannot deal with those. Therefore, just hardcode the paths to the
34 # necessary libraries.
36 ext = stdenv.hostPlatform.extensions.sharedLibrary;
38 cat > pyglet/lib.py <<EOF
40 def load_library(*names, **kwargs):
44 path = '${libGL}/lib/libGL${ext}'
46 path = '${libGL}/lib/libEGL${ext}'
48 path = '${libGLU}/lib/libGLU${ext}'
50 path = '${glibc}/lib/libc${ext}.6'
52 path = '${xorg.libX11}/lib/libX11${ext}'
53 elif name == 'gdk-x11-2.0':
54 path = '${gtk2-x11}/lib/libgdk-x11-2.0${ext}'
55 elif name == 'gdk_pixbuf-2.0':
56 path = '${gdk-pixbuf}/lib/libgdk_pixbuf-2.0${ext}'
58 path = '${xorg.libXext}/lib/libXext${ext}'
59 elif name == 'fontconfig':
60 path = '${fontconfig.lib}/lib/libfontconfig${ext}'
61 elif name == 'freetype':
62 path = '${freetype}/lib/libfreetype${ext}'
63 elif name[0:2] == 'av' or name[0:2] == 'sw':
64 path = '${ffmpeg-full}/lib/lib' + name + '${ext}'
65 elif name == 'openal':
66 path = '${openal}/lib/libopenal${ext}'
68 path = '${libpulseaudio}/lib/libpulse${ext}'
70 path = '${xorg.libXi}/lib/libXi${ext}'
71 elif name == 'Xinerama':
72 path = '${xorg.libXinerama}/lib/libXinerama${ext}'
73 elif name == 'Xxf86vm':
74 path = '${xorg.libXxf86vm}/lib/libXxf86vm${ext}'
76 return ctypes.cdll.LoadLibrary(path)
77 raise Exception("Could not load library {}".format(names))
81 nativeBuildInputs = [ unzip ];
83 # needs GL set up which isn't really possible in a build environment even in headless mode.
84 # tests do run and pass in nix-shell, however.
92 export PYGLET_HEADLESS=True
95 # test list taken from .travis.yml
100 "tests/unit/text/test_layout.py"
103 pythonImportsCheck = [ "pyglet" ];
106 homepage = "http://www.pyglet.org/";
107 description = "A cross-platform windowing and multimedia library";
108 license = licenses.bsd3;
109 platforms = platforms.mesaPlatforms;