Skip to content

doc how to lookup python toolchain information #3044

Open
@rickeylev

Description

@rickeylev

A case I've had to explain a few times to people is how to use toolchains to get information custom rules want. Often what I see is people hard-coding python versions in constants or using large select statements, when a toolchain lookup is typically more appropriate.

Bazel Toolchains are intimidating, though. Most Bazel docs talk about the backend details of defining them and resolving them, so the easy part of just accessing them gets lost:

  • Add toolchains = ... arg to rule()
  • Use ctx.toolchains[...] in the rule

We should have some docs that give examples for some common cases, e.g.

  • I want to get the current python version
  • I want to get the current python headers
  • I want to build the string needed for e.g. wheel file naming.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions