-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Editable installs (pip install -e) aren't fully supported #78
Comments
I wonder if this is related to my issue #70 My package isn't installed by pip but it is symlinked into the site packages folder like pip would do in editable mode. |
I do not believe we currently handle editable installs. |
I can confirm the same as @bobatsar describes when using pipenv install -e. Installing a package normally everything works. |
so do i |
Hey, I'm encountering the same issue with editable installs. Are there any plans to tackle this issue? I'm also happy to look into contributing a fix, but I may need a pointer in the right direction. 🙂 |
Any updates we have will be posted here; I know we want to look into this but it will take some care to get right. There are other things that have taken priority over working on editable installs / pth files. You could look at the pyright import resolver and path system to see what might be needed, but having personally added editable install support to the old language server previously, it may be tricky. (Or, it may be a simple bug, given we are supposed to be using the paths given by the interpreter and edtiable installs install pth files which modify what Python tell us.) |
Yeah, this is a tricky area of the code. I'd prefer that you don't attempt any changes. If you want to debug and report back, that'd be fine. |
After looking at this code for another bug, there are a couple places that stand out as problematic in the current code. The main thing is that with editable installs, the interpreter provides the paths, so that's what we want to work. |
Noting this as another example to use for testing: #892 (comment) |
If anyone is looking for a VSCode solution in the meantime, you can add something like:
to your settings. |
@jakebailey, I think this should fully work now. |
I believe it only works so long as the code you added to parse pth files by hand is triggered (and the pth file does not contain anything but strings; not true for libraries like matplotlib or pywin32) In the case of a regular interpreter where that code is not used and we are relying on it to read |
I've tested it out, and things do work as expected, but only the first time things load. There's a global cache in front of our calls to python for path info which means that when the file watcher detects that the new package has been installed (the egg-link is created), we still return the old results. This cache is never cleared. As far as I can tell, there are only a few uses of the call to python. Two of them only run on settings change, and the rest come from the import resolver which has another cache for this function specifically (that is cleared on import resolver invalidation, which happens on library changes). So, I think that it's safe for us to just remove this cache, and then editable installs will work both on first load and |
At this point (besides needing to force a restart when changing things while Pylance is running), I believe editable installs to be working. I'd appreciate if those watching this thread who use editable installs could confirm that things work as expected. Pinging a few who have commented (sorry 🙂): @bobatsar @erinxocon @NiklasRosenstein @wojtek-viirtue @zuozhiwen @mjmaurer |
@jakebailey on my side it seems good now. |
This issue has been fixed in version 2021.3.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202132-17-march-2021 |
I am seeing this same problem with pyright (integrated into emacs). |
Yes, the same code is present in both. You may want to file a new issue on the pyright tracker (if your issue is pyright focused); this one has been closed for 6 months. |
I still get Missing Imports warning for pylance in vs-code notebooks. (works fine on scripts) I understand this could be outside the scope of this repo. But does anyone have a suggestion? |
@rupeshknn, this issue has been closed for more than a year. Please file a new issue on the behavior your are seeing. |
I don't know if anything changed but it seems it is not working any longer on my side. Should I open another ticket or can this be reopened? |
@bobatsar, please read https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#editable-install-modules-not-found. If the issue described there is not what you are encountering, please open a new issue. |
Thanks @debonte for the link. I didn't know that there were some changes in the underlying handling of editable installs. |
The extra paths should point to the root of the project (in case this isn't clear to anyone) "python.analysis.extraPaths": [
"<path-to-project-root-of-editable-installed-package>",
], |
My solution not to change the vscode setting is to install in compat mode:
|
worked for me. Ty so much! |
I tried that but get the following error:
Python version 3.11, virtual environment, Ubuntu 22.04 on WSL. |
This is probably due to this : https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behavior :/ |
Environment data
Expected behaviour
If python packages are installed in "develop" mode with
code completion should work as normal.
Actual behaviour
Code completion is not working when packages are installed as "develop"
When installing them normally with
everything seems to work.
The text was updated successfully, but these errors were encountered: