-
Notifications
You must be signed in to change notification settings - Fork 542
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
Smooth IDE support for python_rules #1401
Comments
Note, that For now you could use https://github.com/cedarai/rules_pyvenv to create a virtual environment for a target, that provides good editor integration. That may work with generated code. |
https://github.com/aspect-build/rules_py has the explicit goal of providing excellent Python IDE support for |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
...rather than rules_python's, and create a .vscode/settings.json that points `python.defaultInterpreterPath` at the venv it creates. This allows VSCode intellisense to work across imports out-of-the-box (among other benefits), at least until bazelbuild/rules_python#1401 is fixed.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
Recently, the IntelliJ/PyCharm plugin has received a lot of great patches, I think your could try it |
Hi, Would it be possible to provide an example on how to enable the IDE support? I can't seem to find any specific explanation of how to integrate these rules with any IDE (e.g. vscode). Thanks! |
@antspy In my testing, it was a lot easier to get this to work when the virtualenv is in the repo root, for some reason it was hard to get VSCode to discover one that's in a subfolder - but according to the docs it should work. LMK what you find. |
@alexeagle For posterity: I point VSCode to this environment (it should recognize it automatically) and things seem to be working! :) For the future:
Anyway, thank you for the help! :) |
I recorded a video walkthrough how this worked for me: https://www.youtube.com/watch?v=GTsy7IfmywQ&list=PLLU28e_DRwdu46fldnYzyFYvSJLjVFICd |
That's so cool, thanks a lot for doing this!! Very much appreciated :) :) |
🚀 feature request
Description
I would like smooth editor support of the python_rules. Now when I open an editor (tried helix and vscode) neither recognizes any of the third party imports properly breaking autocomplete and type checking.
Describe the solution you'd like
Something like what the rules_go people have done but I imagine that pyright (the most commonly used python language server) does not have support for something similar to the gopackagedriver.. So I was thinking more along the lines of a shell script that manipulates
PATH
andPYTHONPATH
to achieve something similar. still hacky but better than what I have now. It's also something that would work for other python language server's such as ruff-lsp.Describe alternatives you've considered
Manually make a venv with the same dependencies and activate that before starting my editor. Works fine but it's hackish and it won't work for generated code. For example python files generated from protobuf by Bazel..
The text was updated successfully, but these errors were encountered: