New --debugger flag does not propagate `imports=...` or `venv_site_packages`

🐞 bug report

py_binary, py_test

a94bd0f recently added support for injecting dependencies for easier use of debugger. It allows injecting deps via

--@rules_python//python/config_settings:debugger=<target>

Is this a regression?

Not exactly as it is a new feature right off the press.

Description

I tried this feature for starting targets in vscode. I do this via this strategy

  • Create a target name //debugpy that has
# BUILD file
py_library(
    name = "debugpy",
    # Rough sitecustomize content
    #
    # Detect a env var named bzl_debugpy_config that has the debugpy
    # port, and connect secret. If found use it to connect. This will both make
    # the process show up in vscode debugger, and patches os. process creation
    # files so new subprocesses also connect.
   srcs = ["sitecustomize.py"],
   imports = ["."],
    visibility = ["//:__subpackages__"],
)
  • Then in vscode I start a python target with a script launch.py that
    • imports debugpy, finds the port and secret
    • Adds them as env var bzl_debugpy_config json encoded (for tests via --test_env)
    • Runs the target with --@rules_python//python/config_settings:debugger=//:debugpy

The issue I face is when I put my debugpy in a non root folder and add imports = [.] to it, when using rules_python//python/config_settings:debugger this imports don't get propagated to py_binary/test and sitecustomize does not get executed.

Alternatively, I tried using venv_site_packages and a .pth file and faced similar issue.

🔬 Minimal Reproduction

https://github.com/shayanhoshyari/issue-reports/tree/5d47835baf270e96f30cefd5a10843e389cfba7d/rules_python/vscode_debugger

🔥 Exception or Error

Using rules_python//python/config_settings:debugger is not propagating imports or venv_site_packages (while using deps=... does).

# Summary Command The debugger connection hook is on path
1 --debugger + put in root ./bazel run //:app --@rules_python//python/config_settings:debugger=//:debugpy
2 --debugger + put in venv site-packages ./bazel run //:app --@rules_python//python/config_settings:debugger=//debugpy:venv
3 --debugger + use imports ./bazel run //:app --@rules_python//python/config_settings:debugger=//debugpy:imports
4 explicit dep + put in root Add //:debugpy to //:app.deps + ./bazel run //:app
5 explicit dep + put in venv site-packages Add //debugpy:venv to //:app.deps + ./bazel run //:app
6 explicit dep + use imports Add //debugpy:imports to //:app.deps + ./bazel run //:app

🌍 Your Environment

Operating System: Macos 25
Output of bazel version: 8.5
Rules_python version: a94bd0f