From 52d4d31fa200d4c3c29dae115c2ae6e83193f9f9 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Wed, 15 Mar 2023 01:06:40 +0100 Subject: [PATCH 1/2] python3Packages.pyopengl: support the EGL platform, link libGLESv{1,2} --- .../python-modules/pyopengl/default.nix | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/pyopengl/default.nix b/pkgs/development/python-modules/pyopengl/default.nix index 94b5d38d3fc8..318f2aa033b6 100644 --- a/pkgs/development/python-modules/pyopengl/default.nix +++ b/pkgs/development/python-modules/pyopengl/default.nix @@ -8,6 +8,7 @@ buildPythonPackage rec { pname = "pyopengl"; version = "3.1.6"; + format = "setuptools"; src = fetchPypi { pname = "PyOpenGL"; @@ -24,7 +25,20 @@ buildPythonPackage rec { substituteInPlace OpenGL/platform/glx.py \ --replace "'GL'" "'${pkgs.libGL}/lib/libGL${ext}'" \ --replace "'GLU'" "'${pkgs.libGLU}/lib/libGLU${ext}'" \ - --replace "'glut'" "'${pkgs.freeglut}/lib/libglut${ext}'" + --replace "'glut'" "'${pkgs.freeglut}/lib/libglut${ext}'" \ + --replace "'GLESv1_CM'," "'${pkgs.libGL}/lib/libGLESv1_CM${ext}'," \ + --replace "'GLESv2'," "'${pkgs.libGL}/lib/libGLESv2${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}'," \ + --replace "'glut'," "'${pkgs.freeglut}/lib/libglut${ext}'," \ + --replace "'GLESv1_CM'," "'${pkgs.libGL}/lib/libGLESv1_CM${ext}'," \ + --replace "'GLESv2'," "'${pkgs.libGL}/lib/libGLESv2${ext}'," \ + --replace "'EGL'," "'${pkgs.libGL}/lib/libEGL${ext}'," + substituteInPlace OpenGL/platform/darwin.py \ + --replace "'OpenGL'," "'${pkgs.libGL}/lib/libGL${ext}'," \ + --replace "'GLUT'," "'${pkgs.freeglut}/lib/libglut${ext}'," + # TODO: patch 'gle' in OpenGL/platform/egl.py '' + '' # https://github.com/NixOS/nixpkgs/issues/76822 # pyopengl introduced a new "robust" way of loading libraries in 3.1.4. @@ -41,7 +55,10 @@ buildPythonPackage rec { # Tests have many dependencies # Extension types could not be found. # Should run test suite from $out/${python.sitePackages} - doCheck = false; + 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"; meta = with lib; { homepage = "https://pyopengl.sourceforge.net/"; From 4a4017d9a1341826a1eea0d724659a123609f521 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Tue, 22 Nov 2022 22:53:47 +0100 Subject: [PATCH 2/2] python3Packages.pyrender: init at 0.1.45 --- .../python-modules/pyrender/default.nix | 85 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 87 insertions(+) create mode 100644 pkgs/development/python-modules/pyrender/default.nix diff --git a/pkgs/development/python-modules/pyrender/default.nix b/pkgs/development/python-modules/pyrender/default.nix new file mode 100644 index 000000000000..eb1d5d17ee47 --- /dev/null +++ b/pkgs/development/python-modules/pyrender/default.nix @@ -0,0 +1,85 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, fetchpatch +, freetype-py +, imageio +, networkx +, numpy +, pillow +, pyglet +, pyopengl +, scipy +, six +, trimesh +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "pyrender"; + version = "0.1.45"; + format = "setuptools"; + + disabled = pythonOlder "3.5"; + + src = fetchFromGitHub { + owner = "mmatl"; + repo = "pyrender"; + rev = "refs/tags/${version}"; + hash = "sha256-V2G8QWXMxFDQpT4XDOJhIFI2V9VhDQCaXYBb/QVLxgM="; + }; + + patches = [ + (fetchpatch { # yet to be tagged + name = "relax-pyopengl.patch"; + url = "https://github.com/mmatl/pyrender/commit/7c613e8aed7142df9ff40767a8f10b7a19b6255c.patch"; + hash = "sha256-SXRV9RC3PfQGjjIQ+n97HZrSDPae3rAHnTBiHXSFLaY="; + }) + ]; + + # trimesh too new + # issue: https://github.com/mmatl/pyrender/issues/203 + # mega pr: https://github.com/mmatl/pyrender/pull/216 + # relevant pr commit: https://github.com/mmatl/pyrender/pull/216/commits/5069aeb957addff8919f05dc9be4040f55bff329 + # the commit does not apply as a patch when cherry picked, hence the substituteInPlace + postPatch = '' + substituteInPlace tests/unit/test_meshes.py \ + --replace \ + "bm = trimesh.load('tests/data/WaterBottle.glb').dump()[0]" \ + 'bm = trimesh.load("tests/data/WaterBottle.glb").geometry["WaterBottle"]' + ''; + + propagatedBuildInputs = [ + freetype-py + imageio + networkx + numpy + pillow + pyglet + pyopengl + scipy + six + trimesh + ]; + + env.PYOPENGL_PLATFORM = "egl"; # enables headless rendering during check + + nativeCheckInputs = [ + pytestCheckHook + ]; + + disabledTestPaths = [ + # does not work inside sandbox, no GPU + "tests/unit/test_offscreen.py" + ]; + + pythonImportsCheck = [ "pyrender" ]; + + meta = with lib; { + homepage = "https://pyrender.readthedocs.io/en/latest/"; + description = "Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes"; + license = licenses.mit; + maintainers = with maintainers; [ pbsds ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 4cf1f0a21474..3c1466cad316 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -8312,6 +8312,8 @@ self: super: with self; { pyre-extensions = callPackage ../development/python-modules/pyre-extensions { }; + pyrender = callPackage ../development/python-modules/pyrender { }; + pyrevolve = callPackage ../development/python-modules/pyrevolve { }; pyrfxtrx = callPackage ../development/python-modules/pyrfxtrx { };