Skip to content

fix(py): Resolve Java toolchain paths before the PEP 517 backend chdirs into the sdist#1295

Merged
xangcastle merged 3 commits into
mainfrom
fix/pep517-whl-java-tool-paths-rbe
Jul 14, 2026
Merged

fix(py): Resolve Java toolchain paths before the PEP 517 backend chdirs into the sdist#1295
xangcastle merged 3 commits into
mainfrom
fix/pep517-whl-java-tool-paths-rbe

Conversation

@xangcastle

@xangcastle xangcastle commented Jul 13, 2026

Copy link
Copy Markdown
Member

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_path for 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

  • Covered by existing test cases

tamird and others added 2 commits July 13, 2026 16:26
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

aspect-workflows Bot commented Jul 13, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Tue Jul 14 00:11:03 UTC 2026

✅ 36 successful tasks

  • ✅ buildifier · ⏱ 22.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Format complete (clean)
  • ✅ gazelle · ⏱ 18.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Gazelle complete (clean)
  • ✅ test-e2e-bazel-8 [test] · ⏱ 2m 55s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (195/195 passed)
  • ✅ test-e2e-bazel-9 [test] · ⏱ 3m 39s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (189/189 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-8 [test] · ⏱ 20.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-input-validation-bazel-9 [test] · ⏱ 36.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-8 [test] · ⏱ 25.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-e2e-interpreter-runtime-metadata-bazel-9 [test] · ⏱ 38.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-8 [test] · ⏱ 17.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-interpreter-toolchain-settings-bazel-9 [test] · ⏱ 1m 27s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-8 [test] · ⏱ 1m 53s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-e2e-rules-proto-grpc-python-bazel-9 [test] · ⏱ 1m 26s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-debugger-bazel-8 [test] · ⏱ 28.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-debugger-bazel-9 [test] · ⏱ 45.4s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-8 [test] · ⏱ 37.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-dev_deps-bazel-9 [test] · ⏱ 56.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-django-bazel-8 [test] · ⏱ 21.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-django-bazel-9 [test] · ⏱ 46s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-multi_version-bazel-8 [test] · ⏱ 31.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-multi_version-bazel-9 [test] · ⏱ 49.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (2/2 passed)
  • ✅ test-examples-protobuf-bazel-8 [test] · ⏱ 1m 32s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-protobuf-bazel-9 [test] · ⏱ 1m 58s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_binary-bazel-8 [test] · ⏱ 24.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_binary-bazel-9 [test] · ⏱ 54.9s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_pex_binary-bazel-8 [test] · ⏱ 18.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test-examples-py_pex_binary-bazel-9 [test] · ⏱ 32.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-py_venv-bazel-8 [test] · ⏱ 29.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed)
  • ✅ test-examples-py_venv-bazel-9 [test] · ⏱ 41.1s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (3/3 passed)
  • ✅ test-examples-pytest-bazel-8 [test] · ⏱ 52.7s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (9/9 passed)
  • ✅ test-examples-pytest-bazel-9 [test] · ⏱ 1m 32s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (9/9 passed)
  • ✅ test-examples-uv_pip_compile-bazel-8 [test] · ⏱ 23.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-uv_pip_compile-bazel-9 [test] · ⏱ 36.6s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-8 [test] · ⏱ 20.5s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-examples-virtual_deps-bazel-9 [test] · ⏱ 1m 3s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed)
  • ✅ test-root-bazel-8 [test] · ⏱ 2m 50s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (235/235 passed)
  • ✅ test-root-bazel-9 [test] · ⏱ 2m 51s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (234/234 passed)

⏱ Last updated Tue Jul 14 00:15:53 UTC 2026 · 📊 GitHub API quota 531/15,000 (4% used, resets in 47m)
🚀 Powered by Aspect CLI (v2026.28.2)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.7 (baseline) 191.193 190.376 ±8.799 41.86
HEAD main 60.606 60.319 ±1.300 -68.3% 9.69
This PR 61.617 60.502 ±4.303 -67.8% +1.7% 7.07

Measured with hyperfine --warmup 5 --runs 50 on Linux
Gate: PR vs HEAD main (threshold: 10%). BCR is shown only as a historical baseline.
Build time: cold bazel build //:bench with isolated output base, no disk cache.

sys.path quality

Version sys.path entries distinct site-packages roots duplicate realpaths
BCR 1.11.7 (baseline) 6 1 0
HEAD main 7 2 0
This PR 7 2 0

sys.path quality measured by bench_syspath inside the assembled venv. Duplicate realpaths indicate symlink redundancy; many distinct site-packages roots suggest an inefficient venv layout.

Bazel analysis benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Packages Targets
BCR 2.0.0-alpha.4 (baseline) 9973.724 9944.834 ±138.756 101 301
HEAD main 9220.640 9216.351 ±134.204 -7.6% 101 301
This PR 9199.167 9193.304 ±107.644 -7.8% -0.2% 101 301

Measured with hyperfine --warmup 1 --runs 10 on Linux
Gate: PR vs HEAD main (threshold: 10%). BCR is shown only as a historical baseline.
Command: cold bazel build --nobuild //workspace/... with isolated output base, no disk cache.

Auxiliary metrics

Version Loaded packages Configured targets
BCR 2.0.0-alpha.4 (baseline) 101 301
HEAD main 101 301
This PR 101 301

@tamird tamird left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread uv/private/pep517_whl/tests/python_env_backend/backend.py Outdated
_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.
@xangcastle
xangcastle force-pushed the fix/pep517-whl-java-tool-paths-rbe branch from b74bf66 to a00a701 Compare July 14, 2026 00:10
@xangcastle
xangcastle requested review from acozzette and jbedard July 14, 2026 00:12
@xangcastle xangcastle changed the title Fix/pep517 whl java tool paths rbe fix(py): Resolve Java toolchain paths before the PEP 517 backend chdirs into the sdist Jul 14, 2026
@xangcastle
xangcastle requested a review from tamird July 14, 2026 00:30
@xangcastle
xangcastle marked this pull request as ready for review July 14, 2026 00:32

@tamird tamird left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the cumulative diff at a00a701. The JAR assertion is gone; JAVA_HOME/JAVA still exercise the backend cwd change, and the shared helper preserves the existing CC/CXX behavior. Clean.

@xangcastle
xangcastle enabled auto-merge (squash) July 14, 2026 00:50
@xangcastle
xangcastle merged commit 9edd473 into main Jul 14, 2026
80 of 82 checks passed
@xangcastle
xangcastle deleted the fix/pep517-whl-java-tool-paths-rbe branch July 14, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants