Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Python to choose generator interpreter using shutil parameter t… #647

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading