Z User commited on
Commit
25d86d2
·
1 Parent(s): aa686c9

fix: correct patch path for editable install

Browse files
Files changed (1) hide show
  1. scripts/patch_file_delivery.py +15 -17
scripts/patch_file_delivery.py CHANGED
@@ -12,6 +12,8 @@ on Feishu and WeChat instead of appearing as a plain text path.
12
 
13
  import re
14
  import sys
 
 
15
 
16
  def patch_file(filepath: str):
17
  with open(filepath, 'r') as f:
@@ -55,27 +57,23 @@ def patch_file(filepath: str):
55
  print(f"Patched {filepath}: added document/audio/archive extensions to _LOCAL_MEDIA_EXTS")
56
 
57
  if __name__ == "__main__":
58
- # Find base.py in the installed package
59
- filepath = sys.argv[1] if len(sys.argv) > 1 else None
 
 
60
 
61
- # Try common locations
62
- import importlib.util
63
- for candidate in [
64
- "/app/venv/lib/python3.12/site-packages/gateway/platforms/base.py",
65
- ]:
66
- if not filepath and __import__('os').path.isfile(candidate):
67
- filepath = candidate
68
  break
69
 
70
  if not filepath:
71
- # Try to find it
72
- import os, glob
73
- matches = glob.glob("/app/venv/lib/**/gateway/platforms/base.py", recursive=True)
74
- if matches:
75
- filepath = matches[0]
76
-
77
- if not filepath or not os.path.isfile(filepath):
78
- print(f"ERROR: base.py not found", file=sys.stderr)
79
  sys.exit(1)
80
 
81
  patch_file(filepath)
 
12
 
13
  import re
14
  import sys
15
+ import os
16
+ import glob
17
 
18
  def patch_file(filepath: str):
19
  with open(filepath, 'r') as f:
 
57
  print(f"Patched {filepath}: added document/audio/archive extensions to _LOCAL_MEDIA_EXTS")
58
 
59
  if __name__ == "__main__":
60
+ # hermes-agent is installed in editable mode (-e), so source is in /app/hermes-agent/
61
+ candidates = [
62
+ "/app/hermes-agent/gateway/platforms/base.py",
63
+ ]
64
 
65
+ # Also search venv site-packages as fallback
66
+ candidates.extend(glob.glob("/app/venv/lib/**/gateway/platforms/base.py", recursive=True))
67
+
68
+ filepath = None
69
+ for c in candidates:
70
+ if os.path.isfile(c):
71
+ filepath = c
72
  break
73
 
74
  if not filepath:
75
+ print("ERROR: base.py not found in any candidate location", file=sys.stderr)
76
+ print(f"Checked: {candidates}", file=sys.stderr)
 
 
 
 
 
 
77
  sys.exit(1)
78
 
79
  patch_file(filepath)