@@ -55,7 +55,7 @@ func (*Resolver) Name() string { return languageName }
55
55
// If nil is returned, the rule will not be indexed. If any non-nil slice is
56
56
// returned, including an empty slice, the rule will be indexed.
57
57
func (py * Resolver ) Imports (c * config.Config , r * rule.Rule , f * rule.File ) []resolve.ImportSpec {
58
- if ! indexPyBinaryImport ( r , f ) {
58
+ if r . Kind () == "py_binary" {
59
59
return nil
60
60
}
61
61
cfgs := c .Exts [languageName ].(pythonconfig.Configs )
@@ -369,29 +369,3 @@ func convertDependencySetToExpr(set *treeset.Set) bzl.Expr {
369
369
}
370
370
return & bzl.ListExpr {List : deps }
371
371
}
372
-
373
- // indexPyBinaryImport returns whether the corresponding py_binary rule need to be indexed.
374
- // To avoid multiple labels indexing the same import,
375
- // check if there is a corresponding py_library rule with the same srcs.
376
- func indexPyBinaryImport (r * rule.Rule , f * rule.File ) bool {
377
- // If the rule is not a py_binary, it should be indexed.
378
- if r .Kind () != "py_binary" {
379
- return true
380
- }
381
- pyBinarySrcs := r .AttrStrings ("srcs" )
382
- if len (pyBinarySrcs ) == 0 {
383
- return false
384
- }
385
- for _ , otherRule := range f .Rules {
386
- if otherRule .Kind () != "py_library" {
387
- continue
388
- }
389
- pyLibrarySrcs := otherRule .AttrStrings ("srcs" )
390
- for _ , src := range pyLibrarySrcs {
391
- if src == pyBinarySrcs [0 ] {
392
- return false
393
- }
394
- }
395
- }
396
- return true
397
- }
0 commit comments