Skip to content

Commit fcc17c3

Browse files
committedMar 11, 2025·
wip
1 parent 5705c72 commit fcc17c3

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed
 

‎docs/BUILD.bazel

-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ lock(
172172
args = [
173173
"--universal",
174174
],
175-
run_args = [
176-
"--upgrade",
177-
],
178175
visibility = ["//private:__pkg__"],
179176
)
180177

‎python/uv/private/lock.bzl

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def _lock_impl(ctx):
6363
run_args = [param_file.path]
6464
args = ctx.actions.args()
6565
args.add_all(run_args)
66-
args.add_all(ctx.attr.run_args)
6766

6867
cmd = ctx.executable._cmd
6968

@@ -119,9 +118,12 @@ def _run_lock_impl(ctx):
119118
)
120119

121120
executable = ctx.actions.declare_file(ctx.label.name + ".exe")
122-
ctx.actions.symlink(
121+
ctx.actions.write(
123122
output = executable,
124-
target_file = run_info.cmd_file,
123+
content = "#!/usr/bin/env bash\nset -eux\nexec {} {} \"$@\"".format(
124+
run_info.cmd_file.short_path,
125+
run_info.args.short_path,
126+
),
125127
is_executable = True,
126128
)
127129

@@ -152,7 +154,7 @@ _run_lock = rule(
152154
executable = True,
153155
)
154156

155-
def lock(*, name, srcs, out, args = [], run_args = [], **kwargs):
157+
def lock(*, name, srcs, out, args = [], **kwargs):
156158
"""Pin the requirements based on the src files.
157159
158160
Differences with the current {obj}`compile_pip_requirements` rule:
@@ -196,14 +198,12 @@ def lock(*, name, srcs, out, args = [], run_args = [], **kwargs):
196198
"no-cache",
197199
],
198200
args = args,
199-
run_args = run_args,
200201
target_compatible_with = _REQUIREMENTS_TARGET_COMPATIBLE_WITH,
201202
)
202203

203204
_run_lock(
204205
name = locker_target,
205206
lock = name,
206-
args = run_args,
207207
)
208208

209209
if maybe_out:

‎python/uv/private/pip_compile.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
import argparse
43
import os
54
import sys
65
from pathlib import Path
@@ -20,26 +19,24 @@ def _run() -> None:
2019
uv = os.fsdecode(uv_path)
2120
env = os.environ.copy()
2221

23-
# TODO @aignas 2025-03-11: this does not work when we try to pass extra args via bazel run
24-
# The best way is to do a template expansion.
22+
params = Path(sys.argv[1])
23+
sys_args = sys.argv[2:]
2524

26-
params = Path(f"{sys.argv[0]}.params.txt")
27-
assert params.exists(), f"{params} does not exist"
28-
sys_args = params.read_text().strip().split("\n")
25+
uv_args = params.read_text().strip().split("\n")
2926

3027
# Let `uv` know that it was spawned by this Python interpreter
3128
env["UV_INTERNAL__PARENT_INTERPRETER"] = sys.executable
3229
args = []
33-
src_out = sys_args[1] if sys_args[0] == "--src-out" else None
30+
src_out = uv_args[1] if uv_args[0] == "--src-out" else None
3431
if src_out:
35-
sys_args = sys_args[2:]
32+
uv_args = uv_args[2:]
3633

37-
if sys_args[0] != "--output-file":
34+
if uv_args[0] != "--output-file":
3835
raise ValueError(
39-
f"The first arg should be to declare the output file, got:\n{sys_args}"
36+
f"The first arg should be to declare the output file, got:\n{uv_args}"
4037
)
4138
else:
42-
out = sys_args[1]
39+
out = uv_args[1]
4340

4441
# this is set under bazel run
4542
workspace = env.get("BUILD_WORKSPACE_DIRECTORY")
@@ -51,9 +48,11 @@ def _run() -> None:
5148
import shutil
5249

5350
shutil.copy(src, dst)
54-
sys_args[1] = str(dst)
51+
uv_args[1] = str(dst)
5552

56-
uv_args = ["pip", "compile"] + args + sys_args + uv_args
53+
args += uv_args + sys_args
54+
uv_args = ["pip", "compile"] + args
55+
print("Running 'uv pip compile' with args:\n\t{}".format("\n\t".join(args)))
5756

5857
if sys.platform == "win32":
5958
import subprocess

0 commit comments

Comments
 (0)