diff --git a/experimental/python/wheel.bzl b/experimental/python/wheel.bzl index 9cd6534e78..71bde94e1f 100644 --- a/experimental/python/wheel.bzl +++ b/experimental/python/wheel.bzl @@ -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) @@ -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) + args.add("--input_file_list", packageinputfile) extra_headers = [] if ctx.attr.author: diff --git a/experimental/rules_python/wheelmaker.py b/experimental/rules_python/wheelmaker.py index 6be5d3847f..1b3261d018 100644 --- a/experimental/rules_python/wheelmaker.py +++ b/experimental/rules_python/wheelmaker.py @@ -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. " @@ -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: + 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())