Closed valignatev closed 6 years ago
Hi, thanks for the contribution!
I have several questions:
importlib.reload
survived several renames. Does it present on this name under all supported python versions?sys.path
?What do you think?
Regards, Artem.
Hey, thanks for the fast response!
imp
for python2.7jedi.__version__
we might also check jedi.utils. version_info
I guessI meant check installation directory exists before trying to import jedi. And if it missed add it to the missing dependencies.
This is a great idea actually. Yeah, I'll try to do this and fix my PR accordingly.
I did the upfront checking for installation folders. There's a nested loop here now, but I think it won't harm since we're talking about 6 iterations in the worst case, and it's quite readable to me. I also kept try/except ImportError part just in case installation process fails somehow.
What do you think?
Thanks! I think this should work.
It seems that if python-shell-interpreter
was set to ipython3
, which depends on jedi
and will load it when starts, the sys.path
won't work when import jedi
again.
According to python's documentation, the modules loaded before will be put into sys.modules
as a cache, and if we want to import a module, python will first check whether it is in the cache, and load it directly if it is found. So if we install a old version of jedi
and it is loaded by ipython
first, the jedi
imported by anaconda-mode
will still be the old version, even if we have installed the newer version correctly in local directory and set sys.path
to it, which will cause the assert to fail.
It seems that there are no simple and universal ways to load a module directly from a specific directory.
I'm curious that if the API of jedi
doesn't change in recent versions, why should we force users to use the latest version or jedi
?
Hi! There's a case when jedi is installed globally, and it's of a lesser version than required by anaconda. It might happen quite often provided people using global installation of
ipython
, for example. In this case,import jedi
won't fail, and assertion for jedi version will always fail as well. This little pull request handles this case and also reloads jedi if needed after importing of an older version.What do you think?