Hi there :slightly_smiling_face: I have searched t...
# general
t
Hi there 🙂 I have searched through Slack already and know that it has been asked a few times already. I would love to gather ideas on this again: How are you using Pants (Python) with an IDE, VSCode in particular? Here is what we do currently: • Export third party dependencies and tools using resolves feature as described in https://www.pantsbuild.org/2.18/docs/using-pants/setting-up-an-ide • We run all our tests and applications (e.g. Django) with pants directly:
pants run
and
pants test
• We debug those using the pants debug-adapter • A pre-commit hook calls pants tools like fmt or lint There are some drawbacks we have observed compared to simply using native VSCode capabilities like debugging or running tests: • Due to pants principle of using sandboxes it takes quite a while until all those commands are ready to run • If a pants command is not properly terminated, one have to kill all pants processes manually I think one could use native VSCode capabilites if everything is exported properly and VSCode knows about everything as shown in https://www.pantsbuild.org/2.18/docs/using-pants/setting-up-an-ide. For example using the default debug method: https://code.visualstudio.com/docs/python/tutorial-django#_create-a-debugger-launch-profile. I would like to know which option of the two you are using? What are the drawbacks or advantages you have experienced?
❤️ 1
s
My team uses pants and most of us use vscode. We have 1 resolve for the entire monorepo. We also don't make use of things like code generation. This setup allows up to sidestep pants altogether by using the venv associated with the default resolve and updating our PYTHONPATH to include sources. VSCode will read a top level .env and pass that through to the test explorer for python. With a .env PYTHONPATH=src/ And default interpreter set to the exported venv you can take advantage of debugging through the editor
The docs have an example about generating a .env with your source roots. We just followed that
t
So, in the end pants is actually not used for local development except for exporting the venv?
The good thing about running the applications locally with pants is that you can already test if all BUILD files are correctly configured ahead of deployment, where we use PEX in Dockerfiles
s
Oh, we definitely encourage folks to use Pants. We took this approach because we couldn't put a pause on development for folks to learn Pants. We also needed an escape hatch if folks ran into weird issues that were difficult to reproduce. (E.g. Pants selecting a wonky version of python or a SHEBANG being > 128 characters)
t
Can you elaborate how you are using pants locally then?
Maybe others who seem to use VSCode with pants can add some thoughts? @bored-energy-25252 @curved-manchester-66006 @ripe-gigabyte-88964 @nutritious-application-35061 @freezing-fall-2672 @bumpy-noon-80834 @aloof-appointment-30987 @fresh-cat-90827 @bitter-ability-32190
s
Thanks for this thread. I am particularly interested in an alternative way to discover first party imports, rather than updating PYTHONPATH. Folks in my team are used to using pip editable installs which do not require modifying PYTHONPATH.