Browse Source

Starting ycmd with Python used to build it

Note: depends on Valloric/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
Val Markovic 9 years ago
parent
commit
8fe90b43c4
3 changed files with 19 additions and 2 deletions
  1. 16 1
      python/ycm/paths.py
  2. 2 0
      python/ycm/tests/paths_test.py
  3. 1 1
      third_party/ycmd

+ 16 - 1
python/ycm/paths.py

@@ -63,6 +63,10 @@ def PathToPythonInterpreter():
     raise RuntimeError( "Path in 'g:ycm_server_python_interpreter' option "
                         "does not point to a valid Python 2.6+ or 3.3+." )
 
+  python_interpreter = _PathToPythonUsedDuringBuild()
+  if IsPythonVersionCorrect( python_interpreter ):
+    return python_interpreter
+
   # On UNIX platforms, we use sys.executable as the Python interpreter path.
   # We cannot use sys.executable on Windows because for unknown reasons, it
   # returns the Vim executable. Instead, we use sys.exec_prefix to deduce the
@@ -90,9 +94,20 @@ def PathToPythonInterpreter():
                       "option." )
 
 
+def _PathToPythonUsedDuringBuild():
+  from ycmd import utils
+
+  try:
+    filepath = os.path.join( DIR_OF_YCMD, 'PYTHON_USED_DURING_BUILDING' )
+    return utils.ReadFile( filepath ).strip()
+  # We need to check for IOError for Python2 and OSError for Python3
+  except ( IOError, OSError ):
+    return None
+
+
 def EndsWithPython( path ):
   """Check if given path ends with a python 2.6+ or 3.3+ name."""
-  return PYTHON_BINARY_REGEX.search( path ) is not None
+  return path and PYTHON_BINARY_REGEX.search( path ) is not None
 
 
 def IsPythonVersionCorrect( path ):

+ 2 - 0
python/ycm/tests/paths_test.py

@@ -66,6 +66,8 @@ def EndsWithPython_Python3Paths_test():
 
 def EndsWithPython_BadPaths_test():
   not_python_paths = [
+    None,
+    '',
     '/opt/local/bin/vim',
     r'C:\Program Files\Vim\vim74\gvim.exe',
     '/usr/bin/python2.5',

+ 1 - 1
third_party/ycmd

@@ -1 +1 @@
-Subproject commit 09f216441f99c02d51f9460e006683c5fe83669e
+Subproject commit 89e558f7d49b6d9672477c0d1b4df41d33f1c2e7