From d885486283b9a02613963898aa15c0dffd7272df Mon Sep 17 00:00:00 2001 From: Logan Dhillon Date: Fri, 12 Jul 2024 03:06:05 -0400 Subject: [PATCH] Add bdsh workdir to virtenv path --- bdsh.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bdsh.py b/bdsh.py index cfa3db8..45845a3 100644 --- a/bdsh.py +++ b/bdsh.py @@ -23,6 +23,9 @@ def __init__(self, stdout: callable, stdin: callable, **is_ssh: bool): "ld": self.cmd_ld, } + self.env = os.environ.copy() + self.env['PYTHONPATH'] = os.path.dirname(os.path.realpath(__file__)) + def cmd_ld(self, args): try: self.print('\t'.join([item + '/' if os.path.isdir(os.path.join(self.get_path(args[1] if len(args) > 1 else ""), item)) else item for item in os.listdir(self.get_path(args[1] if len(args) > 1 else ""))])) @@ -41,7 +44,7 @@ def run_line(self, line: str): except Exception as e: self.print(f"{args[0]}: {e}") elif os.path.exists(bin := self.get_path("exec", args[0])): - subprocess.run([sys.executable, bin] + args[1:], stdout=sys.stdout, stderr=subprocess.STDOUT, text=True) + subprocess.run([sys.executable, bin] + args[1:], stdout=sys.stdout, stderr=subprocess.STDOUT, text=True, env=self.env) else: self.print(f"Invalid command: {args[0]}")