From 005bf83e9c87ad40166b2ca2811435f0b5b8c709 Mon Sep 17 00:00:00 2001 From: Peter Linss Date: Wed, 24 May 2017 19:46:41 -0700 Subject: [PATCH] Search for python interpreters in system path Currently the linter complains if the path to the python interpreter isn't an absolute path. This adds a search in the system path allowing relative paths to work. --- Flake8Lint.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Flake8Lint.py b/Flake8Lint.py index 326cc77..a20b966 100644 --- a/Flake8Lint.py +++ b/Flake8Lint.py @@ -1193,11 +1193,19 @@ def async_lint(view, view_settings, quiet=False): else: interpreter = 'python' log("guess interpreter: '{0}'".format(interpreter)) - elif not os.path.exists(interpreter): - sublime.error_message( - "Python Flake8 Lint error:\n" - "python interpreter '%s' is not found" % interpreter - ) + else: + if not os.path.isabs(interpreter): + system_path = os.get_exec_path() + for path in system_path: + if (os.path.exists(os.path.join(path, interpreter))): + interpreter = os.path.join(path, interpreter) + break + else: + if not os.path.exists(interpreter): + sublime.error_message( + "Python Flake8 Lint error:\n" + "python interpreter '%s' is not found" % interpreter + ) # build linter path for Packages Manager installation linter = os.path.join(PLUGIN_DIR, 'lint.py')