1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, fetchpatch
6, freetype-py
7, imageio
8, networkx
9, numpy
10, pillow
11, pyglet
12, pyopengl
13, scipy
14, six
15, trimesh
16, pytestCheckHook
17}:
18
19buildPythonPackage rec {
20 pname = "pyrender";
21 version = "0.1.45";
22 format = "setuptools";
23
24 disabled = pythonOlder "3.5";
25
26 src = fetchFromGitHub {
27 owner = "mmatl";
28 repo = "pyrender";
29 rev = "refs/tags/${version}";
30 hash = "sha256-V2G8QWXMxFDQpT4XDOJhIFI2V9VhDQCaXYBb/QVLxgM=";
31 };
32
33 patches = [
34 (fetchpatch { # yet to be tagged
35 name = "relax-pyopengl.patch";
36 url = "https://github.com/mmatl/pyrender/commit/7c613e8aed7142df9ff40767a8f10b7a19b6255c.patch";
37 hash = "sha256-SXRV9RC3PfQGjjIQ+n97HZrSDPae3rAHnTBiHXSFLaY=";
38 })
39 ];
40
41 # trimesh too new
42 # issue: https://github.com/mmatl/pyrender/issues/203
43 # mega pr: https://github.com/mmatl/pyrender/pull/216
44 # relevant pr commit: https://github.com/mmatl/pyrender/pull/216/commits/5069aeb957addff8919f05dc9be4040f55bff329
45 # the commit does not apply as a patch when cherry picked, hence the substituteInPlace
46 postPatch = ''
47 substituteInPlace tests/unit/test_meshes.py \
48 --replace \
49 "bm = trimesh.load('tests/data/WaterBottle.glb').dump()[0]" \
50 'bm = trimesh.load("tests/data/WaterBottle.glb").geometry["WaterBottle"]'
51 '';
52
53 propagatedBuildInputs = [
54 freetype-py
55 imageio
56 networkx
57 numpy
58 pillow
59 pyglet
60 pyopengl
61 scipy
62 six
63 trimesh
64 ];
65
66 env.PYOPENGL_PLATFORM = "egl"; # enables headless rendering during check
67
68 nativeCheckInputs = [
69 pytestCheckHook
70 ];
71
72 disabledTestPaths = [
73 # does not work inside sandbox, no GPU
74 "tests/unit/test_offscreen.py"
75 ];
76
77 pythonImportsCheck = [ "pyrender" ];
78
79 meta = with lib; {
80 homepage = "https://pyrender.readthedocs.io/en/latest/";
81 description = "Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes";
82 license = licenses.mit;
83 maintainers = with maintainers; [ pbsds ];
84 };
85}