Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f7a96a4

Browse filesBrowse files
pstradomskibrandjon
authored andcommitted
Stop using deprecated depset.union API (bazel-contrib#180)
Also switch to using Args api for building args instead of flattening the depset.
1 parent fa6ab78 commit f7a96a4
Copy full SHA for f7a96a4

File tree

1 file changed

+26
-34
lines changed
Filter options

1 file changed

+26
-34
lines changed

‎experimental/python/wheel.bzl

Copy file name to clipboardExpand all lines: experimental/python/wheel.bzl
+26-34
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def _path_inside_wheel(input_file):
2727
fail("input_file.path '%s' does not start with expected root '%s'" % (input_file.path, root))
2828
return input_file.path[len(root):]
2929

30+
def _input_file_to_arg(input_file):
31+
"""Converts a File object to string for --input_file argument to wheelmaker"""
32+
return "%s;%s" % (_path_inside_wheel(input_file), input_file.path)
33+
3034
def _py_package_impl(ctx):
3135
inputs = depset(
3236
transitive = [dep[DefaultInfo].data_runfiles.files for dep in ctx.attr.deps] +
@@ -83,29 +87,23 @@ def _py_wheel_impl(ctx):
8387
ctx.attr.platform,
8488
]) + ".whl")
8589

86-
inputs = depset(
90+
inputs_to_package = depset(
8791
direct = ctx.files.deps,
8892
)
8993

90-
arguments = [
91-
"--name",
92-
ctx.attr.distribution,
93-
"--version",
94-
ctx.attr.version,
95-
"--python_tag",
96-
ctx.attr.python_tag,
97-
"--abi",
98-
ctx.attr.abi,
99-
"--platform",
100-
ctx.attr.platform,
101-
"--out",
102-
outfile.path,
103-
]
94+
# Inputs to this rule which are not to be packaged.
95+
# Currently this is only the description file (if used).
96+
other_inputs = []
97+
98+
args = ctx.actions.args()
99+
args.add("--name", ctx.attr.distribution)
100+
args.add("--version", ctx.attr.version)
101+
args.add("--python_tag", ctx.attr.python_tag)
102+
args.add("--abi", ctx.attr.abi)
103+
args.add("--platform", ctx.attr.platform)
104+
args.add("--out", outfile.path)
104105

105-
# TODO: Use args api instead of flattening the depset.
106-
for input_file in inputs.to_list():
107-
arguments.append("--input_file")
108-
arguments.append("%s;%s" % (_path_inside_wheel(input_file), input_file.path))
106+
args.add_all(inputs_to_package, format_each = "--input_file=%s", map_each = _input_file_to_arg)
109107

110108
extra_headers = []
111109
if ctx.attr.author:
@@ -118,36 +116,30 @@ def _py_wheel_impl(ctx):
118116
extra_headers.append("License: %s" % ctx.attr.license)
119117

120118
for h in extra_headers:
121-
arguments.append("--header")
122-
arguments.append(h)
119+
args.add("--header", h)
123120

124121
for c in ctx.attr.classifiers:
125-
arguments.append("--classifier")
126-
arguments.append(c)
122+
args.add("--classifier", c)
127123

128124
for r in ctx.attr.requires:
129-
arguments.append("--requires")
130-
arguments.append(r)
125+
args.add("--requires", r)
131126

132127
for option, requirements in ctx.attr.extra_requires.items():
133128
for r in requirements:
134-
arguments.append("--extra_requires")
135-
arguments.append(r + ";" + option)
129+
args.add("--extra_requires", r + ";" + option)
136130

137131
for name, ref in ctx.attr.console_scripts.items():
138-
arguments.append("--console_script")
139-
arguments.append(name + " = " + ref)
132+
args.add("--console_script", name + " = " + ref)
140133

141134
if ctx.attr.description_file:
142135
description_file = ctx.file.description_file
143-
arguments.append("--description_file")
144-
arguments.append(description_file.path)
145-
inputs = inputs.union([description_file])
136+
args.add("--description_file", description_file)
137+
other_inputs.append(description_file)
146138

147139
ctx.actions.run(
148-
inputs = inputs,
140+
inputs = depset(direct = other_inputs, transitive = [inputs_to_package]),
149141
outputs = [outfile],
150-
arguments = arguments,
142+
arguments = [args],
151143
executable = ctx.executable._wheelmaker,
152144
progress_message = "Building wheel",
153145
)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.