Use rules_python python_bootstrap_template instead of bazel_tools's
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, setbootstrap_templateto the rules python template.
The benefits of this are:
- We can now have python version specific bootstrap templates. Or other platform-specific templates.
- We can use some shell tricks to help solve #691. I'm not sure we can entirely solve it, but we probably get close enough.
The will be huge! Can’t wait. So many things can be improved if the rules can manage the bootstrap.
Is this issue resolved? While debugging some Python stuff, I found the bootstrap template from rules_python was being used.
Yeah, I think so. The py_runtime implementation was switch over to starlark, and it gets its bootstrap from rules_python, which is used by py_binary.
For Bazel 6, we have to keep the template compatible across all python versions. With Bazel 7 we could (but don't currently) create a bootstrap for each specific version.
But yes, for the most part, rules_python does control it directly now.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!
🎉