dev-bjoern commited on
Commit
38be658
·
verified ·
1 Parent(s): 331812c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -37
app.py CHANGED
@@ -3,6 +3,31 @@ import subprocess
3
  import os
4
  import spaces
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  # Funktion zum Installieren von Infinigen
7
  def install_infinigen():
8
  infinigen_dir = "infinigen"
@@ -10,34 +35,11 @@ def install_infinigen():
10
  print("Klone Infinigen...")
11
  subprocess.run(["git", "clone", "https://github.com/princeton-vl/infinigen.git"], check=True)
12
 
13
- # Blender-Python-Pfad
14
- blender_python = None
15
- possible_paths = [
16
- "/usr/share/blender/4.2/python/bin/python3.10",
17
- "/usr/lib/blender/4.2/python/bin/python3.10",
18
- "/usr/bin/blender-python3.10" # Fallback für verschiedene Installationen
19
- ]
20
-
21
- for path in possible_paths:
22
- if os.path.exists(path):
23
- blender_python = path
24
- break
25
-
26
  if not blender_python:
27
- # Fallback mit find
28
- result = subprocess.run(
29
- ["find", "/usr", "-name", "python3.10", "-path", "*/blender/*"],
30
- capture_output=True, text=True
31
- )
32
- paths = result.stdout.strip().split("\n")
33
- if paths and paths[0]:
34
- blender_python = paths[0]
35
- else:
36
- raise RuntimeError("Blender Python-Interpreter nicht gefunden!")
37
-
38
- print(f"Blender Python gefunden unter: {blender_python}")
39
 
40
- # Installiere Infinigen mit Blender-Python
41
  subprocess.run([
42
  blender_python, "-m", "pip", "install", "-e", f"{infinigen_dir}[terrain,vis]", "--no-deps"
43
  ], check=True)
@@ -55,17 +57,9 @@ def generate_scene(seed):
55
  output_dir = "outputs"
56
  os.makedirs(output_dir, exist_ok=True)
57
 
58
- blender_python = "/usr/share/blender/4.2/python/bin/python3.10" # Muss ggf. angepasst werden
59
- if not os.path.exists(blender_python):
60
- result = subprocess.run(
61
- ["find", "/usr", "-name", "python3.10", "-path", "*/blender/*"],
62
- capture_output=True, text=True
63
- )
64
- paths = result.stdout.strip().split("\n")
65
- if paths and paths[0]:
66
- blender_python = paths[0]
67
- else:
68
- return "Fehler: Blender Python-Interpreter nicht gefunden!"
69
 
70
  command = [
71
  blender_python, "-m", "infinigen.datagen.manage_jobs",
 
3
  import os
4
  import spaces
5
 
6
+ # Funktion zum Überprüfen und Finden des Blender-Pfads
7
+ def find_blender_python():
8
+ possible_paths = [
9
+ "/usr/share/blender/4.2/python/bin/python3.10",
10
+ "/usr/lib/blender/4.2/python/bin/python3.10",
11
+ "/usr/bin/blender-python3.10",
12
+ "/usr/lib/blender/3.6/python/bin/python3.10" # Ältere Version als Fallback
13
+ ]
14
+
15
+ for path in possible_paths:
16
+ if os.path.exists(path):
17
+ return path
18
+
19
+ # Breiterer Fallback-Suchbefehl
20
+ blender_find_cmd = ["find", "/", "-name", "python3.*", "-path", "*/blender/*", "-type", "f"]
21
+ result = subprocess.run(blender_find_cmd, capture_output=True, text=True)
22
+ paths = result.stdout.strip().split("\n")
23
+ if paths and paths[0] and os.path.exists(paths[0]):
24
+ return paths[0]
25
+
26
+ # Debugging: Blender selbst suchen
27
+ blender_bin = subprocess.run(["find", "/", "-name", "blender", "-type", "f"], capture_output=True, text=True)
28
+ print(f"Blender-Binär gefunden: {blender_bin.stdout}")
29
+ return None
30
+
31
  # Funktion zum Installieren von Infinigen
32
  def install_infinigen():
33
  infinigen_dir = "infinigen"
 
35
  print("Klone Infinigen...")
36
  subprocess.run(["git", "clone", "https://github.com/princeton-vl/infinigen.git"], check=True)
37
 
38
+ blender_python = find_blender_python()
 
 
 
 
 
 
 
 
 
 
 
 
39
  if not blender_python:
40
+ raise RuntimeError("Blender Python-Interpreter nicht gefunden!")
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ print(f"Blender Python gefunden unter: {blender_python}")
43
  subprocess.run([
44
  blender_python, "-m", "pip", "install", "-e", f"{infinigen_dir}[terrain,vis]", "--no-deps"
45
  ], check=True)
 
57
  output_dir = "outputs"
58
  os.makedirs(output_dir, exist_ok=True)
59
 
60
+ blender_python = find_blender_python()
61
+ if not blender_python:
62
+ return "Fehler: Blender Python-Interpreter nicht gefunden!"
 
 
 
 
 
 
 
 
63
 
64
  command = [
65
  blender_python, "-m", "infinigen.datagen.manage_jobs",