Skip to content
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

PEP 582 support? #132

Closed
Gradecak opened this issue Dec 3, 2021 · 9 comments
Closed

PEP 582 support? #132

Gradecak opened this issue Dec 3, 2021 · 9 comments

Comments

@Gradecak
Copy link

Gradecak commented Dec 3, 2021

Hi all,

Just curious if there are any plans to support the loading of project local packages from __pypackages__ directory, as per PEP 582

Or even better, if this is somehow supported would it be possible to point me in the right direction to get pylsp to pick it up?

Thanks!

@krassowski
Copy link
Contributor

As this is not an approved PEP, I would say that no one is working actively to support it (the details might change, or the PEP may be rejected). However, some of tools used by pylsp already support PEP 582 (like jedi: davidhalter/jedi#839). I think to make it work you could start by auditing what other dependencies do support it or don't (and whether some declared that they won't unless the PEP is accepted) and then document what changes are needed to pylsp.

@vikigenius
Copy link

If you are using emacs here is how you can do it for lsp-python-ms pdm-project/pdm#372 (comment).

A similar thing should be possible with python-lsp-server as long as there is an option to add extra search paths.

@Gradecak
Copy link
Author

Thank you both for the helpful responses!

The pdm + lsp-python-ms setup is what prompted me to attempt to replicate the setup with pylsp. Unfortunately, as @krassowski has pointed out above its not quite as straight forward as I originally had thought, as all tools used by the python language server must also have this capability. In my particular case I put looking into this on pause once I discovered that mypy does not yet support searching for library stubs in __pypackages__.

Hopefully something as simple as extra search paths would be possible in the future, if the PEP is approved and gains larger adoption.

@vikigenius
Copy link

That's weird, how does mypy detect venvs? It should be getting that path somewhere right? Why not just modify that mechanism to point to wherever the libs are stored inside pypackages ?

@Gradecak
Copy link
Author

Gradecak commented Dec 22, 2021

If I'm not mistaken when you activate a virtualenv your PYTHONPATH changes and now points to the virtualenv and all the packages contained within. I don't believe that mypy has the ability to detect a virtualenv or knows that it is running inside of a virtualenv.

The same is likely (almost certainly) possible with __pypackages__ , however I would like to accomplish this natively within the tool without needing to activate (or even create) a virtualenv for each project I switch to. This requires the tool in question to search for __pypackages__ in the project root in accordance with PEP582

@vikigenius
Copy link

@Gradecak true, I know that the ideal situation is to have the tools themselves do it. But that won't happen until the PEP actually makes it. I really like the proposal, but it's been in limbo for a while and it will probably be a while if at all for it to be adopted.

@nyngwang
Copy link

nyngwang commented Mar 1, 2022

interested in this one. (It's OK to not support it though)

@doolio
Copy link
Contributor

doolio commented Nov 2, 2023

Considering this PEP is now rejected I think this issue could be closed. If the PEP reappears in some new form then the question of whether pylsp provides support can be revisited.

@ccordoba12
Copy link
Member

Closing then.

@ccordoba12 ccordoba12 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants