Skip to content

Fix PBS encodings error by making pyvenv.cfg home absolute at runtime#1073

Draft
xangcastle wants to merge 1 commit into
mainfrom
xangcastle/fix-pyvenv-absolute-home
Draft

Fix PBS encodings error by making pyvenv.cfg home absolute at runtime#1073
xangcastle wants to merge 1 commit into
mainfrom
xangcastle/fix-pyvenv-absolute-home

Conversation

@xangcastle

@xangcastle xangcastle commented Jun 2, 2026

Copy link
Copy Markdown
Member

PBS encodings fix

Python 3.11/3.12 PBS reimplemented prefix discovery in getpath.py. Its resolvedpath() fails on multi-hop relative symlinks that traverse components across runfiles boundaries. When resolution fails Python falls back to the /install compile-time prefix.

The launcher workaround (exporting PYTHONHOME) doesn't help when nvoked through a venv symlink with -I, because getpath.py reads the venv's pyvenv.cfg first and ignores PYTHONHOME when the relative home = be resolved.

Fix: rewrite pyvenv.cfg at runtime with an absolute home= path so getpath.py discovers the stdlib without following symlinks.

Dep group fallback fix:
Packages with a single available dep_group or single cfg previously required an explicit dep_group attribute, even though there was no ambiguity. Add //conditions:default fallbacks in uv_hub/repository.bzl and uv_project/repository.bzl so these packages resolve automatically.

Changes are visible to end-users: yes/no

  • Searched for relevant documentation and updated as needed: yes/no
  • Breaking change (forces users to change their own code or config): yes/no
  • Suggested release notes appear below: no

Test plan

  • Covered by existing test cases
  • New test cases added
  • Manual testing; please provide instructions so we can reproduce:

@aspect-workflows

aspect-workflows Bot commented Jun 2, 2026

Copy link
Copy Markdown

✨ Aspect Workflows Tasks

📅 Tue Jun 2 13:31:56 UTC 2026

❌ 3 failed tasks

  • ❌ buildifier · ⏱ 32.9s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in diff · Format failed (2 files need format)
  • ❌ test (test-e2e-bazel-8) · ⏱ 33.4s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed
  • ❌ test (test-e2e-bazel-9) · ⏱ 35.3s · 🐙 GitHub Actions · ☑️ Check
    💬 failed in test · Bazel test failed

✅ 4 successful tasks

  • ✅ gazelle · ⏱ 23.2s · 🐙 GitHub Actions · ☑️ Check
    💬 Gazelle complete (clean)
  • ✅ test (test-examples-uv_pip_compile-bazel-8) · ⏱ 20.8s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (1/1 passed · 1 cached)
  • ✅ test (test-root-bazel-8) · ⏱ 1m 53s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (185/185 passed)
  • ✅ test (test-root-bazel-9) · ⏱ 2m 23s · 🐙 GitHub Actions · ☑️ Check
    💬 Bazel test complete (184/184 passed)

🛠️ Fix

❌ buildifier (buildifier)

aspect buildifier --severity=info -- \
  e2e/snapshots/pypi_single.defs.bzl \
  uv/private/uv_hub/snapshots/pypi.defs.bzl
# without Aspect CLI
bazel run --run_in_cwd @buildifier_prebuilt//buildifier -- \
  e2e/snapshots/pypi_single.defs.bzl \
  uv/private/uv_hub/snapshots/pypi.defs.bzl

Install aspect: docs.aspect.build/cli/install

🔁 Reproduce

❌ buildifier (buildifier)

aspect buildifier --severity=fail --base-ref=origin/main

❌ test (test-e2e-bazel-8 · test-e2e-bazel-9)

aspect test -- //...
# without Aspect CLI
bazel test -- //...

Install aspect: docs.aspect.build/cli/install


⏱ Last updated Tue Jun 2 13:34:31 UTC 2026 · 📊 GitHub API quota 9/15,000 (0% used, resets in 57m)
🚀 Powered by Aspect CLI (v2026.22.39)  |  Aspect Build · X · LinkedIn · YouTube

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

py_binary startup benchmark

Version Mean (ms) Median (ms) ± stddev vs BCR vs main Build (s)
BCR 1.11.5 (baseline) 328.836 327.025 ±6.724 39.59
HEAD main 135.083 134.957 ±0.848 -58.9% 11.76
This PR 147.132 146.281 ±5.537 -55.3% +8.9% 10.47

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.5 (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.

@xangcastle xangcastle force-pushed the xangcastle/fix-pyvenv-absolute-home branch from dd75249 to 78777fc Compare June 2, 2026 13:31
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.

1 participant