fix(toolchain): Also set Make variables for local toolchains#3641
fix(toolchain): Also set Make variables for local toolchains#3641jwnimmer-tri wants to merge 1 commit intobazel-contrib:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical build issue within Bazel projects, specifically affecting rules that rely on Python toolchains. It ensures that Make variables like Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request extends the logic for setting $(PYTHON...) Make variables to also cover local toolchains (platform runtimes). For platform runtimes, which use an absolute interpreter_path, both the PYTHON and PYTHON_ROOTPATH variables are set to this path. This ensures the variables are always defined. My review includes minor suggestions to improve code clarity by reducing redundancy.
| vars["PYTHON3"] = toolchain.py3_runtime.interpreter_path | ||
| vars["PYTHON3_ROOTPATH"] = toolchain.py3_runtime.interpreter_path |
There was a problem hiding this comment.
To improve readability and avoid redundant attribute access, you can store toolchain.py3_runtime.interpreter_path in a local variable.
| vars["PYTHON3"] = toolchain.py3_runtime.interpreter_path | |
| vars["PYTHON3_ROOTPATH"] = toolchain.py3_runtime.interpreter_path | |
| path = toolchain.py3_runtime.interpreter_path | |
| vars["PYTHON3"] = path | |
| vars["PYTHON3_ROOTPATH"] = path |
| vars["PYTHON2"] = toolchain.py2_runtime.interpreter_path | ||
| vars["PYTHON2_ROOTPATH"] = toolchain.py2_runtime.interpreter_path |
There was a problem hiding this comment.
Similarly here, you can use a local variable to improve readability and avoid accessing the same attribute twice.
| vars["PYTHON2"] = toolchain.py2_runtime.interpreter_path | |
| vars["PYTHON2_ROOTPATH"] = toolchain.py2_runtime.interpreter_path | |
| path = toolchain.py2_runtime.interpreter_path | |
| vars["PYTHON2"] = path | |
| vars["PYTHON2_ROOTPATH"] = path |
Related to the discussion in #3575, the BCR rules for
@glibrecently added a requirement that the Make variable$(PYTHON3)must always be defined by the current Python toolchain.Here's a sample diff from that pull request bazelbuild/bazel-central-registry#7467 (see also full diff):
However, if the user is using a "platform runtime" (local interpreter) instead of an "in-build interpreter" (hermetic), then the Make variable was not set, resulting in a
@glibbuild error:This change fixes that problem by setting both Make variables to the absolute path of the platform runtime.
Does this change seem like its on the right track?
I was less sure about setting
$(PYTHON3_ROOTPATH)as well. I can remove that part if it seems suspicious.