Clarify error message when executed binary not found by stefanv · Pull Request #237 · scientific-python/spin · GitHub
Skip to content
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
7 changes: 4 additions & 3 deletions spin/cmds/meson.py
8 changes: 6 additions & 2 deletions spin/cmds/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ def run(
print(f"Failed to launch `{cmd}`")
sys.exit(-1)
else:
p = subprocess.run(cmd, *args, **kwargs)
try:
p = subprocess.run(cmd, *args, **kwargs)
except FileNotFoundError:
click.secho(f"`{cmd[0]}` executable not found. Exiting.", fg="bright_red")
raise SystemExit(1) from None
if p.returncode != 0 and sys_exit:
# Output was suppressed, but the process failed, so print it anyway
if output is False:
print(p.stdout.decode("utf-8"), end="")
sys.exit(p.returncode)
raise SystemExit(p.returncode)
return p


Expand Down
10 changes: 10 additions & 0 deletions spin/tests/test_util.py