|
@@ -0,0 +1,77 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+import os
|
|
|
+import vim
|
|
|
+import functools
|
|
|
+from ycmd import utils
|
|
|
+
|
|
|
+DIR_OF_CURRENT_SCRIPT = os.path.dirname( os.path.abspath( __file__ ) )
|
|
|
+
|
|
|
+WIN_PYTHON27_PATH = 'C:\python27\python.exe'
|
|
|
+WIN_PYTHON26_PATH = 'C:\python26\python.exe'
|
|
|
+
|
|
|
+
|
|
|
+def Memoize( obj ):
|
|
|
+ cache = obj.cache = {}
|
|
|
+
|
|
|
+ @functools.wraps( obj )
|
|
|
+ def memoizer( *args, **kwargs ):
|
|
|
+ key = str( args ) + str( kwargs )
|
|
|
+ if key not in cache:
|
|
|
+ cache[ key ] = obj( *args, **kwargs )
|
|
|
+ return cache[ key ]
|
|
|
+ return memoizer
|
|
|
+
|
|
|
+
|
|
|
+@Memoize
|
|
|
+def PathToPythonInterpreter():
|
|
|
+ user_path_to_python = vim.eval( 'g:ycm_path_to_python_interpreter' )
|
|
|
+
|
|
|
+ if user_path_to_python:
|
|
|
+ return user_path_to_python
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ python_names = [ 'python2', 'python' ]
|
|
|
+
|
|
|
+ path_to_python = utils.PathToFirstExistingExecutable( python_names )
|
|
|
+ if path_to_python:
|
|
|
+ return path_to_python
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if utils.OnWindows():
|
|
|
+ if os.path.exists( WIN_PYTHON27_PATH ):
|
|
|
+ return WIN_PYTHON27_PATH
|
|
|
+ elif os.path.exists( WIN_PYTHON26_PATH ):
|
|
|
+ return WIN_PYTHON26_PATH
|
|
|
+
|
|
|
+ raise RuntimeError( 'Python 2.7/2.6 not installed!' )
|
|
|
+
|
|
|
+
|
|
|
+def PathToServerScript():
|
|
|
+ return os.path.join( DIR_OF_CURRENT_SCRIPT, '..', '..', 'third_party',
|
|
|
+ 'ycmd', 'ycmd' )
|
|
|
+
|
|
|
+
|
|
|
+def PathToCheckCoreVersion():
|
|
|
+ return os.path.join( DIR_OF_CURRENT_SCRIPT, '..', '..', 'third_party',
|
|
|
+ 'ycmd', 'check_core_version.py' )
|