refactor: separate Python sources from library runfiles - #1419
Conversation
✨ Aspect Workflows Tasks📅 Wed Aug 12 07:03:39 UTC 2026 ✅ 42 successful tasks
⏱ Last updated Wed Aug 12 07:10:30 UTC 2026 · 📊 GitHub API quota 1,449/15,000 (10% used, resets in 22m) |
py_binary startup benchmark
sys.path quality
Bazel analysis benchmark
|
9da2063 to
a351428
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3514283c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Robot summary, locations where .py files live:
Remaining .py files are intentional:
|
acd7873 to
621cfe7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 621cfe75aa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
621cfe7 to
0d74eb3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d74eb35db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| extra_depsets = [ | ||
| py_toolchain.files, | ||
| srcs_depset, | ||
| ] + virtual_resolution.srcs + virtual_resolution.runfiles, | ||
| ] + virtual_resolution.runfiles, |
There was a problem hiding this comment.
Preserve data dependency sources in runnable venvs
When a standalone py_venv has data = [":plugin"] and that py_library depends on another Python library, ctx.files.data contributes only the plugin's direct source while the newly source-free library runfiles no longer contribute the helper source. The later include_sources = True merge restores only the venv's own srcs/deps closure, so bazel run :venv fails when the plugin imports its helper even though the data contract promises the transitive runtime closure; include Python sources reached through data when constructing the runnable venv.
Useful? React with 👍 / 👎.
| data_sources = [ | ||
| get_py_info(target).transitive_sources | ||
| for target in ctx.attr.data | ||
| if has_py_info(target) |
There was a problem hiding this comment.
Traverse nested Python data edges when restoring sources
This recovery only reads PyInfo from each direct terminal data target, but PyInfo.transitive_sources follows deps, not that target's own data edges. For example, with py_binary(data = [":wrapper"]), wrapper.data = [":plugin"], and plugin.deps = [":helper"], the wrapper's runfiles retain plugin.py through ctx.files.data but lose helper.py because the plugin and helper now have source-free default runfiles; importing the plugin therefore fails. Preserve the source closure across nested data edges rather than restoring only direct data targets' PyInfo.
Useful? React with 👍 / 👎.
0d74eb3 to
085394e
Compare
Avoid adding
.pyfiles toDefaultInfo.default_runfilesuntil absolutely necessary in terminal runnable rules such aspy_venv_exec[_test](whichpy_binary|testwrap).This reduces confusion about providers vs runfiles.
This way the
.pycan more easily be swapped out for.pycfiles in the future.Changes are visible to end-users: no
Test plan