Skip to content

Use rules_python python_bootstrap_template instead of bazel_tools's #1556

@rickeylev

Description

@rickeylev

When a py_binary is built, the resulting executable is expanded from the template python_bootstrap_template.txt.

As of Bazel 7, py_runtime allows specifying this template. This allows us to customize program startup without changes in Bazel itself.

I copied the one in Bazel into rules_python, it lives here: https://github.com/bazelbuild/rules_python/blob/main/python/private/python_bootstrap_template.txt#L4

The basic todos are:

  • Change toolchain generation code, the part that creates py_runtime(), and add a version check for Bazel 7. If its Bazel 7, set bootstrap_template to the rules python template.

The benefits of this are:

  1. We can now have python version specific bootstrap templates. Or other platform-specific templates.
  2. We can use some shell tricks to help solve py_binary with hermetic toolchain requires a system interpreter #691. I'm not sure we can entirely solve it, but we probably get close enough.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Can Close?Will close in 30 days if there is no new activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions