Skip to content

Commit 0d518a9

Browse files
committed
add dev_dependency and doc for it
1 parent 3c83b87 commit 0d518a9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

docs/toolchains.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ local_runtime_repo = use_repo_rule(
358358
local_runtime_toolchains_repo = use_repo_rule(
359359
"@rules_python//python/local_toolchains:repos.bzl"
360360
"local_runtime_toolchains_repo"
361+
dev_dependency = True,
361362
)
362363

363364
# Step 1: Define the Python runtime
@@ -374,12 +375,21 @@ local_runtime_toolchains_repo(
374375
)
375376

376377
# Step 3: Register the toolchains
377-
register_toolchains("@local_toolchains//:all")
378+
register_toolchains("@local_toolchains//:all", dev_dependency = True)
378379
```
379380

380381
Note that `register_toolchains` will insert the local toolchain earlier in the
381382
toolchain ordering, so it will take precedence over other registered toolchains.
382383

384+
:::{important}
385+
Be sure to set `dev_dependency = True`. Using a local toolchain only makes sense
386+
for the root module.
387+
388+
If an intermediate module does it, then the `register_toolchains()` call will
389+
take precedence over the default rules_python toolchains and cause problems for
390+
downstream modules.
391+
:::
392+
383393
Multiple runtimes and/or toolchains can be defined, which allows for multiple
384394
Python versions and/or platforms to be configured in a single `MODULE.bazel`.
385395

0 commit comments

Comments
 (0)