Skip to content

Commit

Permalink
Auto merge of #2140 - Valloric:ubuntu-fix, r=micbou
Browse files Browse the repository at this point in the history
[READY] Starting ycmd with Python used to build it

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

Fixes #2136

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2140)
<!-- Reviewable:end -->
  • Loading branch information
homu committed Apr 28, 2016
2 parents 7f41910 + 8fe90b4 commit cb57569
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion python/ycm/paths.py
Expand Up @@ -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
Expand Down Expand Up @@ -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 ):
Expand Down
2 changes: 2 additions & 0 deletions python/ycm/tests/paths_test.py
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion third_party/ycmd
Submodule ycmd updated from 09f216 to 89e558

2 comments on commit cb57569

@ehzawad
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hell

After updating to this commit...

@puremourning
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run git submodule update --init --recursive and re run install.py?

If so please file a new issue and complete the issue template

Please sign in to comment.