23 buildPythonPackage rec {
25 format = "setuptools";
27 disabled = pythonOlder "3.6";
30 inherit pname version;
31 hash = "sha256-JCvrGzvWfFvr3+W6EexWtpathrUMbn8qMX+NeDJWuck=";
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.
41 ext = stdenv.hostPlatform.extensions.sharedLibrary;
44 cat > pyglet/lib.py <<EOF
46 def load_library(*names, **kwargs):
50 path = '${libGL}/lib/libGL${ext}'
52 path = '${libGL}/lib/libEGL${ext}'
54 path = '${libGLU}/lib/libGLU${ext}'
56 path = '${glibc}/lib/libc${ext}.6'
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}'
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}'
74 path = '${libpulseaudio}/lib/libpulse${ext}'
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}'
82 return ctypes.cdll.LoadLibrary(path)
83 raise Exception("Could not load library {}".format(names))
87 nativeBuildInputs = [ unzip ];
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.
93 nativeCheckInputs = [ pytestCheckHook ];
96 export PYGLET_HEADLESS=True
99 # test list taken from .travis.yml
100 disabledTestPaths = [
104 "tests/unit/text/test_layout.py"
107 pythonImportsCheck = [ "pyglet" ];
110 homepage = "http://www.pyglet.org/";
111 description = "Cross-platform windowing and multimedia library";
112 license = licenses.bsd3;
113 inherit (mesa.meta) platforms;