Skip to content

Windows py_test launcher cannot find bootstrap stub when target name contains slashesΒ #3789

@titusfortner

Description

@titusfortner

🐞 bug report

Affected Rule

py_test / py_binary

Is this a regression?

Yes β€” v1 (which delegated to Bazel's native Python rules); this is part of our Selenium update to v2 (SeleniumHQ/selenium#17502)

Description

On Windows, the bootstrap stub is declared at python/private/py_executable.bzl:427 using executable.basename, which drops the directory component. The stub is therefore created relative to the package root rather than as a sibling of the .exe launcher. When a target name contains / (so Bazel writes the .exe into a nested output directory), the launcher cannot find the stub next to itself and execution fails.

πŸ”¬ Minimal Reproduction

A py_test whose name attribute contains /, e.g.:

  py_test(
      name = "test/unit/foo/color_tests-unit",
      srcs = ["color_tests.py"],
  )

Build on Windows and inspect the action output paths:
stub: bazel-out/x64_windows-fastbuild/bin/pkg/color_tests-unit
executable: bazel-out/x64_windows-fastbuild/bin/pkg/test/unit/foo/color_tests-unit.exe

πŸ”₯ Exception or Error


[Errno 2] No such file or directory

🌍 Your Environment

Operating System:

  
Microsoft Windows Server 2025
  

Output of bazel version:

  
9.1.0
  

Rules_python version:

  
2.0.1
  

Anything else relevant?
PR incoming

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions