Skip to content

Commit 320ff43

Browse files
committed
Mark unstable; create a parallel whl tree
1 parent ad7f828 commit 320ff43

File tree

8 files changed

+71
-20
lines changed

8 files changed

+71
-20
lines changed

e2e/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ importer = use_extension("//cases/repository-rule-deps-299/rules:import.bzl", "i
7272
use_repo(importer, "myrepo")
7373

7474
# For cases/uv-deps-650
75-
uv = use_extension("@aspect_rules_py//uv:extension.bzl", "uv")
75+
uv = use_extension("@aspect_rules_py//uv/unstable:extension.bzl", "uv")
7676
uv.declare_hub(hub_name = "pypi")
7777
uv.declare_venv(
7878
hub_name = "pypi",

uv/private/hub/repository.bzl

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,25 @@ load("@aspect_rules_py//py:defs.bzl", "py_library")
2121
2222
py_library(
2323
name = "all",
24-
deps = select({arms}),
24+
deps = select({lib_arms}),
2525
visibility = ["//visibility:public"],
2626
)
27-
""".format(arms = {
27+
alias(
28+
name = "all_requirements",
29+
actual = ":all",
30+
)
31+
filegroup(
32+
name = "all_whl_requirements",
33+
srcs = select({whl_arms}),
34+
visibility = ["//visibility:public"],
35+
)
36+
""".format(lib_arms = {
2837
"//venv:{}".format(venv): pkgs
2938
for venv, pkgs in venv_packages.items()
39+
},
40+
whl_arms = {
41+
"//venv:{}".format(venv): [it.split(":")[0] + ":whl" for it in pkgs]
42+
for venv, pkgs in venv_packages.items()
3043
}))
3144

3245
################################################################################
@@ -130,18 +143,33 @@ load("//:defs.bzl", "pip")
130143
"""
131144
# This target is for a "hard" dependency.
132145
# Dependencies on this target will cause build failures if it's unavailable.
146+
alias(
147+
name = "lib",
148+
actual = "{name}",
149+
visibility = ["//visibility:public"],
150+
)
133151
alias(
134152
name = "{name}",
135153
actual = select(
136-
{select},
154+
{lib_select},
155+
no_match_error = "{error}",
156+
),
157+
target_compatible_with = pip.compatible_with({compat}),
158+
visibility = ["//visibility:public"],
159+
)
160+
alias(
161+
name = "whl",
162+
actual = select(
163+
{whl_select},
137164
no_match_error = "{error}",
138165
),
139166
target_compatible_with = pip.compatible_with({compat}),
140167
visibility = ["//visibility:public"],
141168
)
142169
""".format(
143170
name = name,
144-
select = repr(select_spec),
171+
lib_select = repr(select_spec),
172+
whl_select = repr({k: v.split(":")[0] + ":whl" for k, v in select_spec.items()}),
145173
compat = repr(spec),
146174
error = error,
147175
),

uv/private/venv_hub/repository.bzl

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ alias(
2020
)
2121
alias(
2222
name = "{pkg}",
23-
actual = "//private/sccs:{scc}",
23+
actual = "//private/sccs:{scc}_lib",
24+
visibility = ["//visibility:public"],
25+
)
26+
alias(
27+
name = "whl",
28+
actual = "//private/sccs:{scc}_whl",
2429
visibility = ["//visibility:public"],
2530
)
2631
""".format(
@@ -81,7 +86,6 @@ decide_marker(
8186

8287
# JSON decode the marker mapping so we can use it
8388
scc_markers = json.decode(repository_ctx.attr.scc_markers)
84-
print(scc_markers)
8589

8690
content = [
8791
"# FIXME",
@@ -90,11 +94,16 @@ decide_marker(
9094
"""
9195
# A placeholder library which allows us to select to nothing
9296
py_library(
93-
name = "empty",
97+
name = "_empty_lib",
9498
srcs = [],
9599
imports = [],
96100
visibility = ["//visibility:private"]
97101
)
102+
filegroup(
103+
name = "_empty_whl",
104+
srcs = [],
105+
visibility = ["//visibility:private"]
106+
)
98107
""",
99108
]
100109

@@ -120,8 +129,6 @@ py_library(
120129
dep_labels.append("\"//%s\"" % d)
121130

122131
else:
123-
print("Got markers", markers)
124-
125132
# Hard case of generating a conditional dep
126133
content.append(
127134
"""
@@ -134,10 +141,17 @@ selects.config_setting_group(
134141
135142
# Depend on {d} of any of the {group} markers is active
136143
alias(
137-
name = "_{group}_{d}",
144+
name = "_{group}_{d}_lib",
138145
actual = select({{
139146
":_maybe_{group}_{d}": "//{d}",
140-
"//conditions:default": ":empty",
147+
"//conditions:default": ":_empty_lib",
148+
}}),
149+
)
150+
alias(
151+
name = "_{group}_{d}_whl",
152+
actual = select({{
153+
":_maybe_{group}_{d}": "//{d}:whl",
154+
"//conditions:default": ":_empty_whl",
141155
}}),
142156
)
143157
""".format(
@@ -146,21 +160,28 @@ alias(
146160
markers = ["//private/markers:%s" % it for it in markers],
147161
),
148162
)
149-
dep_labels.append("\":_{}_{}\"".format(group, d))
163+
dep_labels.append("\":_{}_{}_lib\"".format(group, d))
150164

151165
content.append(
152166
"""
153167
py_library(
154-
name = "{}",
168+
name = "{name}_lib",
155169
srcs = [],
156170
deps = [
157-
{}
171+
{lib_deps}
158172
],
159173
visibility = ["//:__subpackages__"],
160174
)
161-
""".format(
162-
group,
163-
",\n".join([((" " * 8) + it) for it in (member_installs + dep_labels)]),
175+
filegroup(
176+
name = "{name}_whl",
177+
srcs = [
178+
{whl_deps}
179+
],
180+
visibility = ["//:__subpackages__"],
181+
)""".format(
182+
name=group,
183+
lib_deps=",\n".join([((" " * 8) + it) for it in (member_installs + dep_labels)]),
184+
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])]),
164185
),
165186
)
166187

uv/private/whl_install/defs.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Helpers.
33
"""
44

5-
def select_chain(name, arms):
5+
def select_chain(name, arms, visibility = ["//visibility:private"]):
66
"""
77
Generate an ordered select chain.
88
@@ -30,4 +30,5 @@ def select_chain(name, arms):
3030
condition: target,
3131
},
3232
),
33+
visibility = visibility,
3334
)

uv/private/whl_install/repository.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,9 @@ def _whl_install_impl(repository_ctx):
133133
content.append(
134134
"""
135135
select_chain(
136-
name = 'whl',
136+
name = "whl",
137137
arms = {},
138+
visibility = ["//visibility:public"],
138139
)
139140
""".format(
140141
_format_arms(select_arms),

uv/unstable/BUILD.bazel

Whitespace-only changes.

uv/unstable/defs.bzl

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)