Skip to content

Doc mistake about configuring Python toolchains #1921

@xinnjie

Description

@xinnjie

🐞 bug report

Affected Rule

No rules affacted

Is this a regression?

No

Description

Root modules

Root modules are always the top-most module. These are special in two ways:

  1. Some rules_python bzlmod APIs are only respected by the root module.
  2. The root module can force module overrides and specific module dependency
    ordering.

When configuring rules_python for a root module, you typically want to
explicitly specify the Python version you want to use. This ensures that
dependencies don't change the Python version out from under you. Remember that
rules_python will set a version by default, but it will change regularly as
it tracks a recent Python version.

NOTE: If your root module only uses Python for development of the module itself,
you should read the dev-only library module section.

bazel_dep(name="rules_python", version=...)
python = use_extension("@rules_python//extensions:python.bzl", "python")

python.toolchain(python_version = "3.12", is_default = True)

python = use_extension("@rules_python//extensions:python.bzl", "python") is used in documentation, but when I following this , python toolchain configuration is not takeing affect. Aftert changing to python = use_extension("@rules_python//python/extensions:python.bzl", "python"), it works well.

It is like a doc mistake.

I am new to bazel, correct me if it is wrong.

🔬 Minimal Reproduction

🔥 Exception or Error





🌍 Your Environment

Operating System:

  
macOs 14.2.1
  

Output of bazel version:

  
Bazelisk version: development
Build label: 7.1.2
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Wed May 8 20:50:30 2024 (1715201430)
Build timestamp: 1715201430
Build timestamp as int: 171520143
  

Rules_python version:

  
0.32.2
  

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions