Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 86 lines 3.5 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchPypi, 6 pkgs, 7 pillow, 8 mesa, 9}: 10 11buildPythonPackage rec { 12 pname = "pyopengl"; 13 version = "3.1.7"; 14 format = "setuptools"; 15 16 src = fetchPypi { 17 pname = "PyOpenGL"; 18 inherit version; 19 hash = "sha256-7vMaOIjmmE/U2ObJlhsYTJgTyoJgTTf+PagOsACnbIY="; 20 }; 21 22 propagatedBuildInputs = [ pillow ]; 23 24 patchPhase = 25 let 26 ext = stdenv.hostPlatform.extensions.sharedLibrary; 27 in 28 lib.optionalString (!stdenv.hostPlatform.isDarwin) '' 29 # Theses lines are patching the name of dynamic libraries 30 # so pyopengl can find them at runtime. 31 substituteInPlace OpenGL/platform/glx.py \ 32 --replace '"OpenGL",' '"${pkgs.libGL}/lib/libOpenGL${ext}",' \ 33 --replace '"GL",' '"${pkgs.libGL}/lib/libGL${ext}",' \ 34 --replace '"GLU",' '"${pkgs.libGLU}/lib/libGLU${ext}",' \ 35 --replace '"GLX",' '"${pkgs.libglvnd}/lib/libGLX${ext}",' \ 36 --replace '"glut",' '"${pkgs.libglut}/lib/libglut${ext}",' \ 37 --replace '"GLESv1_CM",' '"${pkgs.libGL}/lib/libGLESv1_CM${ext}",' \ 38 --replace '"GLESv2",' '"${pkgs.libGL}/lib/libGLESv2${ext}",' \ 39 --replace '"gle",' '"${pkgs.gle}/lib/libgle${ext}",' \ 40 --replace "'EGL'" "'${pkgs.libGL}/lib/libEGL${ext}'" 41 substituteInPlace OpenGL/platform/egl.py \ 42 --replace "('OpenGL','GL')" "('${pkgs.libGL}/lib/libOpenGL${ext}', '${pkgs.libGL}/lib/libGL${ext}')" \ 43 --replace "'GLU'," "'${pkgs.libGLU}/lib/libGLU${ext}'," \ 44 --replace "'glut'," "'${pkgs.libglut}/lib/libglut${ext}'," \ 45 --replace "'GLESv1_CM'," "'${pkgs.libGL}/lib/libGLESv1_CM${ext}'," \ 46 --replace "'GLESv2'," "'${pkgs.libGL}/lib/libGLESv2${ext}'," \ 47 --replace "'gle'," '"${pkgs.gle}/lib/libgle${ext}",' \ 48 --replace "'EGL'," "'${pkgs.libGL}/lib/libEGL${ext}'," 49 substituteInPlace OpenGL/platform/darwin.py \ 50 --replace "'OpenGL'," "'${pkgs.libGL}/lib/libGL${ext}'," \ 51 --replace "'GLUT'," "'${pkgs.libglut}/lib/libglut${ext}'," 52 '' 53 + '' 54 # https://github.com/NixOS/nixpkgs/issues/76822 55 # pyopengl introduced a new "robust" way of loading libraries in 3.1.4. 56 # The later patch of the filepath does not work anymore because 57 # pyopengl takes the "name" (for us: the path) and tries to add a 58 # few suffix during its loading phase. 59 # The following patch put back the "name" (i.e. the path) in the 60 # list of possible files. 61 substituteInPlace OpenGL/platform/ctypesloader.py \ 62 --replace "filenames_to_try = [base_name]" "filenames_to_try = [name]" 63 ''; 64 65 # Need to fix test runner 66 # Tests have many dependencies 67 # Extension types could not be found. 68 # Should run test suite from $out/${python.sitePackages} 69 doCheck = false; # does not affect pythonImportsCheck 70 71 # OpenGL looks for libraries during import, making this a somewhat decent test of the flaky patching above. 72 pythonImportsCheck = "OpenGL"; 73 74 meta = with lib; { 75 homepage = "https://mcfletch.github.io/pyopengl/"; 76 description = "PyOpenGL, the Python OpenGL bindings"; 77 longDescription = '' 78 PyOpenGL is the cross platform Python binding to OpenGL and 79 related APIs. The binding is created using the standard (in 80 Python 2.5) ctypes library, and is provided under an extremely 81 liberal BSD-style Open-Source license. 82 ''; 83 license = licenses.bsd3; 84 inherit (mesa.meta) platforms; 85 }; 86}