at master 2.6 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 pythonOlder, 6 fetchFromGitHub, 7 fetchpatch, 8 setuptools, 9 freetype-py, 10 imageio, 11 networkx, 12 numpy, 13 pillow, 14 pyglet, 15 pyopengl, 16 scipy, 17 six, 18 trimesh, 19 pytestCheckHook, 20 mesa, 21}: 22 23buildPythonPackage rec { 24 pname = "pyrender"; 25 version = "0.1.45"; 26 pyproject = true; 27 28 disabled = pythonOlder "3.5"; 29 30 src = fetchFromGitHub { 31 owner = "mmatl"; 32 repo = "pyrender"; 33 tag = version; 34 hash = "sha256-V2G8QWXMxFDQpT4XDOJhIFI2V9VhDQCaXYBb/QVLxgM="; 35 }; 36 37 patches = [ 38 (fetchpatch { 39 # yet to be tagged 40 name = "relax-pyopengl.patch"; 41 url = "https://github.com/mmatl/pyrender/commit/7c613e8aed7142df9ff40767a8f10b7a19b6255c.patch"; 42 hash = "sha256-SXRV9RC3PfQGjjIQ+n97HZrSDPae3rAHnTBiHXSFLaY="; 43 }) 44 # fix on numpy 2.0 (np.infty -> np.inf) 45 # https://github.com/mmatl/pyrender/pull/292 46 (fetchpatch { 47 name = "fix-numpy2.patch"; 48 url = "https://github.com/mmatl/pyrender/commit/5408c7b45261473511d2399ab625efe11f0b6991.patch"; 49 hash = "sha256-RIv6lMpxMmops5Tb1itzYdT7GkhPScVWslBXITR3IBM="; 50 }) 51 ]; 52 53 # trimesh too new 54 # issue: https://github.com/mmatl/pyrender/issues/203 55 # mega pr: https://github.com/mmatl/pyrender/pull/216 56 # relevant pr commit: https://github.com/mmatl/pyrender/pull/216/commits/5069aeb957addff8919f05dc9be4040f55bff329 57 # the commit does not apply as a patch when cherry picked, hence the substituteInPlace 58 postPatch = '' 59 substituteInPlace tests/unit/test_meshes.py \ 60 --replace-fail \ 61 "bm = trimesh.load('tests/data/WaterBottle.glb').dump()[0]" \ 62 'bm = trimesh.load("tests/data/WaterBottle.glb").geometry["WaterBottle"]' 63 ''; 64 65 nativeBuildInputs = [ setuptools ]; 66 67 dependencies = [ 68 freetype-py 69 imageio 70 networkx 71 numpy 72 pillow 73 pyglet 74 pyopengl 75 scipy 76 six 77 trimesh 78 ]; 79 80 env.PYOPENGL_PLATFORM = "egl"; # enables headless rendering during check 81 82 nativeCheckInputs = [ 83 pytestCheckHook 84 ] 85 ++ lib.filter (lib.meta.availableOn stdenv.hostPlatform) [ 86 mesa.llvmpipeHook 87 ]; 88 89 disabledTestPaths = lib.optionals (!lib.meta.availableOn stdenv.hostPlatform mesa.llvmpipeHook) [ 90 # requires opengl context 91 "tests/unit/test_offscreen.py" 92 ]; 93 94 pythonImportsCheck = [ "pyrender" ]; 95 96 meta = with lib; { 97 homepage = "https://pyrender.readthedocs.io/en/latest/"; 98 description = "Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes"; 99 license = licenses.mit; 100 maintainers = with maintainers; [ pbsds ]; 101 broken = stdenv.hostPlatform.isDarwin; 102 }; 103}