From 732108109ed207119440cef6a4c218b74c35d040 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 6 Sep 2018 21:23:03 +0530 Subject: [PATCH] Nicer error message when sphinx-build is not in PATH --- __main__.py | 8 +++++++- docs/Makefile | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__main__.py b/__main__.py index 00efea688..650ddbc27 100644 --- a/__main__.py +++ b/__main__.py @@ -42,7 +42,13 @@ def complete(args): def launch(args): import runpy sys.argv = args[1:] - runpy.run_path(args[1], run_name='__main__') + exe = args[1] + if exe.startswith(':'): + import shutil + exe = shutil.which(exe[1:]) + if not exe: + raise SystemExit('{} not found in PATH'.format(args[1][1:])) + runpy.run_path(exe, run_name='__main__') def run_kitten(args): diff --git a/docs/Makefile b/docs/Makefile index 0655df551..210757882 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -T $(FAIL_WARN) -SPHINXBUILD = python3 .. +launch $(shell which sphinx-build) +SPHINXBUILD = python3 .. +launch :sphinx-build SPHINXPROJ = kitty SOURCEDIR = . BUILDDIR = _build