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