fix: make executable implicit defaults public so other modules can use rule builders#3919
Conversation
build_data_writer, debugger_if_target_config, and uncachable_version_file are added as implicit attrs to all py_binary/py_test targets via EXECUTABLE_ATTRS in 1.9.0. When an external package uses py_binary_rule_builder() to construct a custom rule, Bazel checks visibility of those attr defaults from the external package. These targets inherited the package default (//python/private:__subpackages__) making them inaccessible, causing a visibility error at analysis time. Set visibility = ["//visibility:public"] on the three targets.
a3f1a05 to
dd3f1f5
Compare
There was a problem hiding this comment.
Code Review
This pull request resolves a visibility issue where implicit attribute defaults used by py_binary_rule_builder() and py_test_rule_builder() were private to rules_python, causing analysis failures for external modules. The changes expose these targets as public and add regression tests. The review feedback suggests forwarding the visibility parameter to uncachable_version_file_impl to prevent failures when stamping is enabled, and cleaning up placeholder TODO(pr-number) comments in the test files.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
This looks great. Thanks for the fix! |
create_executable_rule_builder()(used bypy_binary_rule_builder()/py_test_rule_builder(), the publicpython/api/executables.bzlAPI)bundles three implicit attrs whose defaults point at private targets
under
//python/private:build_data_writer,debugger_if_target_config, anduncachable_version_file. Thesetargets had no explicit visibility, so they inherited the package's
default_visibility(//:__subpackages__), which only covers packagesinside the rules_python repo itself.
Because the builder API is designed to let external modules call
rule()themselves (viabuilder.build()), Bazel checks visibility ofthese attr defaults from the calling module's package, not from
rules_python's. Any external repo constructing a rule via
py_binary_rule_builder()/py_test_rule_builder()therefore fails atanalysis time with a visibility error.
This has been broken since the builder API's introduction; there's prior
art in this same file for exactly this situation (e.g.
stage1_bootstrap_template, among others)