You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent stdlib pyc files from invalidating runtime repos (bazel-contrib#3661)
The runtime repositories are being constantly invalidated due to pyc
creation under Bazel 9
because, starting in Bazel 9, `glob()` functions implicitly register
`repository_ctx.watch()`
calls on the files and directories they match. Thus, the directories
where `__pycache__`
directories are created end up being considered changed (either directly
because their
mtimes change, or indirectly, because their directory listing changes),
which then invalidates
the repo, causing it to re-run.
This glob-induced-watching seems to occur even if an `exclude` would
have excluded the file.
Note that this only seems to occur if `reproducible=False`, which
generally wouldn't occur,
but could occur if a user is registering their own runtime and doesn't
care about the sha.
Regardless, this still seems worthwhile because it allows pyc to be more
safely be
generated without causing repo invalidations, while allowing them to be
persisted between
repo-phase invocations.
To fix, create `__pycache__` directories ahead of time and symlink them
to a location that Bazel
isn't watching, i.e. outside the repository's directory. I tried
creating a separate top-level
folder that wasn't matched by any globs and symlinking to it, but Bazel
would read through
the symlinks and watch the underlying locations.
This also has a side-bonus that allows pyc files to be re-used in
between
repository-phase invocations.
Fixesbazel-contrib#3643
0 commit comments