()
| 33 | # after running the install script or setting the |
| 34 | # `g:ycm_server_python_interpreter` option. |
| 35 | def PathToPythonInterpreter(): |
| 36 | # Not calling the Python interpreter to check its version as it significantly |
| 37 | # impacts startup time. |
| 38 | from ycmd import utils |
| 39 | |
| 40 | python_interpreter = vim.eval( 'g:ycm_server_python_interpreter' ) |
| 41 | if python_interpreter: |
| 42 | python_interpreter = utils.FindExecutable( python_interpreter ) |
| 43 | if python_interpreter: |
| 44 | return python_interpreter |
| 45 | |
| 46 | raise RuntimeError( "Path in 'g:ycm_server_python_interpreter' option " |
| 47 | "does not point to a valid Python 3.6+." ) |
| 48 | |
| 49 | python_interpreter = _PathToPythonUsedDuringBuild() |
| 50 | if python_interpreter and utils.GetExecutable( python_interpreter ): |
| 51 | return python_interpreter |
| 52 | |
| 53 | # On UNIX platforms, we use sys.executable as the Python interpreter path. |
| 54 | # We cannot use sys.executable on Windows because for unknown reasons, it |
| 55 | # returns the Vim executable. Instead, we use sys.exec_prefix to deduce the |
| 56 | # interpreter path. |
| 57 | python_interpreter = ( WIN_PYTHON_PATH if utils.OnWindows() else |
| 58 | sys.executable ) |
| 59 | if _EndsWithPython( python_interpreter ): |
| 60 | return python_interpreter |
| 61 | |
| 62 | python_interpreter = utils.PathToFirstExistingExecutable( [ 'python3', |
| 63 | 'python' ] ) |
| 64 | if python_interpreter: |
| 65 | return python_interpreter |
| 66 | |
| 67 | raise RuntimeError( "Cannot find Python 3.6+. " |
| 68 | "Set the 'g:ycm_server_python_interpreter' option " |
| 69 | "to a Python interpreter path." ) |
| 70 | |
| 71 | |
| 72 | def _PathToPythonUsedDuringBuild(): |
nothing calls this directly
no test coverage detected