@@ -227,6 +227,41 @@ class LlamaRunner:
227
227
print (f"Error: { e } " )
228
228
return 1
229
229
230
+ def load_env_from_script ():
231
+ system = platform .system ()
232
+
233
+ if system == "Windows" :
234
+ # Call set_paths.cmd and capture output as environment
235
+ result = subprocess .run (
236
+ ["cmd.exe" , "/c" , "set_paths.cmd && set" ],
237
+ capture_output = True , text = True , shell = False
238
+ )
239
+ if result .returncode != 0 :
240
+ print ("Failed to run set_paths.cmd" )
241
+ sys .exit (1 )
242
+
243
+ # Parse environment variables from output
244
+ for line in result .stdout .splitlines ():
245
+ if '=' in line :
246
+ key , value = line .strip ().split ('=' , 1 )
247
+ os .environ [key ] = value
248
+
249
+ elif system in ("Linux" , "Darwin" ):
250
+ # Source the set_paths file and capture env
251
+ command = ['bash' , '-c' , 'source ./set_paths && env' ]
252
+ result = subprocess .run (command , capture_output = True , text = True )
253
+ if result .returncode != 0 :
254
+ print ("Failed to source set_paths" )
255
+ sys .exit (1 )
256
+
257
+ for line in result .stdout .splitlines ():
258
+ if '=' in line :
259
+ key , value = line .strip ().split ('=' , 1 )
260
+ os .environ [key ] = value
261
+ else :
262
+ print (f"Unsupported OS: { system } " )
263
+ sys .exit (1 )
264
+
230
265
def create_parser () -> argparse .ArgumentParser :
231
266
"""Create and configure the argument parser."""
232
267
parser = argparse .ArgumentParser (
@@ -323,6 +358,7 @@ def create_parser() -> argparse.ArgumentParser:
323
358
324
359
def main ():
325
360
"""Main entry point."""
361
+ load_env_from_script ()
326
362
parser = create_parser ()
327
363
args = parser .parse_args ()
328
364
0 commit comments