pythonPackages.pyopengl: fix runtime shared library loading failure

This closes #76822.

pyopengl 3.1.4 introduced a new logic for shared library loading: it
tests a few combinations of library name and suffix (such as .so.X).

Our previous patch was just replacing the library name (e.g. 'glut') by
the full path to the nix store. This does not work anymore with pyopengl
3.1.4 new heuristic.

This commit just keep the behavior of pyopengl but adds the nix store
path to the list of tried paths.
This commit is contained in:
Guillaume Bouchard 2020-02-03 11:52:40 +01:00 committed by Jon
parent a850d0a83d
commit 5c11e174b2

View File

@ -19,6 +19,8 @@ buildPythonPackage rec {
patchPhase = let
ext = stdenv.hostPlatform.extensions.sharedLibrary; in ''
# Theses lines are patching the name of dynamic libraries
# so pyopengl can find them at runtime.
substituteInPlace OpenGL/platform/glx.py \
--replace "'GL'" "'${pkgs.libGL}/lib/libGL${ext}'" \
--replace "'GLU'" "'${pkgs.libGLU}/lib/libGLU${ext}'" \
@ -26,6 +28,16 @@ buildPythonPackage rec {
substituteInPlace OpenGL/platform/darwin.py \
--replace "'OpenGL'" "'${pkgs.libGL}/lib/libGL${ext}'" \
--replace "'GLUT'" "'${pkgs.freeglut}/lib/libglut${ext}'"
# https://github.com/NixOS/nixpkgs/issues/76822
# pyopengl introduced a new "robust" way of loading libraries in 3.1.4.
# The later patch of the filepath does not work anymore because
# pyopengl takes the "name" (for us: the path) and tries to add a
# few suffix during its loading phase.
# The following patch put back the "name" (i.e. the path) in the
# list of possible files.
substituteInPlace OpenGL/platform/ctypesloader.py \
--replace "filenames_to_try = []" "filenames_to_try = [name]"
'';
# Need to fix test runner