Skip to content

Instantly share code, notes, and snippets.

@ldong
Created June 18, 2014 19:14
Show Gist options
  • Save ldong/9a22fe008e896d574ade to your computer and use it in GitHub Desktop.
Save ldong/9a22fe008e896d574ade to your computer and use it in GitHub Desktop.
function python_finder {
python_library="-DPYTHON_LIBRARY="
python_include="-DPYTHON_INCLUDE_DIR="
# python_library="/Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/config"
# python_include="/Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/site-packages"
# The CMake 'FindPythonLibs' Module does not work properly.
# So we are forced to do its job for it.
python_prefix=$(python-config --prefix | sed 's/^[ \t]*//')
if [ -f "${python_prefix}/Python" ]; then
python_library+="${python_prefix}/Python"
python_include+="${python_prefix}/Headers"
else
which_python=$(python -c 'import sys;print(sys.version)' | sed 's/^[ \t]*//')
which_python="python${which_python:0:3}"
lib_python="${python_prefix}/lib/lib${which_python}"
if [ -f "${lib_python}.a" ]; then
python_library+="${lib_python}.a"
# This check is for for CYGWIN
elif [ -f "${lib_python}.dll.a" ]; then
python_library+="${lib_python}.dll.a"
else
python_library+="${lib_python}.dylib"
fi
python_include+="${python_prefix}/include/${which_python}"
fi
python_library="-DPYTHON_LIBRARY="
python_include="-DPYTHON_INCLUDE_DIR="
python_prefix="/System/Library/Frameworks/Python.framework/Versions/2.7"
python_library+="${python_prefix}/Python"
python_include+="${python_prefix}/Headers"
#python_library="/Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/config"
#python_include="/Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/site-packages"
#python_library+="/Users/ldong/.pyenv/versions/2.7.6/lib/libpython2.7.a"
#python_include+="/Users/ldong/.pyenv/versions/2.7.6/include/python2.7"
echo "${python_library} ${python_include}"
}
@ldong
Copy link
Author

ldong commented Jun 18, 2014

Old but working

-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable version "2.7.5", minimum required is "2.6")
-- Found PythonInterp: /Users/ldong/.pyenv/shims/python (found version "2.7.6")

New but not working

-- Found PythonLibs: /Users/ldong/.pyenv/versions/2.7.6/lib/libpython2.7.a (Required is at least version "2.6")
-- Found PythonInterp: /Users/ldong/.pyenv/shims/python (found version "2.7.6")

@ldong
Copy link
Author

ldong commented Jun 18, 2014

-DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dylib
/System/Library/Frameworks/Python.framework/Versions/2.7
Go to

cmake -G "Unix Makefiles" -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dylib

make ycm_support_libs

Read the fucking doc

@ldong
Copy link
Author

ldong commented Jun 18, 2014

cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/usr/lib/libclapack.dylib . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.dylib

@ldong
Copy link
Author

ldong commented Jun 18, 2014

My version of YCM

/Users/ldong/.pyenv/versions/2.7.6/lib/libpython2.7.a
/Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/site-packages/Users/ldong/.pyenv/versions/2.7.6/include/python2.7

New version of YCM

-DPYTHON_LIBRARY=/Users/ldong/.pyenv/versions/2.7.6/lib/libpython2.7.a 
-DPYTHON_INCLUDE_DIR=/Users/ldong/.pyenv/versions/2.7.6/include/python2.7

@ldong
Copy link
Author

ldong commented Jun 18, 2014

mine

/var/folders/jk/8dtll3q94tl33p291bw8_76c0000gn/T/ycm_build.XXXXXX.kO5BbIb2 ~/.vim/bundle/vim_youcompleteme
Path
/Users/ldong/.pyenv/versions/2.7.6/lib/libpython2.7.a /Users/ldong/.pyenv/versions/2.7.6/lib/python2.7/site-packages/Users/ldong/.pyenv/versions/2.7.6/include/python2.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment