- Install vscode recommended extensions:
Cmd + P->Show recommended extensions - Select the target
Bazel: run py runorBazel: test py testin vscode. Only a python interpreter is needed so vscode can startup with (system install works).- py run: for tests and binaries. No sandboxing. You can type
//:appor//:app_testin the input field. - py tests: for tests only. With sandboxing. You can type
//:app_testin the input field.
- py run: for tests and binaries. No sandboxing. You can type
- See breakpoints working in both main process (
mattress) and subprocess (mattress/command.py).
flowchart TD
vscode["vscode (debugpy client)"]-->|configured in launch.json| launch_py["launch.py"]
launch_py-->|"set RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS <br> based on pydev_monkey.patch_args()"| bazel["bazel run/test"]
bazel --> py_binary["py_binary / py_test"]
py_binary --> |"debugpy attach via patched entrypoint through RULES_PYTHON_ADDITIONAL_INTERPRETER_ARGS"| vscode
py_binary --> |subprocess launch| subprocess
subprocess --> |"debugpy attach via patched entrypoint through pdevd usual patching"| vscode
In addition we pass down PYDEVD_RESOLVE_SYMLINKS to each process to make sure that the debugger hits breakpoints in original source and not the symlinks in bazel output.
In launch.json on can further set or unset IDE_PROJECT_ROOTS in lieu of justMyCode.
