Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rules_python python_bootstrap_template instead of bazel_tools's #1556

Closed
1 task
rickeylev opened this issue Nov 13, 2023 · 5 comments
Closed
1 task

Use rules_python python_bootstrap_template instead of bazel_tools's #1556

rickeylev opened this issue Nov 13, 2023 · 5 comments
Labels
Can Close? Will close in 30 days if there is no new activity

Comments

@rickeylev
Copy link
Collaborator

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.
@groodt
Copy link
Collaborator

groodt commented Nov 13, 2023

The will be huge! Can’t wait. So many things can be improved if the rules can manage the bootstrap.

@armandomontanez
Copy link
Contributor

Is this issue resolved? While debugging some Python stuff, I found the bootstrap template from rules_python was being used.

@rickeylev
Copy link
Collaborator Author

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.

Copy link

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!

@github-actions github-actions bot added the Can Close? Will close in 30 days if there is no new activity label Jul 20, 2024
@arrdem
Copy link
Contributor

arrdem commented Jul 22, 2024

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days if there is no new activity
Projects
None yet
Development

No branches or pull requests

4 participants