@@ -3,14 +3,12 @@ Installing wheels as a Bazel build action, rather than a repo step.
33"""
44
55load ("@rules_python//python:defs.bzl" , "PyInfo" )
6+ load ("//py/private/toolchain:types.bzl" , "PY_TOOLCHAIN" , "UNPACK_TOOLCHAIN" )
67
7- PYTHON_TOOLCHAIN_TYPE = "@rules_python//python:toolchain_type"
8- UV_TOOLCHAIN = "@multitool//tools/uv:toolchain_type"
98
109def _whl_install (ctx ):
11- py_toolchain = ctx .toolchains [PYTHON_TOOLCHAIN_TYPE ].py3_runtime
12- uv = ctx .toolchains [UV_TOOLCHAIN ]
13-
10+ py_toolchain = ctx .toolchains [PY_TOOLCHAIN ].py3_runtime
11+ unpack_toolchain = ctx .toolchains [UNPACK_TOOLCHAIN ]
1412 install_dir = ctx .actions .declare_directory (
1513 "install" ,
1614 )
@@ -24,25 +22,28 @@ def _whl_install(ctx):
2422 #
2523 # Could probably use bsdtar here rather than non-hermetic unzip.
2624
25+
2726 # FIXME: Need the Python toolchain here?
2827 archive = ctx .attr .src [DefaultInfo ].files .to_list ()[0 ]
28+
29+ arguments = ctx .actions .args ()
30+ arguments .add_all ([
31+ "--into" ,
32+ install_dir .path ,
33+ "--wheel" ,
34+ archive .path ,
35+ "--python-version" ,
36+ "{}.{}.{}" .format (
37+ py_toolchain .interpreter_version_info .major ,
38+ py_toolchain .interpreter_version_info .minor ,
39+ py_toolchain .interpreter_version_info .micro ,
40+ ),
41+ ])
42+
2943 ctx .actions .run (
30- executable = uv .executable ,
31- arguments = [
32- "pip" ,
33- "install" ,
34- "--no-deps" ,
35- # FIXME: What happens when this is a TreeArtifact?
36- "--prefix" ,
37- install_dir .path ,
38- "--python" ,
39- py_toolchain .interpreter .path ,
40- archive .path ,
41- ],
42- inputs = [
43- archive ,
44- uv .executable ,
45- ] + py_toolchain .files .to_list (),
44+ executable = unpack_toolchain .bin .bin ,
45+ arguments = [arguments ],
46+ inputs = [archive ],
4647 outputs = [
4748 install_dir ,
4849 ],
@@ -83,8 +84,8 @@ whl_install = rule(
8384 "src" : attr .label (doc = "" ),
8485 },
8586 toolchains = [
86- PYTHON_TOOLCHAIN_TYPE ,
87- UV_TOOLCHAIN ,
87+ PY_TOOLCHAIN ,
88+ UNPACK_TOOLCHAIN ,
8889 ],
8990 provides = [
9091 DefaultInfo ,
0 commit comments