fix(precompile): skip precompilation for directory and pyc inputs in srcs - #4113
Open
rickeylev wants to merge 12 commits into
Open
fix(precompile): skip precompilation for directory and pyc inputs in srcs#4113rickeylev wants to merge 12 commits into
rickeylev wants to merge 12 commits into
Conversation
Add analysis and execution tests verifying precompiling behavior when directory or pyc file inputs are passed in target srcs.
Directories and precompiled pyc files cannot be compiled directly into pyc files. Skip precompiling when src.is_directory is true or the extension is pyc/pyo while retaining them in target outputs.
… srcs Allow arbitrary files in the srcs attribute while filtering to Python source files via an is_py_source helper. Skip precompilation for directories or any file that is not a Python source file, and remove legacy py3 extension references.
…mat srcs doc Propagate input .pyc files through precompilation into target default outputs, and format the srcs attribute docstring with a list of allowed file types.
…ies to maybe_precompile Compute direct_sources as the py, pyc, and directory files from srcs, pass direct_sources to maybe_precompile, and update tree artifact analysis test outputs.
…ecompile doc Factor out filter_to_direct_sources helper in common.bzl to share direct sources filtering across py_library and py_executable, and update _precompile return type docstring.
…bzl_library dep Add news fragment for skip precompile src errors fix, document allowed srcs file types with versionchanged in attributes.bzl, and add :common dependency to precompile bzl_library.
Associate news entry with newly created PR bazel-contrib#4113.
…ctive Update version directive in attributes.bzl from VERSION_NEXT_FEATURE to VERSION_NEXT_PATCH.
…ntry
Update news/4113.fixed.md to use valid Sphinx MyST {obj} syntax, wrap lines within 80 columns, and link to PR bazel-contrib#4113.
rickeylev
marked this pull request as ready for review
August 25, 2026 07:43
aignas
reviewed
Aug 26, 2026
| ], | ||
| ) | ||
| srcs_attr = builder.attrs.get("srcs") | ||
| srcs_attr.set_allow_files(True) |
| srcs_attr.set_allow_files(True) | ||
| srcs_attr.set_doc(srcs_attr.doc() + """ | ||
|
|
||
| :::{versionchanged} 2.3.2 |
Collaborator
There was a problem hiding this comment.
Should this be also consolidated in the common.bzl?
aignas
approved these changes
Aug 26, 2026
aignas
left a comment
Collaborator
There was a problem hiding this comment.
Pending the comments, LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Precompiling
py_library,py_binary, orpy_testtargets fails whensrcscontains directory artifacts or.pycfiles. The precompilerdeclares invalid actions on directories and drops non-
.pysources fromdefault outputs.
This change:
.pycfiles, anddirectories.
retaining them in default outputs.
srcsvalidation and documentation.