Skip to content

Commit 4694253

Browse files
committed
Use with_cfg to implement the whl transition
1 parent 69b4e61 commit 4694253

File tree

7 files changed

+37
-57
lines changed

7 files changed

+37
-57
lines changed

.bcr/patches/remove_dev_deps.patch

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
--- a/MODULE.bazel 2025-11-05 12:16:36.670092448 -0700
2-
+++ b/MODULE.bazel 2025-11-05 12:16:36.670200199 -0700
3-
@@ -46,548 +46,5 @@
1+
--- a/MODULE.bazel 2025-11-05 15:06:52.140088163 -0700
2+
+++ b/MODULE.bazel 2025-11-05 15:06:52.140147023 -0700
3+
@@ -47,546 +47,5 @@
44
# HACK: In prod the includer's patch inserts the use_repo for multitool. This
55
# solves the problem of needing a use_repo here in prod and below in dev.
66

@@ -170,7 +170,6 @@
170170
-# Rust configuration
171171
-
172172
-bazel_dep(name = "rules_rust", version = "0.67.0")
173-
-
174173
-bazel_dep(name = "openssl", version = "3.3.1.bcr.6")
175174
-
176175
-RUST_EDITION = "2024"
@@ -529,7 +528,6 @@
529528
-
530529
-########################################
531530
-# from bazel/include/release.MODULE.bazel
532-
-bazel_dep(name = "with_cfg.bzl", version = "0.11.0")
533531
-bazel_dep(name = "rules_pkg", version = "1.1.0")
534532
-
535533
-########################################

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ bazel_dep(name = "bazel_lib", version = "3.0.0")
1111
bazel_dep(name = "bazel_skylib", version = "1.4.2")
1212
bazel_dep(name = "platforms", version = "1.0.0")
1313
bazel_dep(name = "rules_python", version = "1.0.0")
14+
bazel_dep(name = "with_cfg.bzl", version = "0.11.0")
1415

1516
# FIXME: We're using this to pull in multitool for source builds. Could use an
1617
# internal tool instead.
@@ -570,7 +571,6 @@ http_file(
570571

571572
########################################
572573
# from bazel/include/release.MODULE.bazel
573-
bazel_dep(name = "with_cfg.bzl", version = "0.11.0")
574574
bazel_dep(name = "rules_pkg", version = "1.1.0")
575575

576576
########################################

bazel/include/release.MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
bazel_dep(name = "with_cfg.bzl", version = "0.11.0")
21
bazel_dep(name = "rules_pkg", version = "1.1.0")

uv/private/defs.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
load("//py:defs.bzl", "py_library")
2+
load("@with_cfg.bzl", "with_cfg")
3+
4+
py_whl_library, _ = with_cfg(py_library).set(Label("//uv/private/constraints:lib_mode"), "whl").build()

uv/private/hub/repository.bzl

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,21 @@ def _hub_impl(repository_ctx):
1818
# out how to make this take "soft" rather than "hard" dependencies.
1919
repository_ctx.file("BUILD.bazel", """\
2020
load("@aspect_rules_py//py:defs.bzl", "py_library")
21+
load("@aspect_rules_py//uv/private:defs.bzl", "py_whl_library")
2122
22-
alias(
23-
name = "all",
24-
actual = ":all_requirements",
25-
visibility = ["//visibility:public"],
26-
)
27-
alias(
28-
name = "all_requirements",
29-
actual = select({{
30-
"@aspect_rules_py//uv/private/constraints:libs_are_libs": ":all_lib",
31-
"@aspect_rules_py//uv/private/constraints:libs_are_whls": ":all_whl_requirements",
32-
}}),
33-
visibility = ["//visibility:public"],
34-
)
3523
py_library(
36-
name = "all_lib",
24+
name = "all_requirements",
3725
deps = select({lib_arms}),
3826
visibility = ["//visibility:private"],
3927
)
40-
filegroup(
28+
py_whl_library(
4129
name = "all_whl_requirements",
42-
srcs = select({whl_arms}),
30+
deps = [":all_requirements"],
4331
visibility = ["//visibility:public"],
4432
)
4533
""".format(lib_arms = {
4634
"//venv:{}".format(venv): pkgs
4735
for venv, pkgs in venv_packages.items()
48-
},
49-
whl_arms = {
50-
"//venv:{}".format(venv): [it.split(":")[0] + ":whl" for it in pkgs]
51-
for venv, pkgs in venv_packages.items()
5236
}))
5337

5438
################################################################################

uv/private/venv_hub/repository.bzl

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def _venv_hub_impl(repository_ctx):
1010
entrypoints = json.decode(repository_ctx.attr.entrypoints)
1111

1212
for pkg, group in repository_ctx.attr.aliases.items():
13-
content = []
13+
content = [
14+
"""load("@aspect_rules_py//uv/private:defs.bzl", "py_whl_library")"""
15+
]
1416
content.append(
1517
"""
1618
alias(
@@ -20,15 +22,12 @@ alias(
2022
)
2123
alias(
2224
name = "{pkg}",
23-
actual = select({{
24-
"@aspect_rules_py//uv/private/constraints:libs_are_libs": "//private/sccs:{scc}_lib",
25-
"@aspect_rules_py//uv/private/constraints:libs_are_whls": "//private/sccs:{scc}_whl",
26-
}}),
25+
actual = "//private/sccs:{scc}_lib",
2726
visibility = ["//visibility:public"],
2827
)
29-
alias(
28+
py_whl_library(
3029
name = "whl",
31-
actual = "//private/sccs:{scc}_whl",
30+
deps = [":{pkg}"],
3231
visibility = ["//visibility:public"],
3332
)
3433
""".format(
@@ -102,11 +101,6 @@ py_library(
102101
imports = [],
103102
visibility = ["//visibility:private"]
104103
)
105-
filegroup(
106-
name = "_empty_whl",
107-
srcs = [],
108-
visibility = ["//visibility:private"]
109-
)
110104
""",
111105
]
112106

@@ -150,13 +144,6 @@ alias(
150144
"//conditions:default": ":_empty_lib",
151145
}}),
152146
)
153-
alias(
154-
name = "_{group}_{d}_whl",
155-
actual = select({{
156-
":_maybe_{group}_{d}": "//{d}:whl",
157-
"//conditions:default": ":_empty_whl",
158-
}}),
159-
)
160147
""".format(
161148
group = group,
162149
d = d,
@@ -175,16 +162,9 @@ py_library(
175162
],
176163
visibility = ["//:__subpackages__"],
177164
)
178-
filegroup(
179-
name = "{name}_whl",
180-
srcs = [
181-
{whl_deps}
182-
],
183-
visibility = ["//:__subpackages__"],
184-
)""".format(
165+
""".format(
185166
name=group,
186167
lib_deps=",\n".join([((" " * 8) + it) for it in (member_installs + dep_labels)]),
187-
whl_deps=",\n".join([((" " * 8) + it) for it in ([it.replace(":install", ":whl") for it in member_installs] + [(it[:-1] + ":whl\"") if "//" in it else it.replace("_lib", "_whl") for it in dep_labels])]),
188168
),
189169
)
190170

uv/private/whl_install/repository.bzl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def _whl_install_impl(repository_ctx):
6565
# The strategy here is to roll through the wheels,
6666
select_arms = {}
6767
content = [
68-
"load(\"@aspect_rules_py//uv/private/whl_install:rule.bzl\", \"whl_install\")",
68+
"load(\"@aspect_rules_py//py:defs.bzl\", \"py_library\")",
6969
"load(\"@aspect_rules_py//uv/private/whl_install:defs.bzl\", \"select_chain\")",
70+
"load(\"@aspect_rules_py//uv/private/whl_install:rule.bzl\", \"whl_install\")",
7071
"load(\"@bazel_skylib//lib:selects.bzl\", \"selects\")",
7172
]
7273

@@ -135,7 +136,13 @@ def _whl_install_impl(repository_ctx):
135136
select_chain(
136137
name = "whl",
137138
arms = {},
138-
visibility = ["//visibility:public"],
139+
visibility = ["//visibility:private"],
140+
)
141+
py_library(
142+
name = "whl_lib",
143+
srcs = [],
144+
data = [":whl"],
145+
visibility = ["//visibility:private"],
139146
)
140147
""".format(
141148
_format_arms(select_arms),
@@ -146,8 +153,16 @@ select_chain(
146153
content.append(
147154
"""
148155
whl_install(
149-
name = "install",
156+
name = "actual_install",
150157
src = ":whl",
158+
visibility = ["//visibility:private"],
159+
)
160+
alias(
161+
name = "install",
162+
actual = select({
163+
"@aspect_rules_py//uv/private/constraints:libs_are_libs": ":actual_install",
164+
"@aspect_rules_py//uv/private/constraints:libs_are_whls": ":whl_lib",
165+
}),
151166
visibility = ["//visibility:public"],
152167
)
153168
""",

0 commit comments

Comments
 (0)