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