我想调试一个Python文件,该文件具有一些依赖性,这些依赖性仅出现在bazel的runfiles
中。如何使用vscode调试器调试bazel版本?
答案 0 :(得分:3)
正如某位名人所说:“是的,我们可以。”
您需要使用“ ptvsd” python软件包。
launch.json
文件中,添加以下配置:{
"name": "Python: Attach",
"type": "python",
"request": "attach",
"port": 5724,
"host": "localhost"
},
要调试特定文件时:
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
)随意更改端口,在此示例中为5724。