2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, buildPythonPackage
|
|
|
|
, fetchPypi
|
2021-08-22 07:53:02 +00:00
|
|
|
, unzip
|
|
|
|
, pythonOlder
|
2020-04-24 23:36:52 +00:00
|
|
|
, libGL
|
|
|
|
, libGLU
|
|
|
|
, xorg
|
2021-08-22 07:53:02 +00:00
|
|
|
, pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
, glibc
|
|
|
|
, gtk2-x11
|
|
|
|
, gdk-pixbuf
|
|
|
|
, fontconfig
|
|
|
|
, freetype
|
|
|
|
, ffmpeg-full
|
2021-08-22 07:53:02 +00:00
|
|
|
, openal
|
|
|
|
, libpulseaudio
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
2023-11-16 04:20:00 +00:00
|
|
|
version = "2.0.10";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "pyglet";
|
2021-08-22 07:53:02 +00:00
|
|
|
disabled = pythonOlder "3.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2023-11-16 04:20:00 +00:00
|
|
|
hash = "sha256-JCvrGzvWfFvr3+W6EexWtpathrUMbn8qMX+NeDJWuck=";
|
2021-08-22 07:53:02 +00:00
|
|
|
extension = "zip";
|
2020-04-24 23:36:52 +00: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.
|
|
|
|
postPatch = let
|
|
|
|
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':
|
|
|
|
path = '${libGL}/lib/libGL${ext}'
|
2021-08-22 07:53:02 +00:00
|
|
|
elif name == 'EGL':
|
|
|
|
path = '${libGL}/lib/libEGL${ext}'
|
2020-04-24 23:36:52 +00:00
|
|
|
elif name == 'GLU':
|
|
|
|
path = '${libGLU}/lib/libGLU${ext}'
|
|
|
|
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':
|
|
|
|
path = '${gdk-pixbuf}/lib/libgdk_pixbuf-2.0${ext}'
|
|
|
|
elif name == 'Xext':
|
|
|
|
path = '${xorg.libXext}/lib/libXext${ext}'
|
|
|
|
elif name == 'fontconfig':
|
|
|
|
path = '${fontconfig.lib}/lib/libfontconfig${ext}'
|
|
|
|
elif name == 'freetype':
|
|
|
|
path = '${freetype}/lib/libfreetype${ext}'
|
|
|
|
elif name[0:2] == 'av' or name[0:2] == 'sw':
|
|
|
|
path = '${ffmpeg-full}/lib/lib' + name + '${ext}'
|
2021-08-22 07:53:02 +00:00
|
|
|
elif name == 'openal':
|
|
|
|
path = '${openal}/lib/libopenal${ext}'
|
|
|
|
elif name == 'pulse':
|
|
|
|
path = '${libpulseaudio}/lib/libpulse${ext}'
|
|
|
|
elif name == 'Xi':
|
|
|
|
path = '${xorg.libXi}/lib/libXi${ext}'
|
|
|
|
elif name == 'Xinerama':
|
|
|
|
path = '${xorg.libXinerama}/lib/libXinerama${ext}'
|
|
|
|
elif name == 'Xxf86vm':
|
|
|
|
path = '${xorg.libXxf86vm}/lib/libXxf86vm${ext}'
|
2020-04-24 23:36:52 +00:00
|
|
|
if path is not None:
|
|
|
|
return ctypes.cdll.LoadLibrary(path)
|
|
|
|
raise Exception("Could not load library {}".format(names))
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
nativeBuildInputs = [ unzip ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
# needs GL set up which isn't really possible in a build environment even in headless mode.
|
|
|
|
# tests do run and pass in nix-shell, however.
|
2020-04-24 23:36:52 +00:00
|
|
|
doCheck = false;
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2021-08-22 07:53:02 +00:00
|
|
|
pytestCheckHook
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
preCheck = ''
|
|
|
|
export PYGLET_HEADLESS=True
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
# test list taken from .travis.yml
|
|
|
|
disabledTestPaths = [
|
|
|
|
"tests/base"
|
|
|
|
"tests/interactive"
|
|
|
|
"tests/integration"
|
|
|
|
"tests/unit/text/test_layout.py"
|
|
|
|
];
|
|
|
|
|
|
|
|
pythonImportsCheck = [ "pyglet" ];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.pyglet.org/";
|
|
|
|
description = "A cross-platform windowing and multimedia library";
|
|
|
|
license = licenses.bsd3;
|
|
|
|
platforms = platforms.mesaPlatforms;
|
|
|
|
};
|
|
|
|
}
|