You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This way doesn't work for us in our monorepo setting for couple of reasons:
We use custom pytest_runner
We have our own VSCode extension which uses bazel to run tests and debug in TestExplorer and other things and we would prefer to keep interaction with tests and codebase through bazel, not via python interpreter from rules_py venv
It creates one extra step for our user to be able to interact with IDE, comparing with current setup
What is the current behavior?
Currently bootstrap script doesn't allow to pass custom interpreter flags to Python interpreter:
https://github.com/aspect-build/rules_py/blob/main/py/private/run.tmpl.sh#L61
Two flags are added by rules_py implementation (https://github.com/aspect-build/rules_py/blob/main/py/private/py_semantics.bzl#L6-L14), but I didn't find an option to add more flags defined by user to interpreter
args argument for py_binary target allows to pass custom arguments to invoked script, but not to interpreter itself.
Describe the feature
I would like to have ability to pass custom user flags to Python interpreter used by rules_py.
Main motivation for it to allow to run py_binary targets under debugpy debugger via bazel.
Instead of having following line in bootstrap file
exec "{{EXEC_PYTHON_BIN}}" {{INTERPRETER_FLAGS}} "$(rlocation {{ENTRYPOINT}})" "$@"
I want to have something like
+exec "{{EXEC_PYTHON_BIN}}" {{INTERPRETER_FLAGS}} $RULES_PY_USER_INTERPRETER_FLAGS "$(rlocation {{ENTRYPOINT}})" "$@"
Example usage will be:
RULES_PY_USER_INTERPRETER_FLAGS="-m debugpy --listen 12345 --wait-for-client" bazel run //path/to/rules_py/py_binary/target
I've seen and tried proposed way to debug via creating venv from bazelbuild/rules_python#1401 (comment)
This way doesn't work for us in our monorepo setting for couple of reasons:
Similar feature request from bazel slack:
https://bazelbuild.slack.com/archives/CA31HN1T3/p1730573900089359
Another alternative I was thinking is to use run_under flag (https://bazel.build/reference/command-line-reference#flag--run_under), but it seems to be not feasible for debugpy use case, as bootstrap script is shell and not Python.
If there is a way to specify custom toolchain for this use case I am happy to learn how to do it as well!
Thanks!
The text was updated successfully, but these errors were encountered: