Repository navigation
Conversation
With `--experimental_remote_repo_contents_cache`, a module extension or repository rule that reads a Label makes Bazel copy that whole repo to disk. The `python` extension and the `pythons_hub` repo read `runtimes_manifest.txt` this way, so every build materializes rules_python. This loads the same text from `runtimes_manifest_workspace.bzl` (`MANIFEST_TEXT`), which `runtimes_manifest_workspace_sync_test` already keeps identical to the `.txt`. The archive-flavor test passes its manifest through a new testing-only `_default_runtime_manifest` argument, and the now-unused default manifest mock is removed.
|
Hm, interesting, and a bit confusing. (1) How can the rules_python bzlmod extension be processed if rules_python isn't available? (2) Does this effectively mean bzlmod extensions can't read any files without incurring a download of an entire repository? |
|
(1) Bazel has a virtual file system that will download the remote files on demand when loading bzl files. All the starlark can work without materializing the whole thing. This is a decent change on its own merits, but we can close in favor of a ctx.read(label) change later after my Bazel PR merges if you prefer. |
|
I brought this up in #bzlmod on bazel slack: https://bazelbuild.slack.com/archives/C014RARENH0/p1792553506777879 It turns out bazel will prefetch all Does changing If not, then: (1) Whats the minimum version of bazel to get the above behavior? Basically we're going to drop bazel 7 support when bazel 10 comes out, so I'd rather not add it just for bazel 7. (2) Some variant of this PR SGTM. In that case, the main change in this PR to make is removing the dead code and renaming as appropriate -- runtimes_manifest.txt essentially becomes unused, and runtimes_manifest_workspace.bzl becomes a misnomer. But either way, there's no avoiding the fetch of the content: either bazel prefetches it due to the .bzl extension, or it gets fetched later when read() is called. |
I checked, it doesn't. There's a pending PR in bazel to allow that, but not in current versions. Ah well. Yeah, lets move it all to the .bzl file as a string for now, then. |
Now that both Bzlmod and WORKSPACE mode load `MANIFEST_TEXT` from Starlark instead of reading `runtimes_manifest.txt`, keeping both files and a sync script is redundant. Replace `runtimes_manifest.txt` and `runtimes_manifest_workspace.bzl` with `runtimes_manifest.bzl`, remove `sync_runtimes_manifest_workspace.py`, and update `sort_manifest.py` to sort `runtimes_manifest.bzl` in place.
With
--experimental_remote_repo_contents_cache, a module extension orrepository rule that reads a Label makes Bazel copy that whole repo to
disk. The
pythonextension and thepythons_hubrepo readruntimes_manifest.txtthis way, so every build materializesrules_python.
This replaces
runtimes_manifest.txtandruntimes_manifest_workspace.bzlwith a singleruntimes_manifest.bzl(
MANIFEST_TEXT) loaded directly by both Bzlmod and WORKSPACE mode, andupdates
sort_manifest.pyto sortruntimes_manifest.bzlin place.Before:
DEBUG: Materializing remote repo @@rules_python+on everybuild. After: no materialization; the same 741
@pythons_hubtargetsand an identical
versions.bzl. Tested with Bazel 10.0.0rc1 and aremote cache, querying
@pythons_hub//:allfrom a fresh output baseafter a warm-up run.
Tests: the mock
module_ctxcan't read real files, which is why theextension tests had a fake default manifest. Since the manifest is now
loaded rather than read, they use the real one, and the fake is removed.
The archive-flavor test passes its own manifest through a new
testing-only
_default_runtime_manifestargument.