10000 Fix for when there are so many file arguments it creates the Command To Long error by opbro · Pull Request #320 · bazel-contrib/rules_python · GitHub
[go: up one dir, main page]

Skip to content

Fix for when there are so many file arguments it creates the Command To Long error #320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion experimental/python/wheel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ def _py_wheel_impl(ctx):
# Currently this is only the description file (if used).
other_inputs = []

# Wrap the inputs into a file to reduce command line length.
packageinputfile = ctx.actions.declare_file(ctx.attr.name + '_target_wrapped_inputs.txt')
content = ''
for input_file in inputs_to_package.to_list():
content += _input_file_to_arg(input_file) + '\n'
ctx.actions.write(output = packageinputfile, content=content)
other_inputs.append(packageinputfile)

args = ctx.actions.args()
args.add("--name", ctx.attr.distribution)
args.add("--version", ctx.attr.version)
Expand All @@ -107,7 +115,7 @@ def _py_wheel_impl(ctx):
args.add("--out", outfile.path)
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")

args.add_all(inputs_to_package, format_each = "--input_file=%s", map_each = _input_file_to_arg)
8000 args.add("--input_file_list", packageinputfile)

extra_headers = []
if ctx.attr.author:
Expand Down
12 changes: 12 additions & 0 deletions experimental/rules_python/wheelmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ def main():
help="'package_path;real_path' pairs listing "
"files to be included in the wheel. "
"Can be supplied multiple times.")
contents_group.add_argument(
'--input_file_list', action='append',
help='A file that has all the input files defined as a list to avoid the long command'
)
contents_group.add_argument(
'--console_script', action='append',
help="Defines a 'console_script' entry point. "
Expand All @@ -264,6 +268,14 @@ def main():
input_files = [i.split(';') for i in arguments.input_file]
else:
input_files = []

if arguments.input_file_list:
for input_file in arguments.input_file_list:
with open(input_file) as _file:
4F25 input_file_list = _file.read().splitlines()
for _input_file in input_file_list:
input_files.append(_input_file.split(';'))

all_files = get_files_to_package(input_files)
# Sort the files for reproducible order in the archive.
all_files = sorted(all_files.items())
Expand Down
0