Skip to content

Commit a5bed43

Browse files
committed
local toolchain fix
1 parent 1cb11c0 commit a5bed43

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

python/private/get_local_runtime_info.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"micro": sys.version_info.micro,
2323
"include": sysconfig.get_path("include"),
2424
"implementation_name": sys.implementation.name,
25+
"base_executable": sys._base_executable,
2526
}
2627

2728
config_vars = [

python/private/local_runtime_repo.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ def _local_runtime_repo_impl(rctx):
8484
info = json.decode(exec_result.stdout)
8585
logger.info(lambda: _format_get_info_result(info))
8686

87+
# The base executable is the final, actual, underlying interpreter.
88+
# If an intermediate wrapper is used, then it can cause venvs to not
89+
# be recognized as active.
90+
interpreter_path = info["base_executable"]
91+
print("===", interpreter_path)
92+
8793
# NOTE: Keep in sync with recursive glob in define_local_runtime_toolchain_impl
8894
repo_utils.watch_tree(rctx, rctx.path(info["include"]))
8995

tests/integration/local_toolchains/test.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,13 @@ def test_python_from_path_used(self):
1515
# The shim is e.g. /home/user/.pyenv/shims/python3, which then
1616
# runs e.g. /usr/bin/python3
1717
expected = subprocess.check_output(
18-
[shell_path, "-c", "import os, sys; print(os.path.realpath(sys._base_executable))"],
18+
[shell_path, "-c", "import os, sys; print(sys._base_executable)"],
1919
text=True,
2020
)
2121
expected = expected.strip().lower()
2222

23-
msg = "\n".join([
24-
"other values:",
25-
f"{shell_path=}",
26-
f"{sys.executable=}",
27-
f"{sys._base_executable=}",
28-
])
2923
# Normalize case: Windows may have case differences
30-
self.assertEqual(expected.lower(), sys._base_executable.lower(),
31-
msg = msg)
24+
self.assertEqual(expected.lower(), sys._base_executable.lower())
3225

3326

3427
if __name__ == "__main__":

0 commit comments

Comments
 (0)