-
Notifications
You must be signed in to change notification settings - Fork 283
Allow to use custom python interpreter [fixes #339] #401
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
Allow to use custom python interpreter [fixes #339] #401
Conversation
Thanks for your interest in palantir/python-language-server, @st4lk! Before we can accept your pull request, you need to sign our contributor license agreement - just visit https://cla.palantir.com/ and follow the instructions. Once you sign, I'll automatically update this pull request. |
Why can't your client just take the command |
@gatesn |
Even if I'll install |
From jedi doc:
So by defualt, it will return system python or python from So need to specify Another option is to take virtualenv path from |
Added a new commit - get virtualenv from |
Just to be sure we are on the same page: my goal is to tell jedi, where virtualenv for my current project is. I don't want to install pyls in every project's virtualenv. This is not about starting pyls from custom virtualenv (not from default's python). This can be achived by specifying path to |
In fact I'm not completely sure about Your call |
@gatesn: @st4lk is correct we do not want to have to install pls in every venv, but have it installed separately from the Workspace's venv and have a way to alter the sys.path passed to Jedi to search the Workspace venv libs. @st4lk I also prefer the approach in your first commit. The only thing is the non-public method you've used jedi.api.environment._get_python_prefix() isn't in Jedi master branch anymore so needs changed. There's also PR #382 which uses an alternative approach to pass in an extraSysPath config option from the client list - I'm currently using pls with this PR merged and it works well. However I do think the approach taken in this PR of passing in the venv path to pls and having Jedi work out the sys.path using its Environment API is a bit more elegant. It will also give clients an option to detect if they're running inside a venv and dynamically pass in the $VIRTUAL_ENV path for the current Workspace without needing to hardcode paths in config files. But maybe there's a need for both approaches? @Kronuz do you think both PRs config options are needed? |
@spr0cketeer, each PR is for different things; I would thing both are needed. |
How about we do something like this:
|
90d9fe9
to
9551f5c
Compare
@gatesn With this patch, I don't need to install P.S. updated commit to use only |
a6829dc
to
c8dbb18
Compare
c8dbb18
to
26ca5a0
Compare
@gatesn version >= 1.13.0 contains this fix: davidhalter/jedi@56bd795#diff-c204f420c3d90e6c005f6354c65dc638R161 Now, passing path to virtualenv of my project in |
26ca5a0
to
008c432
Compare
008c432
to
8fe2e0b
Compare
Jedi version was updated by another commit: 50d03d5 |
Python interpreter or virtualenv can be specified in settings. Server can receive them from
workspace/didChangeConfiguration
request.Tested with SublimeText 3 and LSP client plugin.
Example of Sublime LSP plugin settings:
Example of Sublime Text 3 project settings (to specify virtualenv specific to current project):