From 5c0c00f6a86c5763cd5da3bb8f198b5e619a80e2 Mon Sep 17 00:00:00 2001 From: Stuart Stent Date: Wed, 4 Sep 2024 13:39:40 -0400 Subject: [PATCH] explicitly pass Env to subprocess For some systems (e.g. Nixos) not passing the modules path explicitly breaks moduleimports --- beetsplug/bpmanalyser/command.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beetsplug/bpmanalyser/command.py b/beetsplug/bpmanalyser/command.py index d039421..47a7e07 100755 --- a/beetsplug/bpmanalyser/command.py +++ b/beetsplug/bpmanalyser/command.py @@ -185,8 +185,12 @@ def runAnalyser(self, item: Item): item_path = item.get("path").decode("utf-8") log.debug("Analysing[{0}]...".format(item_path)) + # Pass the current environment variables to the subprocess + env = os.environ.copy() + env["PYTHONPATH"] = ":".join(sys.path) + proc = Popen([sys.executable, self.analyser_script_path, item_path], - stdout=PIPE, stderr=PIPE) + stdout=PIPE, stderr=PIPE, env=env) stdout, stderr = proc.communicate() # By default assume unknown error