Skip to content

Commit 4b709f1

Browse files
committed
add docs
1 parent 6b675f0 commit 4b709f1

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,6 @@ uv_dev = use_extension(
251251
"uv",
252252
dev_dependency = True,
253253
)
254-
uv_dev.append_config(
254+
uv_dev.configure(
255255
version = "0.6.2",
256256
)

examples/bzlmod/MODULE.bazel

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,7 @@ uv = use_extension(
109109
# module is used elsewhere.
110110
dev_dependency = True,
111111
)
112-
uv.append_config(version = "0.6.2")
113-
# You can also set the defaults for the base_url
114-
# uv.append_config(base_url = "my_mirror")
115-
# uv.append_config(
116-
# platform = "extra-platform",
117-
# target_settings = ["//my_config_setting_label"],
118-
# compatible_with = ["@platforms//os:exotic"],
119-
# )
112+
uv.configure(version = "0.6.2")
120113

121114
# This extension allows a user to create modifications to how rules_python
122115
# creates different wheel repositories. Different attributes allow the user

python/uv/private/uv.bzl

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,16 @@ load(":uv_toolchains_repo.bzl", "uv_toolchains_repo")
2525
_DOC = """\
2626
A module extension for working with uv.
2727
28-
Use it in your own setup by:
28+
Basic usage:
2929
```starlark
3030
uv = use_extension(
3131
"@rules_python//python/uv:uv.bzl",
3232
"uv",
33+
# Use `dev_dependency` so that the toolchains are not defined pulled when
34+
# your module is used elsewhere.
3335
dev_dependency = True,
3436
)
35-
uv.toolchain(
36-
name = "uv_toolchains",
37-
version = "0.5.24",
38-
)
39-
use_repo(uv, "uv_toolchains")
40-
41-
register_toolchains(
42-
"@uv_toolchains//:all",
43-
dev_dependency = True,
44-
)
37+
uv.configure(version = "0.5.24")
4538
```
4639
4740
Since this is only for locking the requirements files, it should be always
@@ -75,11 +68,29 @@ Set the uv configuration defaults.
7568
},
7669
)
7770

78-
append_config = tag_class(
71+
configure = tag_class(
7972
doc = """\
80-
Build the UV toolchain configuration appending the last configuration fragment or creating a new.
73+
Build the UV toolchain configuration appending configuration to the last version configuration or starting a new version configuration if {attr}`version` is passed.
74+
75+
In addition to the very basic configuration pattern outlined above you can customize
76+
the configuration:
77+
```starlark
78+
# Configure the base_url for the specified version.
79+
uv.configure(base_url = "my_mirror")
80+
81+
# Add an extra platform that can be used with your version.
82+
uv.configure(
83+
platform = "extra-platform",
84+
target_settings = ["//my_config_setting_label"],
85+
compatible_with = ["@platforms//os:exotic"],
86+
)
87+
```
8188
82-
A new configuration is created whenever {attr}`version` is passed.
89+
::::tip
90+
The configuration is additive for each version. This means that if you need to set
91+
defaults for all versions, use the {attr}`default` for all of the configuration,
92+
similarly how `rules_python` is doing it itself.
93+
::::
8394
""",
8495
attrs = {
8596
"base_url": attr.string(
@@ -145,7 +156,7 @@ def parse_modules(module_ctx):
145156
versions = {}
146157
for mod in module_ctx.modules:
147158
last_version = None
148-
for config_attr in mod.tags.append_config:
159+
for config_attr in mod.tags.configure:
149160
last_version = config_attr.version or last_version or config["version"]
150161
specific_config = versions.setdefault(last_version, {
151162
"base_url": config["base_url"],
@@ -292,7 +303,7 @@ uv = module_extension(
292303
doc = _DOC,
293304
implementation = _uv_toolchain_extension,
294305
tag_classes = {
295-
"append_config": append_config,
306+
"configure": configure,
296307
"default": default,
297308
},
298309
)

0 commit comments

Comments
 (0)