Description
🚀 feature request
Relevant Rules
py_binary
, py_test
(from @rules_python)
Description
When building Python binaries or tests using Bazel (specifically with py_binary and py_test),
we encounter an "Argument list too long" error during the build process.
This happens when our projects depend on a very large number of files, particularly those from large Python libraries managed by pip_parse (e.g., boto3, msgraph-sdk-python).
The root cause seems to be that Bazel calls the zipper tool by passing all file paths to be included in the package directly as command-line arguments.
rules_python/python/private/py_executable.bzl
Lines 891 to 957 in 9429ae6
This leads to the argument list exceeding the operating system's ARG_MAX limit.
This error makes our Bazel builds unstable and undermines the reliability of our CI/CD pipelines for large Python projects.
Describe the solution you'd like
We propose enhancing rules_python to always pass arguments to the zipper tool via a temporary response file, rather than directly on the command line.
Upon inspecting zipper's zip_main.cc source code, it appears to support reading arguments from a file using the @ syntax (as indicated by logic to process arguments starting with @).
By consistently utilizing this response file capability, rules_python can entirely bypass OS ARG_MAX limitations.