2024-06-05 15:53:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
buildPythonPackage,
|
|
|
|
fetchPypi,
|
|
|
|
pkgs,
|
|
|
|
pillow,
|
2024-09-19 14:19:46 +00:00
|
|
|
mesa,
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "pyopengl";
|
2024-01-13 08:15:51 +00:00
|
|
|
version = "3.1.7";
|
2023-10-09 19:29:22 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchPypi {
|
|
|
|
pname = "PyOpenGL";
|
|
|
|
inherit version;
|
2024-01-13 08:15:51 +00:00
|
|
|
hash = "sha256-7vMaOIjmmE/U2ObJlhsYTJgTyoJgTTf+PagOsACnbIY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ pillow ];
|
|
|
|
|
2024-06-05 15:53:02 +00:00
|
|
|
patchPhase =
|
|
|
|
let
|
|
|
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in
|
|
|
|
lib.optionalString (!stdenv.isDarwin) ''
|
|
|
|
# Theses lines are patching the name of dynamic libraries
|
|
|
|
# so pyopengl can find them at runtime.
|
|
|
|
substituteInPlace OpenGL/platform/glx.py \
|
|
|
|
--replace '"OpenGL",' '"${pkgs.libGL}/lib/libOpenGL${ext}",' \
|
|
|
|
--replace '"GL",' '"${pkgs.libGL}/lib/libGL${ext}",' \
|
|
|
|
--replace '"GLU",' '"${pkgs.libGLU}/lib/libGLU${ext}",' \
|
|
|
|
--replace '"GLX",' '"${pkgs.libglvnd}/lib/libGLX${ext}",' \
|
2024-07-27 06:49:29 +00:00
|
|
|
--replace '"glut",' '"${pkgs.libglut}/lib/libglut${ext}",' \
|
2024-06-05 15:53:02 +00:00
|
|
|
--replace '"GLESv1_CM",' '"${pkgs.libGL}/lib/libGLESv1_CM${ext}",' \
|
|
|
|
--replace '"GLESv2",' '"${pkgs.libGL}/lib/libGLESv2${ext}",' \
|
|
|
|
--replace '"gle",' '"${pkgs.gle}/lib/libgle${ext}",' \
|
|
|
|
--replace "'EGL'" "'${pkgs.libGL}/lib/libEGL${ext}'"
|
|
|
|
substituteInPlace OpenGL/platform/egl.py \
|
|
|
|
--replace "('OpenGL','GL')" "('${pkgs.libGL}/lib/libOpenGL${ext}', '${pkgs.libGL}/lib/libGL${ext}')" \
|
|
|
|
--replace "'GLU'," "'${pkgs.libGLU}/lib/libGLU${ext}'," \
|
2024-07-27 06:49:29 +00:00
|
|
|
--replace "'glut'," "'${pkgs.libglut}/lib/libglut${ext}'," \
|
2024-06-05 15:53:02 +00:00
|
|
|
--replace "'GLESv1_CM'," "'${pkgs.libGL}/lib/libGLESv1_CM${ext}'," \
|
|
|
|
--replace "'GLESv2'," "'${pkgs.libGL}/lib/libGLESv2${ext}'," \
|
|
|
|
--replace "'gle'," '"${pkgs.gle}/lib/libgle${ext}",' \
|
|
|
|
--replace "'EGL'," "'${pkgs.libGL}/lib/libEGL${ext}',"
|
|
|
|
substituteInPlace OpenGL/platform/darwin.py \
|
|
|
|
--replace "'OpenGL'," "'${pkgs.libGL}/lib/libGL${ext}'," \
|
2024-07-27 06:49:29 +00:00
|
|
|
--replace "'GLUT'," "'${pkgs.libglut}/lib/libglut${ext}',"
|
2024-06-05 15:53:02 +00:00
|
|
|
''
|
|
|
|
+ ''
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/76822
|
|
|
|
# pyopengl introduced a new "robust" way of loading libraries in 3.1.4.
|
|
|
|
# The later patch of the filepath does not work anymore because
|
|
|
|
# pyopengl takes the "name" (for us: the path) and tries to add a
|
|
|
|
# few suffix during its loading phase.
|
|
|
|
# The following patch put back the "name" (i.e. the path) in the
|
|
|
|
# list of possible files.
|
|
|
|
substituteInPlace OpenGL/platform/ctypesloader.py \
|
|
|
|
--replace "filenames_to_try = [base_name]" "filenames_to_try = [name]"
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Need to fix test runner
|
|
|
|
# Tests have many dependencies
|
|
|
|
# Extension types could not be found.
|
|
|
|
# Should run test suite from $out/${python.sitePackages}
|
2023-10-09 19:29:22 +00:00
|
|
|
doCheck = false; # does not affect pythonImportsCheck
|
|
|
|
|
|
|
|
# OpenGL looks for libraries during import, making this a somewhat decent test of the flaky patching above.
|
|
|
|
pythonImportsCheck = "OpenGL";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2024-01-25 14:12:00 +00:00
|
|
|
homepage = "https://mcfletch.github.io/pyopengl/";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "PyOpenGL, the Python OpenGL bindings";
|
|
|
|
longDescription = ''
|
|
|
|
PyOpenGL is the cross platform Python binding to OpenGL and
|
|
|
|
related APIs. The binding is created using the standard (in
|
|
|
|
Python 2.5) ctypes library, and is provided under an extremely
|
|
|
|
liberal BSD-style Open-Source license.
|
|
|
|
'';
|
2024-01-02 11:29:13 +00:00
|
|
|
license = licenses.bsd3;
|
2024-09-19 14:19:46 +00:00
|
|
|
inherit (mesa.meta) platforms;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|