annabossler commited on
Commit
ed6967d
·
verified ·
1 Parent(s): da5f575

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -5,6 +5,46 @@ import numpy as np
5
  import gradio as gr
6
  from ase.io import read, write
7
  from ase.io.trajectory import Trajectory
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  from gradio_molecule3d import Molecule3D
9
  from simulation_scripts_orbmol import load_orbmol_model, run_md_simulation, run_relaxation_simulation
10
  import hashlib
 
5
  import gradio as gr
6
  from ase.io import read, write
7
  from ase.io.trajectory import Trajectory
8
+ import subprocess, sys
9
+ from pathlib import Path
10
+
11
+ # === BUILD AND INSTALL LOCAL gradio_molecule3d ===
12
+ try:
13
+ print("🔧 Building and installing local gradio_molecule3d fork...")
14
+
15
+ base_path = Path(__file__).parent
16
+ local_pkg = base_path / "gradio_molecule3d"
17
+
18
+ # Step 1 — gradio cc install
19
+ subprocess.call(["gradio", "cc", "install"], cwd=local_pkg)
20
+
21
+ # Step 2 — gradio cc build
22
+ subprocess.call(["gradio", "cc", "build"], cwd=local_pkg)
23
+
24
+ # Step 3 — pip install generated wheel
25
+ wheel_path = local_pkg / "dist" / "gradio_molecule3d-0.0.7-py3-none-any.whl"
26
+ if not wheel_path.exists():
27
+ print("Wheel not found, listing dist contents:")
28
+ subprocess.call(["ls", "-R", str(local_pkg / "dist")])
29
+ subprocess.call(
30
+ [
31
+ sys.executable,
32
+ "-m",
33
+ "pip",
34
+ "install",
35
+ str(wheel_path),
36
+ ],
37
+ cwd=base_path.parent,
38
+ )
39
+
40
+ print("gradio_molecule3d built and installed successfully!")
41
+
42
+ except Exception as e:
43
+ print(f"Error building gradio_molecule3d: {e}")
44
+
45
+ # === Import only after it's installed ===
46
+ from gradio_molecule3d import Molecule3D
47
+
48
  from gradio_molecule3d import Molecule3D
49
  from simulation_scripts_orbmol import load_orbmol_model, run_md_simulation, run_relaxation_simulation
50
  import hashlib