Merge pull request #202434 from pbsds/pyrender-init

python3Packages.pyrender: init at 0.1.45
This commit is contained in:
OTABI Tomoya 2023-09-17 23:06:32 +09:00 committed by GitHub
commit 31527f17ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 106 additions and 2 deletions

View File

@ -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/";

View File

@ -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 ];
};
}

View File

@ -8314,6 +8314,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 { };