forked from nerfstudio-project/nerfstudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_install_missing_methods.py
More file actions
52 lines (37 loc) · 1.29 KB
/
Copy pathauto_install_missing_methods.py
File metadata and controls
52 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess
import sys
import re
ROOT = "C:/Users/crist/Documents/nerfstudio_custom"
def run_cmd(cmd):
return subprocess.run(cmd, shell=True, capture_output=True, text=True)
def try_ns():
result = run_cmd("ns-viewer --help")
return result.stderr + result.stdout
def install_module(module_name):
print(f"[AUTO] Trying to install: {module_name}")
import os
for folder in os.listdir(ROOT):
path = os.path.join(ROOT, folder)
if os.path.isdir(path):
if module_name.lower() in folder.lower():
print(f"[FOUND] Installing from {folder}")
subprocess.run(f'cd "{path}" && pip install -e . --no-deps', shell=True)
return True
print(f"[MISS] Could not find folder for {module_name}")
return False
def main():
for _ in range(10):
output = try_ns()
match = re.search(r"No module named '([^']+)'", output)
if not match:
print("✅ All dependencies resolved")
return
missing = match.group(1).split(".")[0]
print(f"[MISSING] {missing}")
ok = install_module(missing)
if not ok:
print("❌ Could not resolve automatically")
return
print("⚠️ Too many iterations")
if __name__ == "__main__":
main()