The Goal
I want to configure rules_ml_toolchain in a pure bzlmod project so I started to write an overlay to declare it as publishable module.
The Problem: "Generate-then-Load" Pattern
The current setup process is incompatible with a pure bzlmod workflow due to its reliance on a "generate-then-load" pattern. The setup requires a sequence of operations that cannot be expressed declaratively in MODULE.bazel.
For example, the CUDA setup follows these steps:
- Generate: The
cuda_json_init_repository rule is called. It runs during the Analysis Phase and generates a new repository (@cuda_redist_json) containing a distributions.bzl file.
- Load: The script must then execute
load("@cuda_redist_json//:distributions.bzl", "CUDA_REDISTRIBUTIONS") to get a variable from the file that was just created.
- Consume: This variable is then passed to another repository rule,
cuda_redist_init_repositories.
This creates a fundamental conflict with Bazel's architecture:
- All
load() statements are processed during the Loading Phase.
- Repository rules are executed later, during the Analysis Phase.
A pure MODULE.bazel setup cannot load() a file that will only be created in a future phase. This forces users to adopt the WORKSPACE.bzlmod file, which prevents a fully modern and clean Bazel setup.
Thank you for considering this enhancement.
The Goal
I want to configure
rules_ml_toolchainin a pure bzlmod project so I started to write an overlay to declare it as publishable module.The Problem: "Generate-then-Load" Pattern
The current setup process is incompatible with a pure bzlmod workflow due to its reliance on a "generate-then-load" pattern. The setup requires a sequence of operations that cannot be expressed declaratively in
MODULE.bazel.For example, the CUDA setup follows these steps:
cuda_json_init_repositoryrule is called. It runs during the Analysis Phase and generates a new repository (@cuda_redist_json) containing adistributions.bzlfile.load("@cuda_redist_json//:distributions.bzl", "CUDA_REDISTRIBUTIONS")to get a variable from the file that was just created.cuda_redist_init_repositories.This creates a fundamental conflict with Bazel's architecture:
load()statements are processed during the Loading Phase.A pure
MODULE.bazelsetup cannotload()a file that will only be created in a future phase. This forces users to adopt theWORKSPACE.bzlmodfile, which prevents a fully modern and clean Bazel setup.Thank you for considering this enhancement.