rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

Use the `launcher_maker` toolchain if available

Open fmeum opened this issue 8 months ago • 2 comments

PR Instructions/requirements

  • Title uses type: description format. See CONTRIBUTING.md for types.
    • Common types are: build, docs, feat, fix, refactor, revert, test
    • Update CHANGELOG.md as applicable
  • Breaking changes include "!" after the type and a "BREAKING CHANGES:" section at the bottom. See CONTRIBUTING.md for our breaking changes process.
  • Body text describes:
    • Why this change is being made, briefly.
    • Before and after behavior, as applicable
    • References issue number, as applicable
  • Update docs and tests, as applicable
  • Delete these instructions prior to sending the PR

fmeum avatar May 20 '25 20:05 fmeum

fwiw/fyi: we have a CI job that uses bazel-rolling, in case that's helpful.

Also, a fun trick is using FeatureFlagInfo to detect if a toolchain is present. Something like:

def impl(ctx):
  return FeatureFlagInfo(value=str(ctx.toolchains["foo"] == None))
has_tc = rule(
  implementation = impl,
  toolchains = [toolchain_type("foo", mandatory=False)]

has_tc(name="has_tc")
config_setting("is_has_tc_true", flag_values = {":has_tc": "True"})

alias("launcher_maker", actual = select({
  "is_has_tc_true": ...,
  })
)

rickeylev avatar May 20 '25 20:05 rickeylev

Adding a dep on bazel_features isn't easy with rules_python's WORKSPACE setup since it doesn't use two levels of macros. Can we add a call to bazel_features_deps to the relnotes?

fmeum avatar May 21 '25 13:05 fmeum