Git Product home page Git Product logo

Comments (2)

cjrh avatar cjrh commented on June 12, 2024

In the latest jedi code, see /jedi/evaluate/sys_path.py at the function get_sys_path(). We could either "pretend" to be a VIRTUAL_ENV (in order to be picked up here) or monkey-patch the get_sys_path() function. Or submit a jedi patch.

from vim-conda.

cjrh avatar cjrh commented on June 12, 2024

Ok, so it turns out that I misread the jedi-vim code. In fact, jedi-vim does really modify the sys.path of the embedded Python...which is what I am doing currently in vim-conda.

There are other issues. In /jedi/evaluate/sys_path.py, the get_sys_path() function looks like this:

def get_sys_path():
    def check_virtual_env(sys_path):
        """ Add virtualenv's site-packages to the `sys.path`."""
        venv = os.getenv('VIRTUAL_ENV')
        if not venv:
            return
        venv = os.path.abspath(venv)
        p = os.path.join(
            venv, 'lib', 'python%d.%d' % sys.version_info[:2], 'site-packages')
        sys_path.insert(0, p)

    check_virtual_env(sys.path)
    return [p for p in sys.path if p != ""]

The problem I've observed is that this function gets called a bunch of times while editing code. After one lookup for a completion, the embedded Python's sys.path looks like this:

image

Lots and lots of the same path getting .insert(0, p)ed. vim-conda does not do this: I am carefully managing the modification of sys.path at the moment. I would think that jedi-vim should operate lookups on a copy of sys.path rather than modify the actual one in the embedded vim-python (I wrongly assumed this was how it worked) but I don't yet know enough about how Jedi works to make a definitive statement about this yet.

I was working on a patch for jedi to incorporate a check for the Conda-specific environment variables, completely analogous to the VIRTUALENV version, but I think I'll hold off for now. The patch looked something like this:

image

Now that I see that jedi-vim modifies sys.path anyway, I'm going to go ahead and stick with my current design. Also, jedi-vim does not have to be modified in this case.

from vim-conda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.