I want to debug a python file which has a few dependencies that only appear in the runfiles
from bazel. How can I debug a bazel build with the vscode debugger?
As someone famous said, "Yes, we can".
You would need to use the "ptvsd" python package.
launch.json
file, add the following configuration:{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"port": 5724,
"host": "localhost"
},
When you want to debug a specific file:
import ptvsd
ptvsd.enable_attach(address=('localhost', 5724), redirect_output=True)
print('Now is a good time to attach your debugger: Run: Python: Attach')
ptvsd.wait_for_attach()
bazel run :server
for instance)Feel free to change the port, 5724 in this example.