Hi! Does any of you use vscode with pants? if so, ...
# general
t
Hi! Does any of you use vscode with pants? if so, could you pls provide any tips on how you set it up? specifically the python setup e.g python path. Thank you!
r
I don’t use VsCode with pants unfortunately
But I can look into what your pythonpath should look like
I can’t find anything useful 😞 I think the best bet is to search if someone has implemented an LSP server for python as a pants plugin, or wrapped an existing one, and use that to connect to VSCode
e
Depending on how you have your repo setup, maintaining a virtualenv tends to work well, since most editors that understand python understand pointing to a venv. If VSCode supports this, then create an empty venv and populate it with something like
pip install -U -r <(./pants dependencies --external-only 3rdparty/python::)
. This example is taken from the pants repo, your python 3rdparty dependencies may be located elsewhere. The key bit is the
./pants dependencies ...
subcommand which looks like so for the pants repo:
Copy code
$ ./pants dependencies --external-only 3rdparty/python::
twitter.common.collections<0.4,>=0.3.1
twitter.common.dirutil<0.4,>=0.3.1
twitter.common.confluence<0.4,>=0.3.1
pywatchman==1.4.1
pyopenssl==17.3.0
setproctitle==1.1.10
future==0.16.0
pyflakes==2.0.0
thrift>=0.9.1
contextlib2==0.5.5
coverage<4.6,>=4.5
wheel==0.31.1
requests[security]<2.19,>=2.5.0
fasteners==0.14.1
s3-log-parse==0.1.1
pathspec==0.5.0
pytest<4.0,>=3.4
Markdown==2.1.1
packaging==16.8
psutil==4.3.0
pex==1.5.3
futures==3.0.5; python_version < "3"
six<2,>=1.9.0
beautifulsoup4<4.7,>=4.6.0
faulthandler==2.6; python_version < "3"
parameterized==0.6.1
pytest-cov<2.6,>=2.5
mock==2.0.0
antlr_python_runtime==3.1.3
configparser==3.5.0
pystache==0.5.3
ansicolors==1.0.2
cffi==1.11.1
Pygments==1.4
subprocess32==3.2.7; python_version < "3"
docutils<0.13,>=0.12
setuptools==40.4.3
scandir==1.2
pycodestyle==2.4.0
www-authenticate==0.9.2
That output is compatible with a python requirements file which is what
pip install -f
expects.
t
thanks @enough-analyst-54434 and @red-balloon-89377
a
i’m working on a BSP (https://github.com/scalacenter/bsp) implementation for pants which should make extending to editors such as VSCode much simpler. intellij has a client implementation and i was talking with justin kaeser from jetbrains about it at scale by the bay so the only thing holding me back is bandwidth. VSCode would need a client impl as well but i love javascript
(there may need to be an LSP impl potentially as well depending on how VSCode handles python, but BSP at least addresses the issue of loading your project into the editor)
f
@enough-analyst-54434 if that approach works, I think it’d be good to have it documented in a more durable place