Skip to content

chore: better bootstrap logging#3608

Merged
rickeylev merged 2 commits intobazel-contrib:mainfrom
rickeylev:chore.bootstrap.logging
Feb 21, 2026
Merged

chore: better bootstrap logging#3608
rickeylev merged 2 commits intobazel-contrib:mainfrom
rickeylev:chore.bootstrap.logging

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

@rickeylev rickeylev commented Feb 18, 2026

Adds additional logging in the python bootstrap.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @rickeylev, 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 significantly enhances the robustness and debuggability of the Python bootstrap mechanism, particularly addressing cross-platform compatibility issues. It introduces more verbose logging to provide deeper insights into the bootstrap's execution flow and improves error messages for clearer problem identification. Furthermore, it includes crucial fixes for Windows environments, ensuring correct file encoding, path handling, and permissions during the build data generation and consumption processes.

Highlights

  • Enhanced Bootstrap Logging: Added more verbose logging statements within the Python bootstrap process to provide deeper insights into execution flow and variable states.
  • Improved Error Messages: The AssertionError message for a missing Python binary has been made more informative, including both expected and actual binary paths.
  • Windows Compatibility Fixes: Implemented several changes to improve compatibility on Windows, including robust file writing in PowerShell, correct path handling in Python, and better error reporting for build data.
  • Refactored Path Construction: Updated the py_executable.bzl file to use a dedicated runfiles_root_path utility for constructing the stage2 bootstrap path.

🧠 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
  • python/private/build_data_writer.ps1
    • Refactored file content collection into an array for batch writing.
    • Updated file writing to use .NET's System.IO.File::WriteAllLines with UTF8 without BOM for improved encoding and locking.
    • Added Test-Path checks before attempting to read VersionFilePath and InfoFilePath.
    • Applied read permissions for 'Everyone' to the output file using ACLs.
  • python/private/py_executable.bzl
    • Replaced direct string formatting for the stage2_bootstrap path with a call to the runfiles_root_path utility function.
  • python/private/python_bootstrap_template.txt
    • Added print_verbose statements for STAGE2_BOOTSTRAP, PYTHON_BINARY, PYTHON_BINARY_ACTUAL, IS_ZIPFILE, RECREATE_VENV_AT_RUNTIME, and WORKSPACE_NAME.
    • Added print_verbose statements for main_rel_path and runfiles root.
    • Modified the AssertionError message for a missing Python binary to include both PYTHON_BINARY and PYTHON_BINARY_ACTUAL.
  • python/private/stage2_bootstrap_template.py
    • Added a comment clarifying the need for Windows path conversion for BUILD_DATA_FILE.
    • Implemented Windows-specific path normalization and conversion (replacing '/' with '' and using os.path.normpath) for rlocation_path.
    • Changed file opening to use encoding='utf-8-sig' to correctly handle Windows Byte Order Mark (BOM).
    • Enhanced exception handling in get_build_data to add notes about the rlocation_path, file existence, and readability for debugging.
  • tests/pypi/whl_installer/wheel_installer_test.py
    • Modified the tearDown method to use shutil.rmtree(..., ignore_errors=True) to prevent errors during directory removal on Windows.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces helpful improvements to the bootstrap logging and error reporting, which will aid in debugging issues during Python binary execution. The refactoring of the Windows build data writer to use .NET APIs is a robust change. However, there is a critical regression in the stage 2 bootstrap where runfiles lookup keys are incorrectly normalized with backslashes on Windows, which will break lookups. Additionally, the error handling logic in the stage 2 bootstrap should be more defensive when the runfiles lookup fails.

@rickeylev rickeylev force-pushed the chore.bootstrap.logging branch 2 times, most recently from e364945 to 1ac813d Compare February 18, 2026 02:57
@rickeylev rickeylev force-pushed the chore.bootstrap.logging branch from 1ac813d to 2e00f57 Compare February 18, 2026 02:58
@rickeylev rickeylev enabled auto-merge February 20, 2026 07:13
@rickeylev rickeylev added this pull request to the merge queue Feb 21, 2026
Merged via the queue into bazel-contrib:main with commit b6f1b78 Feb 21, 2026
4 checks passed
@rickeylev rickeylev deleted the chore.bootstrap.logging branch February 21, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants