Skip to content

refactor(toolchain): replace resolved_venv_toolchain with venv_exec_toolchain_type#911

Merged
gregmagolan merged 12 commits intomainfrom
cleanup_venv_toolchain
Apr 6, 2026
Merged

refactor(toolchain): replace resolved_venv_toolchain with venv_exec_toolchain_type#911
gregmagolan merged 12 commits intomainfrom
cleanup_venv_toolchain

Conversation

@gregmagolan
Copy link
Copy Markdown
Member

@gregmagolan gregmagolan commented Apr 5, 2026

Summary

resolved_venv_toolchain was a workaround: a regular dep with cfg = "exec" used to pull the venv binary into exec config for the build action in py_venv.bzl. This PR replaces it with a proper toolchain type, and takes the opportunity to clean up the overall toolchain design.

Changes

PrebuiltToolConfig redesigncfg is now mandatory and accepts "target", "exec", or "both". Tools with cfg = "both" (like venv) register under two toolchain types from a single downloaded binary: target_compatible_with for runfiles (runs on the user's machine) and exec_compatible_with for build actions (runs on the exec host). The struct exposes toolchain_type and exec_toolchain_type fields derived from cfg; callers no longer pass types explicitly.

TOOL_CFGS simplifiedvenv_exec entry removed; venv now carries cfg = "both". The separate py/private/toolchain/venv_exec/ directory is gone.

source_toolchain simplified — takes only name and bin; derives everything else from TOOL_CFGS. Creates {name}_tool / {name}_source_toolchain for target-cfg tools and {name}_exec_tool / {name}_exec_source_toolchain for exec-cfg tools.

Toolchain type renames for consistency:

  • unpack_toolchain_typeunpack_exec_toolchain_type
  • target_exec_toolchain_typenative_build_toolchain_type (self-documenting: forces exec platform to match target for native wheel builds)
  • TARGET_EXEC_TOOLCHAINNATIVE_BUILD_TOOLCHAIN

NewVENV_EXEC_TOOLCHAIN constant and venv_exec_toolchain_type toolchain type for the exec-cfg venv binary used by py_venv build actions.

py_venv.bzl — replaces ctx.attr._venv (private dep with cfg = "exec") with ctx.toolchains[VENV_EXEC_TOOLCHAIN]. Removes resolved_venv_toolchain rule and target entirely.

repo.bzl_toolchains_repo_impl emits target_compatible_with or exec_compatible_with toolchain declarations based on which types are present, with no string-interpolated cfg values. _prebuilt_tool_repo_impl downloads once per tool regardless of how many toolchain types it serves.

@aspect-workflows
Copy link
Copy Markdown

aspect-workflows Bot commented Apr 5, 2026

Bazel 8 (Test)

All tests were cache hits

111 tests (100.0%) were fully cached saving 53s.


Bazel 9 (Test)

All tests were cache hits

111 tests (100.0%) were fully cached saving 1m 20s.


Bazel 8 (Test)

e2e

All tests were cache hits

51 tests (100.0%) were fully cached saving 55s.


Bazel 9 (Test)

e2e

All tests were cache hits

51 tests (100.0%) were fully cached saving 43s.


Bazel 8 (Test)

examples/uv_pip_compile

All tests were cache hits

1 test (100.0%) was fully cached saving 444ms.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 5, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread py/private/py_venv/py_venv.bzl Outdated
Comment thread py/private/toolchain/tools.bzl Outdated
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from 55d2c29 to 1286ed6 Compare April 5, 2026 22:05
…oolchain_type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from e40a2ec to 675e6f5 Compare April 5, 2026 22:46
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from 656eb9f to 2747426 Compare April 5, 2026 22:50
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from 495f3de to 70e3062 Compare April 5, 2026 23:05
aspect-marvin and others added 2 commits April 5, 2026 23:06
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from 6e4e7d5 to 895ddd6 Compare April 6, 2026 02:33
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from a6406f6 to 1450218 Compare April 6, 2026 02:56
@gregmagolan gregmagolan force-pushed the cleanup_venv_toolchain branch from 10dd601 to 4b325ba Compare April 6, 2026 03:11
@gregmagolan gregmagolan merged commit 396cee6 into main Apr 6, 2026
1 of 2 checks passed
@gregmagolan gregmagolan deleted the cleanup_venv_toolchain branch April 6, 2026 03:20
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.

4 participants