8000 Fix for when there are so many file arguments it creates the Command … · bazel-contrib/rules_python@c82a8cc · GitHub
[go: up one dir, main page]

Skip to content

Commit c82a8cc

Browse files
authored
Fix for when there are so many file arguments it creates the Command To Long error (#320)
1 parent 708ed86 commit c82a8cc

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

experimental/python/wheel.bzl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ def _py_wheel_impl(ctx):
9898
# Currently this is only the description file (if used).
9999
other_inputs = []
100100

101+
# Wrap the inputs into a file to reduce command line length.
102+
packageinputfile = ctx.actions.declare_file(ctx.attr.name + '_target_wrapped_inputs.txt')
103+
content = ''
104+
for input_file in inputs_to_package.to_list():
105+
content += _input_file_to_arg(input_file) + '\n'
106+
ctx.actions.write(output = packageinputfile, content=content)
107+
other_inputs.append(packageinputfile)
108+
101109
args = ctx.actions.args()
102110
args.add("--name", ctx.attr.distribution)
103111
args.add("--version", ctx.attr.version)
@@ -107,7 +115,7 @@ def _py_wheel_impl(ctx):
107115
args.add("--out", outfile.path)
108116
args.add_all(ctx.attr.strip_path_prefixes, format_each = "--strip_path_prefix=%s")
109117

110-
args.add_all(inputs_to_package, format_each = "--input_file=%s", map_each = _input_file_to_arg)
118+
args.add("--input_file_list", packageinputfile)
111119

112120
extra_headers = []
113121
if ctx.attr.author:

experimental/rules_python/wheelmaker.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ def main():
242242
help="'package_path;real_path' pairs listing "
243243
"files to be included in the wheel. "
244244
"Can be supplied multiple times.")
245+
contents_group.add_argument(
246+
'--input_file_list', action='append',
247+
help='A file that has all the input files defined as a list to avoid the long command'
248+
)
245249
contents_group.add_argument(
246250
'--console_script', action='append',
247251
help="Defines a 'console_script' entry point. "
@@ -264,6 +268,14 @@ def main():
264268
input_files = [i.split(';') for i in arguments.input_file]
265269
else:
266270
input_files = []
271+
272+
if arguments.input_file_list:
273+
for input_file in arguments.input_file_list:
274+
with open(input_file) as _file:
275+
input_file_list = _file.read().splitlines()
276+
for _input_file in input_file_list:
277+
input_files.append(_input_file.split(';'))
278+
267279
all_files = get_files_to_package(input_files)
268280
# Sort the files for reproducible order in the archive.
269281
all_files = sorted(all_files.items())

0 commit comments

Comments
 (0)
0