From 9a227a2be2c408e5439b213b52460a2341dd37cc Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 20 Sep 2023 16:13:07 -0400 Subject: [PATCH] Use shutil.which to find generator interpreters, as sometimes shutil.which can find binaries that the system cannot. See Pythons Popen documentation. --- fusesoc/capi2/json_schema.py | 2 +- fusesoc/edalizer.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fusesoc/capi2/json_schema.py b/fusesoc/capi2/json_schema.py index 4b341444..f38da7b6 100644 --- a/fusesoc/capi2/json_schema.py +++ b/fusesoc/capi2/json_schema.py @@ -317,7 +317,7 @@ "type": "string" }, "interpreter": { - "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.", + "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).", "type": "string" }, "cache_type": { diff --git a/fusesoc/edalizer.py b/fusesoc/edalizer.py index d51d6e6b..8fa4d1e1 100644 --- a/fusesoc/edalizer.py +++ b/fusesoc/edalizer.py @@ -521,6 +521,7 @@ def __init__(self, ttptttg, core, generators, gen_root, resolve_env_vars=False): self.generator = generators[generator_name] self.name = ttptttg["name"] self.pos = ttptttg["pos"] + self.gen_name = generator_name self.gen_root = gen_root self.resolve_env_vars = resolve_env_vars parameters = ttptttg["config"] @@ -601,7 +602,14 @@ def _run(self, generator_cwd): ] if "interpreter" in self.generator: - args[0:0] = [self.generator["interpreter"]] + interp = self.generator["interpreter"] + interppath = shutil.which(interp) + if not interppath: + raise RuntimeError( + f"Could not find generator interpreter '{interp}' using shutil.which.\n" + f"Interpreter requested by generator {self.gen_name}, requested by core {self.core}.\n" + ) + args[0:0] = [interppath] Launcher(args[0], args[1:], cwd=generator_cwd).run()