1{ lib, stdenv 2, buildPythonPackage 3, fetchPypi 4, pkgs 5, pillow 6}: 7 8buildPythonPackage rec { 9 pname = "pyopengl"; 10 version = "3.1.4"; 11 12 src = fetchPypi { 13 pname = "PyOpenGL"; 14 inherit version; 15 sha256 = "0bdf5ed600df30c8830455702338902528717c0af85ac5914f1dc5aa0bfa6eee"; 16 }; 17 18 propagatedBuildInputs = [ pillow ]; 19 20 patchPhase = let 21 ext = stdenv.hostPlatform.extensions.sharedLibrary; in '' 22 # Theses lines are patching the name of dynamic libraries 23 # so pyopengl can find them at runtime. 24 substituteInPlace OpenGL/platform/glx.py \ 25 --replace "'GL'" "'${pkgs.libGL}/lib/libGL${ext}'" \ 26 --replace "'GLU'" "'${pkgs.libGLU}/lib/libGLU${ext}'" \ 27 --replace "'glut'" "'${pkgs.freeglut}/lib/libglut${ext}'" 28 substituteInPlace OpenGL/platform/darwin.py \ 29 --replace "'OpenGL'" "'${pkgs.libGL}/lib/libGL${ext}'" \ 30 --replace "'GLUT'" "'${pkgs.freeglut}/lib/libglut${ext}'" 31 32 # https://github.com/NixOS/nixpkgs/issues/76822 33 # pyopengl introduced a new "robust" way of loading libraries in 3.1.4. 34 # The later patch of the filepath does not work anymore because 35 # pyopengl takes the "name" (for us: the path) and tries to add a 36 # few suffix during its loading phase. 37 # The following patch put back the "name" (i.e. the path) in the 38 # list of possible files. 39 substituteInPlace OpenGL/platform/ctypesloader.py \ 40 --replace "filenames_to_try = []" "filenames_to_try = [name]" 41 ''; 42 43 # Need to fix test runner 44 # Tests have many dependencies 45 # Extension types could not be found. 46 # Should run test suite from $out/${python.sitePackages} 47 doCheck = false; 48 49 meta = with lib; { 50 homepage = "http://pyopengl.sourceforge.net/"; 51 description = "PyOpenGL, the Python OpenGL bindings"; 52 longDescription = '' 53 PyOpenGL is the cross platform Python binding to OpenGL and 54 related APIs. The binding is created using the standard (in 55 Python 2.5) ctypes library, and is provided under an extremely 56 liberal BSD-style Open-Source license. 57 ''; 58 license = "BSD-style"; 59 platforms = platforms.mesaPlatforms; 60 }; 61 62 63}