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