<commit_before>{ stdenv
, buildPythonPackage
, fetchPypi
, libGL
, libGLU
, xorg
, future
, pytest
, glibc
, gtk2-x11
, gdk-pixbuf
, fontconfig
, freetype
}:

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 = '${libGL}/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}'<commit_msg>pythonPackages.pyglet: fix libGLU path<commit_after>{ stdenv
, buildPythonPackage
, fetchPypi
, libGL
, libGLU
, xorg
, future
, pytest
, glibc
, gtk2-x11
, gdk-pixbuf
, fontconfig
, freetype
}:

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}'
{'fraction_non_alphanumeric': 0.138217000691085, 'fraction_numerical': 0.0331720801658604, 'mean_word_length': 2.3237657864523538, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1882536', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1041, 'n_words': 224}