aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2019-01-07 14:46:58 +0100
committerMarco Hinz <mh.codebro@gmail.com>2019-01-07 23:29:46 +0100
commit75593e6fcebcfd1404c8851653d5d8b1195ee34c (patch)
tree5c4fb331fd1ec9381bff3e9afc01f05fd3585df2
parenteb91101a467004bda48fe0dd257a695d5b3d8d5f (diff)
downloadrneovim-75593e6fcebcfd1404c8851653d5d8b1195ee34c.tar.gz
rneovim-75593e6fcebcfd1404c8851653d5d8b1195ee34c.tar.bz2
rneovim-75593e6fcebcfd1404c8851653d5d8b1195ee34c.zip
health/pythonx: handle "pip upgrade failure"
Reference: https://github.com/neovim/neovim/wiki/Following-HEAD#20181118
-rw-r--r--runtime/autoload/health/provider.vim32
-rw-r--r--runtime/autoload/provider/pythonx.vim7
2 files changed, 26 insertions, 13 deletions
diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim
index 526623c86f..8f364a2ace 100644
--- a/runtime/autoload/health/provider.vim
+++ b/runtime/autoload/health/provider.vim
@@ -277,7 +277,7 @@ function! s:check_python(version) abort
let [pyname, pythonx_errors] = provider#pythonx#Detect(a:version)
if empty(pyname)
- call health#report_warn('No Python executable found that could `import neovim`. '
+ call health#report_warn('No Python executable found that can `import neovim`. '
\ . 'Using the first available executable for diagnostics.')
elseif exists('g:'.host_prog_var)
let python_exe = pyname
@@ -387,29 +387,37 @@ function! s:check_python(version) abort
let pip = 'pip' . (a:version == 2 ? '' : '3')
- if !empty(python_exe)
+ if empty(python_exe)
+ " No Python executable can import 'neovim'. Check if any Python executable
+ " can import 'pynvim'. If so, that Python failed to import 'neovim' as
+ " well, which is most probably due to a failed pip upgrade:
+ " https://github.com/neovim/neovim/wiki/Following-HEAD#20181118
+ let [pynvim_exe, errors] = provider#pythonx#DetectByModule('pynvim', a:version)
+ if !empty(pynvim_exe)
+ call health#report_error(
+ \ 'Detected pip upgrade failure: Python executable can import "pynvim" but '
+ \ . 'not "neovim": '. pynvim_exe,
+ \ "Use that Python version to reinstall \"pynvim\" and optionally \"neovim\".\n"
+ \ . pip ." uninstall pynvim neovim\n"
+ \ . pip ." install pynvim\n"
+ \ . pip ." install neovim # only if needed by third-party software")
+ endif
+ else
let [pyversion, current, latest, status] = s:version_info(python_exe)
+
if a:version != str2nr(pyversion)
call health#report_warn('Unexpected Python version.' .
\ ' This could lead to confusing error messages.')
endif
+
if a:version == 3 && str2float(pyversion) < 3.3
call health#report_warn('Python 3.3+ is recommended.')
endif
call health#report_info('Python version: ' . pyversion)
+
if s:is_bad_response(status)
call health#report_info(printf('pynvim version: %s (%s)', current, status))
- let [module_found, _msg] = provider#pythonx#CheckForModule(python_exe,
- \ 'pynvim', a:version)
- if status !=? '^outdated' && module_found
- " neovim module was not found, but pynvim was
- call health#report_error('Importing "neovim" failed.',
- \ "Reinstall \"pynvim\" and optionally \"neovim\" packages.\n" .
- \ pip ." uninstall pynvim neovim\n" .
- \ pip ." install pynvim\n" .
- \ pip ." install neovim # only if needed by third-party software")
- endif
else
call health#report_info(printf('pynvim version: %s', current))
endif
diff --git a/runtime/autoload/provider/pythonx.vim b/runtime/autoload/provider/pythonx.vim
index 06611377b1..59b1c27b72 100644
--- a/runtime/autoload/provider/pythonx.vim
+++ b/runtime/autoload/provider/pythonx.vim
@@ -35,6 +35,11 @@ endfunction
" Returns [path_to_python_executable, error_message]
function! provider#pythonx#Detect(major_version) abort
+ return provider#pythonx#DetectByModule('neovim', a:major_version)
+endfunction
+
+" Returns [path_to_python_executable, error_message]
+function! provider#pythonx#DetectByModule(module, major_version) abort
let python_exe = s:get_python_executable_from_host_var(a:major_version)
if !empty(python_exe)
@@ -45,7 +50,7 @@ function! provider#pythonx#Detect(major_version) abort
let errors = []
for exe in candidates
- let [result, error] = provider#pythonx#CheckForModule(exe, 'neovim', a:major_version)
+ let [result, error] = provider#pythonx#CheckForModule(exe, a:module, a:major_version)
if result
return [exe, error]
endif