File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 4848 buildFilenames = []string {"BUILD" , "BUILD.bazel" }
4949)
5050
51- func GetActualKindName (kind string , args language. GenerateArgs ) string {
52- if kindOverride , ok := args . Config .KindMap [kind ]; ok {
51+ func GetActualKindName (kind string , c * config. Config ) string {
52+ if kindOverride , ok := c .KindMap [kind ]; ok {
5353 return kindOverride .KindName
5454 }
5555 return kind
@@ -90,9 +90,9 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
9090 }
9191 }
9292
93- actualPyBinaryKind := GetActualKindName (pyBinaryKind , args )
94- actualPyLibraryKind := GetActualKindName (pyLibraryKind , args )
95- actualPyTestKind := GetActualKindName (pyTestKind , args )
93+ actualPyBinaryKind := GetActualKindName (pyBinaryKind , args . Config )
94+ actualPyLibraryKind := GetActualKindName (pyLibraryKind , args . Config )
95+ actualPyTestKind := GetActualKindName (pyTestKind , args . Config )
9696
9797 pythonProjectRoot := cfg .PythonProjectRoot ()
9898
Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ func (*Resolver) Name() string { return languageName }
5757func (py * Resolver ) Imports (c * config.Config , r * rule.Rule , f * rule.File ) []resolve.ImportSpec {
5858 cfgs := c .Exts [languageName ].(pythonconfig.Configs )
5959 cfg := cfgs [f .Pkg ]
60+ if ! cfg .PerFileGeneration () && GetActualKindName (r .Kind (), c ) == pyBinaryKind {
61+ // Don't index py_binary in except in file mode, because all non-test Python files
62+ // are in py_library already.
63+ return nil
64+ }
6065 srcs := r .AttrStrings ("srcs" )
6166 provides := make ([]resolve.ImportSpec , 0 , len (srcs )+ 1 )
6267 for _ , src := range srcs {
You can’t perform that action at this time.
0 commit comments