fix(py): Resolve Java toolchain paths before the PEP 517 backend chdirs into the sdist#1295
Conversation
The path.exists guard on JAVA_HOME/JAVA made absolutization a silent no-op whenever the JDK was not observable on the helper's filesystem. The JDK is declared as an action input via _collect_toolchain_inputs_and_vars (DefaultInfo.files, runfiles, and ToolchainInfo.all_files from the toolchains attr), so the binaries are materialized in the sandbox and path.exists can only fail in misconfigured cases — exactly where we want a loud backend failure rather than a silently broken relative env that breaks the build opaquely inside the unpacked sdist. Drop the guard to match _resolve_compiler_path's treatment of CC/CXX, which absolutizes unconditionally and lets the child process surface a clear "java: not found" if the input is genuinely missing.
✨ Aspect Workflows Tasks📅 Tue Jul 14 00:11:03 UTC 2026 ✅ 36 successful tasks
⏱ Last updated Tue Jul 14 00:15:53 UTC 2026 · 📊 GitHub API quota 531/15,000 (4% used, resets in 47m) |
py_binary startup benchmark
sys.path quality
Bazel analysis benchmark
Auxiliary metrics
|
tamird
left a comment
There was a problem hiding this comment.
The JAVA_HOME/JAVA absolutization looks sound, and the shared helper preserves the existing CC/CXX behavior. I found one test issue below. Please also replace the template PR body with the causal summary and test plan before marking this ready.
_resolve_compiler_path (CC/CXX) and _absolutize_java_tool_paths (JAVA_HOME/JAVA) both implemented the same pattern: resolve a workspace-relative toolchain path to absolute, leave absolute values untouched. The policy was duplicated and, worse, had already drifted — the Java path grew a path.exists guard that the CC path never had, which is exactly how the previous bug slipped in. Hoist the shared operation into _absolutize_path(value) and have both callers consume it. Behavior-equivalent: parts[0] from shlex.split is always truthy so _resolve_compiler_path returns identical values, and _absolutize_java_tool_paths now rewrites absolute values in-place to themselves (no observable change). The intent — that both toolchains follow the same absolutization policy — now lives in one place, which matters as more toolchains (FC, RUSTC, ...) are wired into the rule.
b74bf66 to
a00a701
Compare
Bazel expands
$(JAVA)and$(JAVABASE)as workspace-relative paths, but the PEP 517 backend chdirs into the unpacked sdist before building; leaving JAVA_HOME/JAVA pointing at locations that no longer resolve.The build helper now resolves them to absolute while it still runs from the action execroot, mirroring
_resolve_compiler_pathfor CC/CXX. The initial path.exists guard is dropped (the JDK is a declared action input, so a missing path should fail loudly rather than silently ship a broken env); the shared absolutization is extracted into _absolutize_path so the two toolchain paths can't drift again.Changes are visible to end-users: no
Test plan