ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.44k stars 2.81k forks source link

Feature request: Allow use of a custom PYTHONPATH #2468

Closed realh closed 7 years ago

realh commented 7 years ago

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside the brackets) before filing your issue:

Issue Details

I've been struggling to get ycm to support GObject Introspection via fakegir. fakegir's build-jedi-cache.sh didn't seem to do enough to get it working so I created a simple wrapper script to add ~/.cache/fakegir to PYTHONPATH and set its path in g:ycm_python_binary_path.

It would be easier if YCM had another variable to override PYTHONPATH instead of having to create a wrapper script.

vheon commented 7 years ago

Wouldn't be a better approach to use a virtualenv? Looks like is mentioned in the README of fakegit as well on how to use it. Once you have the virtualenv you can either set g:ycm_python_binary_path to the Python binary inside the virtualenv or you can do it at runtime with YcmCompleter Restart <path_to_binary_of_virtyalenv>. I think this would be nicer instead of acting directly on the PYTHONPATH. But I'm not a Python dev so maybe @micbou knows better?

realh commented 7 years ago

fakegir's README also says that the virtualenv method doesn't seem to work with python3, which is what I want to use.

micbou commented 7 years ago

fakegir's README also says that the virtualenv method doesn't seem to work with python3, which is what I want to use.

Did you try? I was able to get some completions of the gi module by copying the ~/.cache/fakegir folder to the site-packages of a Python 3 virtualenv created with pyenv-virtualenv.

puremourning commented 7 years ago

The author of the fakegir script says:

The other option which I use is to create a virtualenv and copy the fakegir gi package into it:

mkvirtualenv fakegir cdvirtualenv cd lib/python*/site-packages cp -a ~/.cache/fakegir/gi .

This appears to be what @micbou has had success with. So, you could try that? Adding yet more options for a very specific use case is not really something we want to do. Closing this for now, as it seems there is a workaround. We can re-open if there really is a bug or a feature request that will benefit large numbers of users.