Skip to content

fix: Local Toolchain on Windows: local_runtime_repo generates interpreter_path without escaping backward slashes #3055

@albertocavalcante

Description

@albertocavalcante

🐞 bug report

Affected Rule

python/private/local_runtime_repo.bzl

Is this a regression?

No

Description

When using a local toolchain on Windows as per https://rules-python.readthedocs.io/en/latest/toolchains.html#local-toolchain,
the define_local_runtime_toolchain.impl.interpreter_path is not escaping the backward slashes, making bazel fail with invalid escape sequence.

If I set:

local_runtime_repo(
    name = "local_python3",
    on_failure = "fail",
    interpreter_path = "python"
    # or interpreter_path = "C:\\path\\to\\python.exe"
)

I get a

# Generated by python/private/local_runtime_repo.bzl

load()

define_local_runtime_toolchain_impl(
    interpreter_path = "C:\path\to\python.exe" # expected: either "\\" or "/"
)

🔬 Minimal Reproduction

TODO

🔥 Exception or Error

TODO

🌍 Your Environment

Operating System:

  
Windows
  

Output of bazel version:

  
8.2.1
  

Rules_python version:

  
1.5.0
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugtype: toolchainRelated to the toolchains provided by rules_python

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions