Skip to content

Commit cd34111

Browse files
perf(py_wheel): defer depset expansion to execution time (#3599)
This is the `py_wheel` counterpart to the analysis-time performance work done for `py_binary`/`py_test` in #3381 and #3442, deferring depset expansion to execution time. Tested under Bazel 8.5.1 and 9.0.0. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 22f1352 commit cd34111

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ END_UNRELEASED_TEMPLATE
7272
{obj}`--stamp` flag.
7373
* (pypi) Now the RECORD file patches will follow the quoted or unquoted filenames convention
7474
in order to make `pytorch` and friends easier to patch.
75+
* (wheel) `py_wheel` no longer expands the input depset during analysis,
76+
improving analysis performance for targets with large dependency trees.
7577

7678
{#v0-0-0-fixed}
7779
### Fixed

python/private/py_wheel.bzl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,13 @@ def _py_wheel_impl(ctx):
344344
# Currently this is only the description file (if used).
345345
other_inputs = []
346346

347-
# Wrap the inputs into a file to reduce command line length.
347+
# Wrap the inputs into a file to reduce command line length, deferring
348+
# depset expansion to execution time via Args.add_all with map_each.
348349
packageinputfile = ctx.actions.declare_file(ctx.attr.name + "_target_wrapped_inputs.txt")
349-
content = ""
350-
for input_file in inputs_to_package.to_list():
351-
content += _input_file_to_arg(input_file) + "\n"
352-
ctx.actions.write(output = packageinputfile, content = content)
350+
package_args = ctx.actions.args()
351+
package_args.set_param_file_format("multiline")
352+
package_args.add_all(inputs_to_package, map_each = _input_file_to_arg)
353+
ctx.actions.write(output = packageinputfile, content = package_args)
353354
other_inputs.append(packageinputfile)
354355

355356
args = ctx.actions.args()

0 commit comments

Comments
 (0)