2019-05-28 12:44:29 +01:00
|
|
|
{ stdenv
|
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
2019-11-10 16:44:34 +00:00
|
|
|
, libGL
|
|
|
|
, libGLU
|
2019-05-28 12:44:29 +01:00
|
|
|
, xorg
|
|
|
|
, future
|
|
|
|
, pytest
|
|
|
|
, glibc
|
|
|
|
, gtk2-x11
|
2019-05-22 12:03:39 +01:00
|
|
|
, gdk-pixbuf
|
2019-10-11 08:15:42 +01:00
|
|
|
, fontconfig
|
|
|
|
, freetype
|
2020-03-10 06:58:50 +00:00
|
|
|
, ffmpeg-full
|
2019-05-28 12:44:29 +01:00
|
|
|
}:
|
2017-08-31 15:02:11 +01:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2019-08-20 12:55:20 +01:00
|
|
|
version = "1.4.2";
|
2017-08-31 15:02:11 +01:00
|
|
|
pname = "pyglet";
|
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2019-08-20 12:55:20 +01:00
|
|
|
sha256 = "1dxxrl4nc7xh3aai1clgzvk48bvd35r7ksirsddz0mwhx7jmm8px";
|
2017-08-31 15:02:11 +01:00
|
|
|
};
|
|
|
|
|
2019-05-28 12:44:29 +01:00
|
|
|
# find_library doesn't reliably work with nix (https://github.com/NixOS/nixpkgs/issues/7307).
|
|
|
|
# Even naively searching `LD_LIBRARY_PATH` won't work since `libc.so` is a linker script and
|
|
|
|
# ctypes.cdll.LoadLibrary cannot deal with those. Therefore, just hardcode the paths to the
|
|
|
|
# necessary libraries.
|
2017-12-31 10:11:32 +00:00
|
|
|
postPatch = let
|
2019-05-28 12:44:29 +01:00
|
|
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in ''
|
|
|
|
cat > pyglet/lib.py <<EOF
|
|
|
|
import ctypes
|
|
|
|
def load_library(*names, **kwargs):
|
|
|
|
for name in names:
|
|
|
|
path = None
|
|
|
|
if name == 'GL':
|
2019-11-10 16:44:34 +00:00
|
|
|
path = '${libGL}/lib/libGL${ext}'
|
2019-05-28 12:44:29 +01:00
|
|
|
elif name == 'GLU':
|
2019-11-26 15:38:22 +00:00
|
|
|
path = '${libGLU}/lib/libGLU${ext}'
|
2019-05-28 12:44:29 +01:00
|
|
|
elif name == 'c':
|
|
|
|
path = '${glibc}/lib/libc${ext}.6'
|
|
|
|
elif name == 'X11':
|
|
|
|
path = '${xorg.libX11}/lib/libX11${ext}'
|
|
|
|
elif name == 'gdk-x11-2.0':
|
|
|
|
path = '${gtk2-x11}/lib/libgdk-x11-2.0${ext}'
|
|
|
|
elif name == 'gdk_pixbuf-2.0':
|
2019-05-22 12:03:39 +01:00
|
|
|
path = '${gdk-pixbuf}/lib/libgdk_pixbuf-2.0${ext}'
|
2019-11-02 13:11:31 +00:00
|
|
|
elif name == 'Xext':
|
|
|
|
path = '${xorg.libXext}/lib/libXext${ext}'
|
2019-10-11 08:15:42 +01:00
|
|
|
elif name == 'fontconfig':
|
|
|
|
path = '${fontconfig.lib}/lib/libfontconfig${ext}'
|
|
|
|
elif name == 'freetype':
|
|
|
|
path = '${freetype}/lib/libfreetype${ext}'
|
2020-03-10 06:58:50 +00:00
|
|
|
elif name[0:2] == 'av' or name[0:2] == 'sw':
|
|
|
|
path = '${ffmpeg-full}/lib/lib' + name + '${ext}'
|
2019-05-28 12:44:29 +01:00
|
|
|
if path is not None:
|
|
|
|
return ctypes.cdll.LoadLibrary(path)
|
|
|
|
raise Exception("Could not load library {}".format(names))
|
|
|
|
EOF
|
|
|
|
'';
|
2017-08-31 15:02:11 +01:00
|
|
|
|
2019-05-28 12:44:29 +01:00
|
|
|
propagatedBuildInputs = [ future ];
|
|
|
|
|
|
|
|
# needs an X server. Keep an eye on
|
|
|
|
# https://bitbucket.org/pyglet/pyglet/issues/219/egl-support-headless-rendering
|
2017-08-31 15:02:11 +01:00
|
|
|
doCheck = false;
|
|
|
|
|
2019-05-28 12:44:29 +01:00
|
|
|
checkInputs = [
|
|
|
|
pytest
|
|
|
|
];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
py.test tests/unit tests/integration
|
|
|
|
'';
|
2017-12-31 10:11:32 +00:00
|
|
|
|
2017-08-31 15:02:11 +01:00
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = "http://www.pyglet.org/";
|
|
|
|
description = "A cross-platform windowing and multimedia library";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.mesaPlatforms;
|
|
|
|
};
|
|
|
|
}
|