11 buildPythonPackage rec {
14 format = "setuptools";
19 hash = "sha256-7vMaOIjmmE/U2ObJlhsYTJgTyoJgTTf+PagOsACnbIY=";
22 propagatedBuildInputs = [ pillow ];
26 ext = stdenv.hostPlatform.extensions.sharedLibrary;
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}',"
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]"
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
71 # OpenGL looks for libraries during import, making this a somewhat decent test of the flaky patching above.
72 pythonImportsCheck = "OpenGL";
75 homepage = "https://mcfletch.github.io/pyopengl/";
76 description = "PyOpenGL, the Python OpenGL bindings";
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.
83 license = licenses.bsd3;
84 inherit (mesa.meta) platforms;