-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Python virtual env support #2973
Comments
Replying to @AlexTugarev's post in the thread linked above:
This is how I see it: the user will have some UI to change the currently selected virtual environment one way or another. Maybe it will be as simple as a preference, or more complete UI like the C++ build configurations. Changing the selected virtual environment should trigger a restart of the language server, where the new language server will be spawned with a new value of VIRTUAL_ENV. There is an example of language server being restarted in #2907. I still need to confirm that the same strategy would work here. About the language server being launched in a container thing, I am not sure what it changes. If your backend contributes a different python contribution that spawns the python language server differently (in a container), then it will just need to honor the virtualEnv parameter that is sent by the frontend, and inject the VIRTUAL_ENV environment variable in the container. Or maybe I don't understand what you mean. |
So as I feared, let's say the Python language server was created initially with the If we want to continue on this path, we would need to figure out how to completely tear down the rpc channel and create a new one on a different path. An alternative path would instead be to delay the start of the language server when opening the |
Thanks @simark for the detailed explanation. As far as I understand your requirement, it goes well with what I was thinking about the situation, where the pyls/python is started on a remote machine. Could you please test your requirement with the following concept?
In general, I think we can accomplish that without touching the language client. Managing of environments can be done in completely different ways, therefore I prefer to separate it from the languages service. |
That would be exactly the effect, if we would have an python environment manager in place, which would read the VIRTUAL_ENV value and inject it once called in |
I'm not 100% sure we are totally in sync, may it's me missing the point...
I am not sure I understand how, if as a user I set VIRTUAL_ENV in a terminal session, it could be picked up by Theia. Unless that terminal session is the one from which I also start the backend? But I don't think that's what you meant.
Well, if the user wishes to use a virtualenv, you will have to find a way to set that VIRTUAL_ENV variable even if the process runs remotely. Also, if the process runs remotely, it will need to somehow have access to the same filesystem, with the project at the same path as where Theia runs? Otherwise we would need some kind of path translation mechanism I guess.
There is already a way to restart the language server (not very well tested though). Calling
The way I see it, the change in the virtual env to use always comes from the user (the virtualenv path is not something the project sources dictate, it's something the user decides). To the change in the virtual env to use will come from Theia, either by the user changing a preference or choosing a path in a pre-defined list.
I see it the other way around: when the user decides to use a different virtual env, we restart the language server with a different VIRTUAL_ENV env var value (we don't react to something changing the value of the VIRTUAL_ENV env var. |
I would love to see this feature. Support for Conda environment would also be great! |
We no longer implement any LSP functionality. Closing. |
This issue is to track support of virtualenv when writing Python code. The scope of the feature (at least in my mind) is to provide a way for the user to specify the virtual environment they intend to run their code in. This will influence how the code is analyzed by the language server.
See the original discussion here:
4ba4e65#r30632208
cc @AlexTugarev @marechal-p
The text was updated successfully, but these errors were encountered: