Skip to content

Commit f7ba97d

Browse files
committed
simplify
1 parent 8ecb3de commit f7ba97d

File tree

1 file changed

+17
-27
lines changed

1 file changed

+17
-27
lines changed

python/uv/private/lock.bzl

+17-27
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,23 @@ def _lock_impl(ctx):
112112
lock_args.add_all(srcs)
113113
lock_args.add("--output-file", output)
114114

115-
progress_message = "Creating a requirements.txt with uv: //{}:{}".format(ctx.label.package, ctx.label.name)
116-
if ctx.files.existing_output:
117-
ctx.actions.run_shell(
118-
command = "{copy} {src} {dst} && \"$@\"".format(
119-
copy = ctx.attr.copy_cmd,
120-
src = ctx.files.existing_output[0].path,
121-
dst = output.path,
122-
),
123-
mnemonic = "PyRequirementsLockUv",
124-
inputs = srcs + ctx.files.existing_output,
125-
outputs = [output],
126-
arguments = [lock_args],
127-
tools = [uv],
128-
progress_message = progress_message,
129-
env = ctx.attr.env,
130-
)
131-
else:
132-
ctx.actions.run_shell(
133-
command = "\"$@\"",
134-
mnemonic = "PyRequirementsLockUv",
135-
inputs = srcs,
136-
outputs = [output],
137-
arguments = [lock_args],
138-
tools = [uv],
139-
progress_message = progress_message,
140-
env = ctx.attr.env,
141-
)
115+
ctx.actions.run_shell(
116+
command = '{copy} {src} {dst} && "$@"'.format(
117+
copy = ctx.attr.copy_cmd,
118+
src = ctx.files.existing_output[0].path,
119+
dst = output.path,
120+
) if ctx.files.existing_output else '"$@"',
121+
inputs = srcs + ctx.files.existing_output,
122+
mnemonic = "PyRequirementsLockUv",
123+
outputs = [output],
124+
arguments = [lock_args],
125+
tools = [uv],
126+
progress_message = "Creating a requirements.txt with uv: //{}:{}".format(
127+
ctx.label.package,
128+
ctx.label.name,
129+
),
130+
env = ctx.attr.env,
131+
)
142132

143133
return [
144134
DefaultInfo(files = depset([output])),

0 commit comments

Comments
 (0)