Skip to content

test: add system_python_nodeps_test#3609

Open
rickeylev wants to merge 1 commit intobazel-contrib:mainfrom
rickeylev:test.system.python
Open

test: add system_python_nodeps_test#3609
rickeylev wants to merge 1 commit intobazel-contrib:mainfrom
rickeylev:test.system.python

Conversation

@rickeylev
Copy link
Collaborator

@rickeylev rickeylev commented Feb 18, 2026

Adds a simple system_python bootstrap test. Such a test otherwise doesn't directly
exist, and only ends up accidentally tested by something in an example directory.

@gemini-code-assist
Copy link
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 primarily focuses on enhancing the robustness and testability of Python rules, with a significant emphasis on improving Windows compatibility and debugging capabilities. It introduces a new test to verify system Python behavior without dependencies, alongside several fixes and enhancements to PowerShell scripts and Python bootstrap templates. These changes address Windows-specific challenges related to file paths, encoding, and permissions, while also adding verbose logging to facilitate the diagnosis of bootstrap-related issues.

Highlights

  • New Test Added: Introduced a new system_python_nodeps_test to validate the behavior of system Python bootstraps without additional dependencies.
  • Windows Compatibility Enhancements: Improved Windows compatibility for build data writing by refactoring the PowerShell script to use .NET for file operations, ensuring UTF-8 encoding without Byte Order Mark (BOM), and setting appropriate file permissions. Additionally, Windows-specific path handling and BOM support were added to the Python stage2 bootstrap template.
  • Improved Debugging and Diagnostics: Added verbose logging for key bootstrap variables and paths within the Python bootstrap template to aid in diagnosing issues. Error reporting for missing Python binaries and build data file access has also been enhanced with more context.
  • Path Handling Refinement: Updated py_executable.bzl to utilize a dedicated runfiles_root_path function for generating stage2_bootstrap paths, promoting consistent and correct path resolution.
  • Robust Test Cleanup: Modified wheel_installer_test.py to gracefully handle potential file deletion errors on Windows during test cleanup by ignoring errors when removing the temporary wheel directory.

🧠 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 writing logic to use .NET's WriteAllLines for improved encoding control (UTF-8 without BOM) and to mitigate PowerShell's file locking issues.
    • Added logic to set file system access control lists (ACLs) to grant read access for 'Everyone' to the output file.
    • Updated conditional checks for VersionFilePath and InfoFilePath to include Test-Path.
  • python/private/py_executable.bzl
    • Replaced manual string formatting for the stage2_bootstrap path with a call to the runfiles_root_path function.
  • python/private/python_bootstrap_template.txt
    • Added verbose print statements for STAGE2_BOOTSTRAP, PYTHON_BINARY, PYTHON_BINARY_ACTUAL, IS_ZIPFILE, RECREATE_VENV_AT_RUNTIME, WORKSPACE_NAME, main_rel_path, and runfiles root.
    • Enhanced the error message when FindPythonBinary fails to include both PYTHON_BINARY and PYTHON_BINARY_ACTUAL for better debugging.
  • python/private/stage2_bootstrap_template.py
    • Added a comment indicating that BUILD_DATA_FILE uses forward slashes and requires conversion for Windows.
    • Implemented Windows-specific path conversion for rlocation_path and path using replace("/", "\\") and os.path.normpath.
    • Opened BUILD_DATA_FILE with encoding='utf-8-sig' to correctly handle Windows Byte Order Mark (BOM).
    • Enhanced exception handling to add notes about the rlocation_path, file existence, and readability when get_build_data fails.
  • tests/bootstrap_impls/BUILD.bazel
    • Loaded py_binary and py_test rules.
    • Added a new py_test target named system_python_nodeps_test configured to use the system_python bootstrap implementation.
  • tests/bootstrap_impls/system_python_nodeps_test.py
    • Added a simple Python script that prints 'Hello, world'.
  • tests/pypi/whl_installer/wheel_installer_test.py
    • Modified the tearDown method to use shutil.rmtree(..., ignore_errors=True) to prevent errors during directory deletion 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
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

This pull request adds a new test, system_python_nodeps_test, and introduces several valuable improvements for Windows compatibility and debuggability. The changes to the PowerShell script build_data_writer.ps1 and the Python bootstrap templates are particularly beneficial, enhancing the robustness of file writing and path handling. The adoption of .NET APIs for file operations and the more detailed exception information are excellent additions. I have one minor suggestion to improve code consistency.

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

Comments