Skip to content

Commit 221dade

Browse files
committed
[feat] Removed the loading of environment vars from Makefile and added it as a step in llama-tornado. This is to enable make in Windows.
1 parent f1560bd commit 221dade

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ clean:
1414
# Package the project without running tests
1515
package:
1616
mvn package -DskipTests
17-
. ./set_paths
1817

1918

2019
# Combined clean and package

llama-tornado

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
230265
def 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

324359
def main():
325360
"""Main entry point."""
361+
load_env_from_script()
326362
parser = create_parser()
327363
args = parser.parse_args()
328364

0 commit comments

Comments
 (0)