@@ -227,6 +227,41 @@ class LlamaRunner:
227227 print (f"Error: { e } " )
228228 return 1
229229
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+
230265def create_parser () -> argparse .ArgumentParser :
231266 """Create and configure the argument parser."""
232267 parser = argparse .ArgumentParser (
@@ -323,6 +358,7 @@ def create_parser() -> argparse.ArgumentParser:
323358
324359def main ():
325360 """Main entry point."""
361+ load_env_from_script ()
326362 parser = create_parser ()
327363 args = parser .parse_args ()
328364
0 commit comments