@@ -44,7 +44,8 @@ you should read the dev-only library module section.
4444bazel_dep(name="rules_python", version=...)
4545python = use_extension("@rules_python//python/extensions:python.bzl", "python")
4646
47- python.toolchain(python_version = "3.12", is_default = True)
47+ python.defaults(python_version = "3.12")
48+ python.toolchain(python_version = "3.12")
4849```
4950
5051### Library modules
@@ -72,7 +73,8 @@ python = use_extension(
7273 dev_dependency = True
7374)
7475
75- python.toolchain(python_version = "3.12", is_default=True)
76+ python.defaults(python_version = "3.12")
77+ python.toolchain(python_version = "3.12")
7678```
7779
7880#### Library modules without version constraints
@@ -161,9 +163,13 @@ Multiple versions can be specified and used within a single build.
161163# MODULE.bazel
162164python = use_extension(" @rules_python//python/extensions:python.bzl" , " python" )
163165
166+ python.defaults(
167+ # The environment variable takes precedence if set.
168+ python_version = " 3.11" ,
169+ python_version_env = " BAZEL_PYTHON_VERSION" ,
170+ )
164171python.toolchain(
165172 python_version = " 3.11" ,
166- is_default = True ,
167173)
168174
169175python.toolchain(
@@ -264,7 +270,8 @@ bazel_dep(name = "rules_python", version = "0.40.0")
264270
265271python = use_extension(" @rules_python//python/extensions:python.bzl" , " python" )
266272
267- python.toolchain(is_default = True , python_version = " 3.10" )
273+ python.defaults(python_version = " 3.10" )
274+ python.toolchain(python_version = " 3.10" )
268275
269276use_repo(python, " python_3_10" , " python_3_10_host" )
270277```
0 commit comments