1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-12-16 09:53:17 +00:00
nixpkgs/pkgs/development/python-modules/pyglet/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

85 lines
2.4 KiB
Nix

{ lib, stdenv
, buildPythonPackage
, fetchPypi
, libGL
, libGLU
, xorg
, future
, pytest
, glibc
, gtk2-x11
, gdk-pixbuf
, fontconfig
, freetype
, ffmpeg-full
}:
buildPythonPackage rec {
version = "1.4.2";
pname = "pyglet";
src = fetchPypi {
inherit pname version;
sha256 = "1dxxrl4nc7xh3aai1clgzvk48bvd35r7ksirsddz0mwhx7jmm8px";
};
# 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}'
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}'
if path is not None:
return ctypes.cdll.LoadLibrary(path)
raise Exception("Could not load library {}".format(names))
EOF
'';
propagatedBuildInputs = [ future ];
# needs an X server. Keep an eye on
# https://bitbucket.org/pyglet/pyglet/issues/219/egl-support-headless-rendering
doCheck = false;
checkInputs = [
pytest
];
checkPhase = ''
py.test tests/unit tests/integration
'';
meta = with lib; {
homepage = "http://www.pyglet.org/";
description = "A cross-platform windowing and multimedia library";
license = licenses.bsd3;
platforms = platforms.mesaPlatforms;
};
}