drozdgk commited on
Commit
6cced5a
·
1 Parent(s): 8965662

Runtime fallback: install local detectron2 if import fails (no build isolation)

Browse files
Files changed (1) hide show
  1. mvp.py +10 -0
mvp.py CHANGED
@@ -52,6 +52,16 @@ sys.path.append(os.path.join(REPO_ROOT, "vggt"))
52
  MK_PATH = os.path.join(REPO_ROOT, "MaskClustering")
53
  DETECTRON2_ROOT = os.path.join(REPO_ROOT, "MaskClustering", "third_party", "detectron2")
54
 
 
 
 
 
 
 
 
 
 
 
55
  # If detectron2 isn't installed as a package, allow importing from vendored source.
56
  if os.path.isdir(DETECTRON2_ROOT) and DETECTRON2_ROOT not in sys.path:
57
  sys.path.append(DETECTRON2_ROOT)
 
52
  MK_PATH = os.path.join(REPO_ROOT, "MaskClustering")
53
  DETECTRON2_ROOT = os.path.join(REPO_ROOT, "MaskClustering", "third_party", "detectron2")
54
 
55
+ # Ensure local detectron2 is installed at runtime if postBuild didn't run
56
+ try:
57
+ import detectron2 # noqa: F401
58
+ except Exception:
59
+ print("[runtime] detectron2 not found. Installing local detectron2 (editable, no build isolation)...")
60
+ os.system("python -m pip install --no-build-isolation -e ./MaskClustering/third_party/detectron2")
61
+ import importlib
62
+ importlib.invalidate_caches()
63
+ import detectron2 # noqa: F401
64
+
65
  # If detectron2 isn't installed as a package, allow importing from vendored source.
66
  if os.path.isdir(DETECTRON2_ROOT) and DETECTRON2_ROOT not in sys.path:
67
  sys.path.append(DETECTRON2_ROOT)