1{ 2 lib, 3 4 buildPythonPackage, 5 fetchFromGitHub, 6 7 # nativeBuildInputs 8 nodejs, 9 fetchYarnDeps, 10 yarnConfigHook, 11 12 # build-system 13 hatchling, 14 15 # dependencies 16 imageio, 17 msgspec, 18 nodeenv, 19 numpy, 20 opencv-python, 21 plyfile, 22 psutil, 23 requests, 24 rich, 25 scikit-image, 26 scipy, 27 tqdm, 28 trimesh, 29 typing-extensions, 30 websockets, 31 yourdfpy, 32 33 # optional-dependencies 34 hypothesis, 35 pre-commit, 36 pandas, 37 pyright, 38 pytest, 39 ruff, 40 gdown, 41 matplotlib, 42 plotly, 43 # pyliblzfse, 44 robot-descriptions, 45 torch, 46 tyro, 47 48 # nativeCheckInputs 49 pytestCheckHook, 50}: 51 52buildPythonPackage rec { 53 pname = "viser"; 54 version = "1.0.4"; 55 pyproject = true; 56 57 src = fetchFromGitHub { 58 owner = "nerfstudio-project"; 59 repo = "viser"; 60 tag = "v${version}"; 61 hash = "sha256-AS5D6pco6wzQ414yxvv0K9FB3tfP1BvqigRLJJXDduU="; 62 }; 63 64 postPatch = '' 65 # prepare yarn offline cache 66 mkdir -p node_modules 67 cd src/viser/client 68 cp package.json yarn.lock ../../.. 69 ln -s ../../../node_modules 70 71 # fix: [vite-plugin-eslint] Failed to load config "react-app" to extend from. 72 substituteInPlace vite.config.mts --replace-fail \ 73 "eslint({ failOnError: false, failOnWarning: false })," "" 74 75 cd ../../.. 76 ''; 77 78 nativeBuildInputs = [ 79 yarnConfigHook 80 nodejs 81 ]; 82 83 yarnOfflineCache = fetchYarnDeps { 84 yarnLock = src + "/src/viser/client/yarn.lock"; 85 hash = "sha256-4x+zJIqjVoKmEdOUPGpCuMmlRBfF++3oWtbNYAvd2ko="; 86 }; 87 88 preBuild = '' 89 cd src/viser/client 90 yarn --offline build 91 cd ../../.. 92 ''; 93 94 build-system = [ 95 hatchling 96 ]; 97 98 dependencies = [ 99 imageio 100 msgspec 101 nodeenv 102 numpy 103 opencv-python 104 plyfile 105 psutil 106 requests 107 rich 108 scikit-image 109 scipy 110 tqdm 111 trimesh 112 typing-extensions 113 websockets 114 yourdfpy 115 ]; 116 117 optional-dependencies = { 118 dev = [ 119 hypothesis 120 pre-commit 121 pyright 122 pytest 123 ruff 124 ]; 125 examples = [ 126 gdown 127 matplotlib 128 pandas 129 plotly 130 plyfile 131 # pyliblzfse 132 robot-descriptions 133 torch 134 tyro 135 ]; 136 }; 137 138 nativeCheckInputs = [ 139 hypothesis 140 pytestCheckHook 141 ]; 142 143 pythonImportsCheck = [ 144 "viser" 145 ]; 146 147 meta = { 148 changelog = "https://github.com/nerfstudio-project/viser/releases/tag/${src.tag}"; 149 description = "Web-based 3D visualization + Python"; 150 homepage = "https://github.com/nerfstudio-project/viser"; 151 license = lib.licenses.asl20; 152 maintainers = with lib.maintainers; [ nim65s ]; 153 }; 154}