From 339dd4b1fb25db2c592cd93e01d83a5b03a66f66 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 22 Oct 2016 17:28:17 +0200 Subject: [PATCH 1/6] s:check_python: handle 'pip install --user -e' --- runtime/autoload/health/provider.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 98e2f90155..a26ac7e902 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -174,7 +174,9 @@ function! s:version_info(python) abort let nvim_version = 'unable to find nvim version' let base = fnamemodify(nvim_path, ':h') - let metas = glob(base.'-*/METADATA', 1, 1) + glob(base.'-*/PKG-INFO', 1, 1) + let metas = glob(base.'-*/METADATA', 1, 1) + \ + glob(base.'-*/PKG-INFO', 1, 1) + \ + glob(base.'.egg-info/PKG-INFO', 1, 1) let metas = sort(metas, 's:compare') if !empty(metas) From 0583ca63a52e2dea8945475e726d1c7d55da2ec7 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 22 Oct 2016 17:35:01 +0200 Subject: [PATCH 2/6] Improve error reporting for Python health check - s:version_info: return errors from the `import` - skip report_ok for latest version, in case the current version was not found. status contains the error that has been reported in that case already. --- runtime/autoload/health/provider.vim | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index a26ac7e902..1d181f9ac4 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -155,13 +155,10 @@ function! s:version_info(python) abort endif let nvim_path = s:trim(s:system([ - \ a:python, - \ '-c', - \ 'import neovim; print(neovim.__file__)'])) - let nvim_path = s:shell_error ? '' : nvim_path - - if empty(nvim_path) - return [python_version, 'unable to find nvim executable', pypi_version, 'unable to get nvim executable'] + \ a:python, '-c', 'import neovim; print(neovim.__file__)'])) + if s:shell_error || empty(nvim_path) + return [python_version, 'unable to load neovim Python module', pypi_version, + \ nvim_path] endif " Assuming that multiple versions of a package are installed, sort them @@ -172,7 +169,7 @@ function! s:version_info(python) abort return a == b ? 0 : a > b ? 1 : -1 endfunction - let nvim_version = 'unable to find nvim version' + let nvim_version = 'unable to find neovim Python module version' let base = fnamemodify(nvim_path, ':h') let metas = glob(base.'-*/METADATA', 1, 1) \ + glob(base.'-*/PKG-INFO', 1, 1) @@ -390,7 +387,7 @@ function! s:check_python(version) abort if s:is_bad_response(status) call health#report_warn(printf('Latest %s-neovim is NOT installed: %s', \ python_bin_name, latest)) - elseif !s:is_bad_response(latest) + elseif !s:is_bad_response(latest) !s:is_bad_response(current) call health#report_ok(printf('Latest %s-neovim is installed: %s', \ python_bin_name, latest)) endif From 5ce50504f99124e9363804dd853a85d07e9c9d2f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Jan 2017 13:32:55 +0100 Subject: [PATCH 3/6] healthcheck: python: include nvim path for unknown/outdated version This helps to identify where the `neovim` module is coming from, e.g. - INFO: python3-neovim version: 0.1.10 (outdated; from ~/Vcs/neovim-python-client/neovim) - WARNING: Latest python3-neovim is NOT installed: 0.1.12 --- runtime/autoload/health/provider.vim | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 1d181f9ac4..b1a3711390 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -185,10 +185,11 @@ function! s:version_info(python) abort endfor endif - let version_status = 'unknown' + let nvim_path_base = fnamemodify(nvim_path, ':~:h') + let version_status = 'unknown; '.nvim_path_base if !s:is_bad_response(nvim_version) && !s:is_bad_response(pypi_version) if s:version_cmp(nvim_version, pypi_version) == -1 - let version_status = 'outdated' + let version_status = 'outdated; from '.nvim_path_base else let version_status = 'up to date' endif @@ -371,7 +372,11 @@ function! s:check_python(version) abort endif call health#report_info('Python'.a:version.' version: ' . pyversion) - call health#report_info(printf('%s-neovim version: %s', python_bin_name, current)) + if s:is_bad_response(status) + call health#report_info(printf('%s-neovim version: %s (%s)', python_bin_name, current, status)) + else + call health#report_info(printf('%s-neovim version: %s', python_bin_name, current)) + endif if s:is_bad_response(current) call health#report_error( From adf32e14033ebfafb1910410058ec7453e40e54f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Jan 2017 16:23:13 +0100 Subject: [PATCH 4/6] healthcheck: python: prefer neovim.VERSION --- runtime/autoload/health/provider.vim | 36 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index b1a3711390..81fc7ed4d1 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -37,6 +37,7 @@ endfunction function! s:system(cmd, ...) abort let stdin = a:0 ? a:1 : '' let ignore_stderr = a:0 > 1 ? a:2 : 0 + let ignore_error = a:0 > 2 ? a:3 : 0 let opts = { \ 'output': '', \ 'on_stdout': function('s:system_handler'), @@ -63,7 +64,7 @@ function! s:system(cmd, ...) abort call health#report_error(printf('Command timed out: %s', \ type(a:cmd) == type([]) ? join(a:cmd) : a:cmd)) call jobstop(jobid) - elseif s:shell_error != 0 + elseif s:shell_error != 0 && !ignore_error call health#report_error(printf("Command error (%d) %s: %s", jobid, \ type(a:cmd) == type([]) ? join(a:cmd) : a:cmd, \ opts.output)) @@ -169,20 +170,27 @@ function! s:version_info(python) abort return a == b ? 0 : a > b ? 1 : -1 endfunction - let nvim_version = 'unable to find neovim Python module version' - let base = fnamemodify(nvim_path, ':h') - let metas = glob(base.'-*/METADATA', 1, 1) - \ + glob(base.'-*/PKG-INFO', 1, 1) - \ + glob(base.'.egg-info/PKG-INFO', 1, 1) - let metas = sort(metas, 's:compare') + " Try to get neovim.VERSION (added in 0.1.11dev). + let nvim_version = s:system(['python', '-c', + \ 'from neovim import VERSION as v; '. + \ 'print("{}.{}.{}{}".format(v.major, v.minor, v.patch, v.prerelease))'], + \ '', 1, 1) + if empty(nvim_version) + let nvim_version = 'unable to find neovim Python module version' + let base = fnamemodify(nvim_path, ':h') + let metas = glob(base.'-*/METADATA', 1, 1) + \ + glob(base.'-*/PKG-INFO', 1, 1) + \ + glob(base.'.egg-info/PKG-INFO', 1, 1) + let metas = sort(metas, 's:compare') - if !empty(metas) - for meta_line in readfile(metas[0]) - if meta_line =~# '^Version:' - let nvim_version = matchstr(meta_line, '^Version: \zs\S\+') - break - endif - endfor + if !empty(metas) + for meta_line in readfile(metas[0]) + if meta_line =~# '^Version:' + let nvim_version = matchstr(meta_line, '^Version: \zs\S\+') + break + endif + endfor + endif endif let nvim_path_base = fnamemodify(nvim_path, ':~:h') From 7db0017f4e5bff4b31e2b665ebd80291a33e97d1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Jan 2017 16:42:35 +0100 Subject: [PATCH 5/6] healthcheck: s:check_python: only report latest with good response --- runtime/autoload/health/provider.vim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 81fc7ed4d1..58098b08f9 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -393,14 +393,12 @@ function! s:check_python(version) abort endif if s:is_bad_response(latest) - call health#report_warn('Unable to contact PyPI.') + call health#report_warn('Could not contact PyPI to get latest version.') call health#report_error('HTTP request failed: '.latest) - endif - - if s:is_bad_response(status) + elseif s:is_bad_response(status) call health#report_warn(printf('Latest %s-neovim is NOT installed: %s', \ python_bin_name, latest)) - elseif !s:is_bad_response(latest) !s:is_bad_response(current) + elseif !s:is_bad_response(current) call health#report_ok(printf('Latest %s-neovim is installed: %s', \ python_bin_name, latest)) endif From 35988b93e15a2b852d5a2dec91e992a5af37de7d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 8 Jan 2017 16:46:15 +0100 Subject: [PATCH 6/6] healthcheck: s:download: do not report curl errors (twice) Since `curl -s` is used, the actual error (e.g. "curl: (6) Could not resolve host: pypi.python.org") gets not reported anyway, and s:download returns an error message with `s:shell_error` already. This changes `s:download` to also include `a:url` in the error message now. It removes > ERROR: Command error (7) curl -sL https://pypi.python.org/pypi/neovim/json: And changes > ERROR: HTTP request failed: error: curl error with https://pypi.python.org/pypi/neovim/json: 6 --- runtime/autoload/health/provider.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/autoload/health/provider.vim b/runtime/autoload/health/provider.vim index 58098b08f9..417426c101 100644 --- a/runtime/autoload/health/provider.vim +++ b/runtime/autoload/health/provider.vim @@ -84,8 +84,8 @@ endfunction " Fetch the contents of a URL. function! s:download(url) abort if executable('curl') - let rv = s:system(['curl', '-sL', a:url]) - return s:shell_error ? 'curl error: '.s:shell_error : rv + let rv = s:system(['curl', '-sL', a:url], '', 1, 1) + return s:shell_error ? 'curl error with '.a:url.': '.s:shell_error : rv elseif executable('python') let script = " \try:\n