Skip to content

chore: disable build_python_zip#3612

Draft
rickeylev wants to merge 10 commits intobazel-contrib:mainfrom
rickeylev:chore.disable.build.python.zip
Draft

chore: disable build_python_zip#3612
rickeylev wants to merge 10 commits intobazel-contrib:mainfrom
rickeylev:chore.disable.build.python.zip

Conversation

@rickeylev
Copy link
Collaborator

.bazelrc changes that disable --build_python_zip

DO NOT MERGE: await #3611

@rickeylev rickeylev marked this pull request as draft February 18, 2026 01:35
@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 refining Bazel build configurations for Python rules, with a significant emphasis on disabling implicit Python zip creation and improving Windows compatibility. It introduces a more robust mechanism for handling config_settings by recognizing and aliasing Bazel's internal command-line options, ensuring consistent behavior across different platforms and build scenarios. The changes also enhance the runfiles lookup process, making it more resilient to various build environments.

Highlights

  • Bazel Configuration Updates: The pull request disables the implicit Python zip creation (--build_python_zip) across the main .bazelrc file and numerous example/test .bazelrc files, addressing issue 3567.
  • Enhanced config_settings Handling: Introduced special handling for //command_line_option labels within config_settings to correctly map them to Bazel-builtin pseudo-targets. Default config_settings are now applied to py_binary and py_test rules, including enable_runfiles for Windows.
  • Improved Windows Compatibility: Several changes were made to enhance compatibility on Windows, including using .NET for file writing in PowerShell scripts, adjusting runfiles path handling, and adding error handling for file operations.
  • Runfiles Lookup Enhancements: The Python bootstrap template now includes logic to search for files within the runfiles manifest, improving the reliability of finding executables and main files, especially in complex runfiles environments.
  • New command_line_option Package: A new command_line_option package was added, defining aliases for Bazel's //command_line_option pseudo-targets, which are used in config_settings.

🧠 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
  • .bazelrc
    • Added flags to disable implicit Python zip creation (--build_python_zip=false and --@rules_python//python/config_settings:build_python_zip=false).
  • BUILD.bazel
    • Included //command_line_option:distribution in the distribution filegroup.
  • command_line_option/BUILD.bazel
    • Added a new BUILD file defining aliases for Bazel's //command_line_option pseudo-targets, such as build_runfile_links and enable_runfiles.
  • docs/api/rules_python/command_line_option/index.md
    • Added new documentation for the //command_line_option package.
  • examples/build_file_generation/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • examples/bzlmod/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • examples/multi_python_versions/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • examples/pip_parse/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • examples/pip_parse_vendored/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • examples/pip_repository_annotations/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • gazelle/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • gazelle/examples/bzlmod_build_file_generation/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • python/private/attributes.bzl
    • Added an important note about special handling for command_line_option labels in config_settings.
    • Modified apply_config_settings_attr to correctly process command_line_option package labels.
  • python/private/build_data_writer.ps1
    • Refactored file writing to use .NET WriteAllLines for improved Windows compatibility and added ACL setting for the output file.
  • python/private/common_labels.bzl
    • Added new labels for BUILD_RUNFILE_LINKS, ENABLE_RUNFILES, and PLATFORMS_OS_WINDOWS.
    • Reordered the PIP_ENV_MARKER_CONFIG label.
  • python/private/py_binary_macro.bzl
    • Replaced the direct call to convert_legacy_create_init_to_int with common_executable_macro_kwargs_setup.
  • python/private/py_executable.bzl
    • Updated _create_stage1_bootstrap to use runfiles_root_path for stage2_bootstrap paths.
    • Introduced add_config_setting_defaults to apply default config_settings, including enable_runfiles for Windows.
    • Created common_executable_macro_kwargs_setup to consolidate common macro keyword argument setup.
    • Updated _transition_executable_impl and create_executable_rule_builder to include build_runfile_links and enable_runfiles in transition inputs and outputs.
  • python/private/py_test_macro.bzl
    • Replaced the direct call to convert_legacy_create_init_to_int with common_executable_macro_kwargs_setup.
  • python/private/python_bootstrap_template.txt
    • Removed a comment about runfiles-relative path and added one for runfiles-root-relative path.
    • Added maybe_find_in_manifest function to search for files in the runfiles manifest.
    • Modified FindBinary to utilize maybe_find_in_manifest and improved error messages.
    • Added find_main_file to centralize main file lookup, incorporating manifest search.
    • Expanded verbose logging for bootstrap variables.
  • python/private/stage2_bootstrap_template.py
    • Added a comment regarding BUILD_DATA_FILE path conversion for Windows.
    • Modified get_build_data to handle Windows path separators, use utf-8-sig encoding, and include detailed error notes.
    • Added a comment to find_runfiles_root about --enable_runfiles=false.
  • tests/bootstrap_impls/BUILD.bazel
    • Loaded py_binary and py_test rules.
    • Added a new py_test target named system_python_nodeps_test.
  • tests/bootstrap_impls/system_python_nodeps_test.py
    • Added a simple Python script for testing purposes.
  • tests/build_data/BUILD.bazel
    • Added tags = ["manual"] to the tool_build_data genrule.
  • tests/integration/compile_pip_requirements/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • tests/integration/compile_pip_requirements_test_from_external_repo/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • tests/integration/local_toolchains/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • tests/integration/pip_parse/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • tests/integration/py_cc_toolchain_registered/.bazelrc
    • Added flags to disable implicit Python zip creation.
  • tests/pypi/whl_installer/wheel_installer_test.py
    • Modified tearDown to ignore errors when removing the wheel directory, specifically addressing Windows issues.
  • tests/support/py_reconfig.bzl
    • Removed direct iteration over config_settings in _perform_transition_impl.
    • Added build_runfile_links, extra_toolchains, and stamp to _RECONFIG_INPUTS.
Activity
  • The pull request includes .bazelrc changes to disable --build_python_zip.
  • The author has marked this PR with 'DO NOT MERGE: await fix: better bootstrap manifest handling #3611', indicating it is dependent on another issue or PR.
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 disables implicit Python zip creation by default across .bazelrc files and updates related configurations. A critical security concern was identified in a PowerShell script, where overly permissive file permissions granted to "Everyone" could lead to information leakage in shared build environments. Furthermore, while the supporting code changes are well-executed and improve robustness, especially for Windows, documentation for the new //command_line_option feature is suggested to enhance usability and maintainability.

Comment on lines 24 to 27
$Acl = Get-Acl $OutputPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Read", "Allow")
$Acl.SetAccessRule($AccessRule)
Set-Acl $OutputPath $Acl
Copy link
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The script explicitly sets the Access Control List (ACL) of the output build data file to allow "Everyone" read access. This is overly permissive and violates the Principle of Least Privilege. In a shared environment, such as a multi-user CI server or a shared development machine, any user on the system can read the contents of this file.

While the file primarily contains build metadata (target name, config mode, etc.), it also includes the contents of the workspace status files (VERSION_FILE and INFO_FILE). These files can contain sensitive information depending on the user's workspace status script configuration.

Consider removing this ACL change or using a more restrictive group such as "Authenticated Users" if explicit permissions are necessary.

$Acl = Get-Acl $OutputPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Authenticated Users", "Read", "Allow")
$Acl.SetAccessRule($AccessRule)
Set-Acl $OutputPath $Acl

Comment on lines +10 to +22
# todo: add docs, xref with config_settings
# rules_python target, config_setting processing code converts it to the
# Bazel-builtin //command_line_label:build_runfile_links psuedo-target
alias(
name = "build_runfile_links",
actual = "//python:none",
)

# todo: add docs
alias(
name = "enable_runfiles",
actual = "//python:none",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The new aliases build_runfile_links and enable_runfiles have todo: add docs comments. It would be beneficial to add this documentation as part of this PR to make the new feature easier for users to understand. The documentation could explain what these aliases are for, how they relate to the Bazel built-in command line options, and include a cross-reference to config_settings as noted in the comment.

Comment on lines +1 to +6
:::{default-domain} bzl
:::
:::{bzl:currentfile} //command_line_option:BUILD.bazel
:::

# //command_line_option
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This documentation file is currently a stub. It would be beneficial to expand it to document the new //command_line_option feature, including the available aliases and how to define custom ones. This would make the feature more discoverable and usable.

@rickeylev rickeylev force-pushed the chore.disable.build.python.zip branch from b806a1d to 9a93f27 Compare February 18, 2026 02:33
@rickeylev rickeylev force-pushed the chore.disable.build.python.zip branch 2 times, most recently from 8b335c5 to cf5e26c Compare February 18, 2026 02:34
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.

1 participant

Comments