mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	provider/pythonx: handle exit code 127 from pyenv
This also checks the major/min version only for expected return codes.
With pyenv, you might get the following (return code 127):
    pyenv: python3.4: command not found
    The `python3.4' command exists in these Python versions:
      3.4.3
      3.4.3/envs/tmp-3.4.3-eElS6Y
      tmp-3.4.3-eElS6Y
			
			
This commit is contained in:
		@@ -83,8 +83,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
 | 
				
			|||||||
  " Try to load neovim module, and output Python version.
 | 
					  " Try to load neovim module, and output Python version.
 | 
				
			||||||
  " Return codes:
 | 
					  " Return codes:
 | 
				
			||||||
  "   0  Neovim module can be loaded.
 | 
					  "   0  Neovim module can be loaded.
 | 
				
			||||||
  "   1  Something else went wrong.
 | 
					 | 
				
			||||||
  "   2  Neovim module cannot be loaded.
 | 
					  "   2  Neovim module cannot be loaded.
 | 
				
			||||||
 | 
					  "   Otherwise something else went wrong (e.g. 1 or 127).
 | 
				
			||||||
  let prog_ver = system([ a:prog , '-c' ,
 | 
					  let prog_ver = system([ a:prog , '-c' ,
 | 
				
			||||||
        \ 'import sys; ' .
 | 
					        \ 'import sys; ' .
 | 
				
			||||||
        \ 'sys.path.remove(""); ' .
 | 
					        \ 'sys.path.remove(""); ' .
 | 
				
			||||||
@@ -93,7 +93,8 @@ function! s:check_interpreter(prog, major_ver, skip) abort
 | 
				
			|||||||
        \ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
 | 
					        \ 'exit(2*int(pkgutil.get_loader("neovim") is None))'
 | 
				
			||||||
        \ ])
 | 
					        \ ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if prog_ver
 | 
					  if v:shell_error == 2 || v:shell_error == 0
 | 
				
			||||||
 | 
					    " Check version only for expected return codes.
 | 
				
			||||||
    if prog_ver !~ '^' . a:major_ver
 | 
					    if prog_ver !~ '^' . a:major_ver
 | 
				
			||||||
      return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
 | 
					      return [0, prog_path . ' is Python ' . prog_ver . ' and cannot provide Python '
 | 
				
			||||||
            \ . a:major_ver . '.']
 | 
					            \ . a:major_ver . '.']
 | 
				
			||||||
@@ -103,12 +104,16 @@ function! s:check_interpreter(prog, major_ver, skip) abort
 | 
				
			|||||||
    endif
 | 
					    endif
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if v:shell_error == 1
 | 
					  if v:shell_error == 2
 | 
				
			||||||
    return [0, 'Checking ' . prog_path . ' caused an unknown error. '
 | 
					    return [0, prog_path . ' does not have the neovim module installed. '
 | 
				
			||||||
          \ . 'Please report this at github.com/neovim/neovim.']
 | 
					 | 
				
			||||||
  elseif v:shell_error == 2
 | 
					 | 
				
			||||||
    return [0, prog_path . ' does have not have the neovim module installed. '
 | 
					 | 
				
			||||||
          \ . 'See ":help nvim-python".']
 | 
					          \ . 'See ":help nvim-python".']
 | 
				
			||||||
 | 
					  elseif v:shell_error == 127
 | 
				
			||||||
 | 
					    " This can happen with pyenv's shims.
 | 
				
			||||||
 | 
					    return [0, prog_path . ' does not exist: ' . prog_ver]
 | 
				
			||||||
 | 
					  elseif v:shell_error
 | 
				
			||||||
 | 
					    return [0, 'Checking ' . prog_path . ' caused an unknown error. '
 | 
				
			||||||
 | 
					          \ . '(' . v:shell_error . ', output: ' . prog_ver . ')'
 | 
				
			||||||
 | 
					          \ . ' Please report this at github.com/neovim/neovim.']
 | 
				
			||||||
  endif
 | 
					  endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return [1, '']
 | 
					  return [1, '']
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user