forked from bazelbuild/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(precompiling)!: make binary-level precompile opt-in/opt-opt work (b…
…azelbuild#2243) This makes binary-level opt-in/opt-out of precompiling work as intended. Previously, when `pyc_collection=include_pyc` was set on a binary, only transitive libraries that had explicitly enabled precompiling were being included (which was moot anyways -- libraries put their files in runfiles, so no matter what, their files were included). The intent was that, when a binary set `pyc_collection=include_pyc`, then precompiled files would be used for all its transitive dependencies (unless they had, at the target-level, disabled precompiling). Conversely, if `pyc_collection=disabled` was set, the precompiled files would not be used (unless a target had, at the target level, enabled precompiling). To make it work as desired, the basic fix is to make it so that libraries have a place to put the implicit pyc files (the ones automatically generated), and have the binaries include those when requested. The net effect is a library has 4 sets of files it produces: * required py files: py source files that should always go into the binary's runfiles * required pyc files: precompiled pyc files that should always go into the binary's runfiles (e.g., when a library sets `precompile=enabled` directly). * implicit pyc files: precompiled pyc files for a library that are always generated, but it's up to the binary if they go into the runfiles * implicit pyc source files: the source py file for an implicit pyc file. When a binary *doesn't* include the implicit pyc file, it must include the source py file (otherwise none of the library's code ends up included). Similarly, in order to allow a binary to decide what files are used, libraries must stop putting the py/pyc files into runfiles themselves. While this is potentially a breaking change, I found that, within Google, there was no reliance on this behavior, so should be safe enough. That said, I added `--add_srcs_to_runfiles` to restore the previous behavior to aid in transitioning. **BREAKING CHANGES** 1. `py_library` no longer puts its srcs into runfiles directly. 2. Removed `--precompile_add_to_runfiles` 3. Removed `--pyc_collection` 4. `precompile=if_generated_source` removed 5. `precompile_source_retention=omit_if_generated_source` removed Though 2 through 5 are technically breaking changes, I don't think precompiling was very usable anyways, so usages of those flags/values is rare. Fixes bazelbuild#2212
- Loading branch information
Showing
17 changed files
with
746 additions
and
344 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.