Skip to content

Commit 9a227a2

Browse files
committed
Use shutil.which to find generator interpreters, as sometimes shutil.which can find binaries that the system cannot. See Pythons Popen documentation.
1 parent 74a4fa1 commit 9a227a2

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

fusesoc/capi2/json_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
"type": "string"
318318
},
319319
"interpreter": {
320-
"description": "If the command needs a custom interpreter (such as python) this will be inserted as the first argument before command when calling the generator. The interpreter needs to be on the system PATH.",
320+
"description": "If the command needs a custom interpreter (such as python) this will be inserted as the first argument before command when calling the generator. The interpreter needs to be on the system PATH; specifically, shutil.which needs to be able to find the interpreter).",
321321
"type": "string"
322322
},
323323
"cache_type": {

fusesoc/edalizer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ def __init__(self, ttptttg, core, generators, gen_root, resolve_env_vars=False):
521521
self.generator = generators[generator_name]
522522
self.name = ttptttg["name"]
523523
self.pos = ttptttg["pos"]
524+
self.gen_name = generator_name
524525
self.gen_root = gen_root
525526
self.resolve_env_vars = resolve_env_vars
526527
parameters = ttptttg["config"]
@@ -601,7 +602,14 @@ def _run(self, generator_cwd):
601602
]
602603

603604
if "interpreter" in self.generator:
604-
args[0:0] = [self.generator["interpreter"]]
605+
interp = self.generator["interpreter"]
606+
interppath = shutil.which(interp)
607+
if not interppath:
608+
raise RuntimeError(
609+
f"Could not find generator interpreter '{interp}' using shutil.which.\n"
610+
f"Interpreter requested by generator {self.gen_name}, requested by core {self.core}.\n"
611+
)
612+
args[0:0] = [interppath]
605613

606614
Launcher(args[0], args[1:], cwd=generator_cwd).run()
607615

0 commit comments

Comments
 (0)