Skip to content

Commit

Permalink
Use shutil.which to find generator interpreters, as sometimes shutil.…
Browse files Browse the repository at this point in the history
…which can find binaries that the system cannot. See Pythons Popen documentation.
  • Loading branch information
cr1901 authored and olofk committed Sep 21, 2023
1 parent c9d91b1 commit 6126576
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fusesoc/capi2/json_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 9 additions & 1 deletion fusesoc/edalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 6126576

Please sign in to comment.