Skip to content

generate: python adds libraries for sources rules_dx binaries, tests or exports_files already own (part of #9237) #9333

Closed

Description

@TrapsterDK

Problem

On main (9a01083), bazel run //dx:generate_check proposes:

  • tools/docs/rule_names/BUILD.bazel: a new python_library(name = "rule_names", srcs = ["rule_names.py"]), although rule_names.py is already the main/srcs of the hand-written python_binary rule_names_bin and python_test rule_names_test.
  • python/rules/BUILD.bazel: a new python_library(name = "grpc_protoc") for grpc_protoc.py, which the package only exports with exports_files.
  • python/tests/BUILD.bazel and python/tests/sdist_native/msvc/BUILD.bazel: testonly = True on existing python_test rules. Tests are already testonly, so this adds nothing.

Where

  • gazelle/python/lang.go:465-485 foreignKinds/foreignSources: only rules_py/rules_python kinds count as owners.
  • gazelle/python/lang.go:341-376: makes a library plan for every unowned source.
  • gazelle/python/lang.go:385-387: FixtureTestonly sets testonly on every generated rule, test kinds included.

Fix

  1. Treat a source as owned when it is in srcs or main of an existing rules_dx python_binary/python_test that the generator did not produce for that file, or when it is listed in exports_files. Do not plan a library for an owned source.
  2. Skip testonly for testKind.
    Add one test per fix in gazelle/python/lang_test.go.

Done when

bazel run //dx:generate_check shows no change to these four BUILD files.

Activity

  1. added
    P2Improve and finish existing features
    model:sonnetAgent lane: scoped change with stated design, Sonnet
    on Nov 7, 2026
  2. TrapsterDK commented on Nov 7, 2026

    @TrapsterDK
    CollaboratorAuthor

    Fixed on origin/main: #9336 (owned-source skip, no testonly on tests) and #9338 (applied the remaining generate diff for imports and python/rules). bazel run //dx:generate_check on current origin/main exits 0 with no change to the four BUILD files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Improve and finish existing featuresmodel:sonnetAgent lane: scoped change with stated design, Sonnet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions