Skip to content

Commit 80c3c12

Browse files
committed
propagate env
1 parent 06a0e53 commit 80c3c12

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

python/uv/private/lock.bzl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ _RunLockInfo = provider(
5555
doc = "",
5656
fields = {
5757
"args": "",
58+
"env": "",
5859
"py": "",
5960
"srcs": "",
6061
"template": "",
@@ -77,7 +78,7 @@ def _lock_impl(ctx):
7778
ctx.actions.expand_template(
7879
template = ctx.files._template[0],
7980
substitutions = {
80-
"\"{{args}}\"": " ",
81+
'"{{args}}"': "",
8182
"{{bazel_out}}": output.path,
8283
"{{src_out}}": existing_output[0].path,
8384
"{{uv}}": uv.path,
@@ -132,6 +133,7 @@ def _lock_impl(ctx):
132133
DefaultInfo(files = depset([output])),
133134
_RunLockInfo(
134135
args = run_args + args,
136+
env = ctx.attr.env,
135137
srcs = srcs,
136138
uv = uv,
137139
py = py_runtime,
@@ -145,10 +147,12 @@ _lock = rule(
145147
""",
146148
attrs = {
147149
"args": attr.string_list(
148-
doc = "",
150+
doc = "Args to pass to `uv`.",
149151
),
150152
"env": attr.string_dict(
151-
doc = "",
153+
doc = """\
154+
The env variables that are set when executing `uv`.
155+
""",
152156
),
153157
"existing_output": attr.label(
154158
mandatory = False,
@@ -221,7 +225,7 @@ def _lock_run_impl(ctx):
221225
ctx.actions.expand_template(
222226
template = info.template,
223227
substitutions = {
224-
"\"{{args}}\"": " ".join([shell.quote(a) for a in args]),
228+
'"{{args}}"': " ".join([shell.quote(a) for a in args]),
225229
"{{src_out}}": "{}/{}".format(ctx.label.package, ctx.attr.output),
226230
"{{uv}}": uv.short_path,
227231
},
@@ -237,11 +241,15 @@ def _lock_run_impl(ctx):
237241
],
238242
),
239243
)
244+
run_environment_info = RunEnvironmentInfo(
245+
environment = info.env,
246+
)
240247
return [
241248
DefaultInfo(
242249
executable = executable,
243250
runfiles = runfiles,
244251
),
252+
run_environment_info,
245253
]
246254

247255
_lock_run = rule(
@@ -342,8 +350,6 @@ def lock(*, name, srcs, out, args = [], env = None, **kwargs):
342350
name = locker_target,
343351
lock = name,
344352
output = out,
345-
# TODO @aignas 2025-03-13: allow customizing the env
346-
# env = env,
347353
tags = ["manual"],
348354
)
349355

0 commit comments

Comments
 (0)