Skip to content

Commit 443fd7c

Browse files
committed
Update
1 parent b1bd1e7 commit 443fd7c

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

gazelle/python/generate.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ var (
4848
buildFilenames = []string{"BUILD", "BUILD.bazel"}
4949
)
5050

51-
func GetActualKindName(kind string, c *config.Config) string {
52-
if kindOverride, ok := c.KindMap[kind]; ok {
51+
func GetActualKindName(kind string, args language.GenerateArgs) string {
52+
if kindOverride, ok := args.Config.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.Config)
94-
actualPyLibraryKind := GetActualKindName(pyLibraryKind, args.Config)
95-
actualPyTestKind := GetActualKindName(pyTestKind, args.Config)
93+
actualPyBinaryKind := GetActualKindName(pyBinaryKind, args)
94+
actualPyLibraryKind := GetActualKindName(pyLibraryKind, args)
95+
actualPyTestKind := GetActualKindName(pyTestKind, args)
9696

9797
pythonProjectRoot := cfg.PythonProjectRoot()
9898

@@ -123,7 +123,6 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
123123
pyFileNames.Add(f)
124124
if !hasPyBinaryEntryPointFile && f == pyBinaryEntrypointFilename {
125125
hasPyBinaryEntryPointFile = true
126-
pyLibraryFilenames.Add(f)
127126
} else if !hasPyTestEntryPointFile && f == pyTestEntrypointFilename {
128127
hasPyTestEntryPointFile = true
129128
} else if f == conftestFilename {
@@ -248,9 +247,9 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
248247

249248
// Remove the file from srcs if we're doing per-file library generation so
250249
// that we don't also generate a py_library target for it.
251-
// if cfg.PerFileGeneration() {
252-
// srcs.Remove(name)
253-
// }
250+
if cfg.PerFileGeneration() {
251+
srcs.Remove(name)
252+
}
254253
}
255254
sort.Strings(mainFileNames)
256255
for _, filename := range mainFileNames {
@@ -353,7 +352,6 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes
353352
collisionErrors.Add(err)
354353
}
355354

356-
// Create the py_binary target that depends on the py_library
357355
pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames).
358356
setMain(pyBinaryEntrypointFilename).
359357
addVisibility(visibility).

gazelle/python/resolve.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ func (*Resolver) Name() string { return languageName }
5757
func (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-
}
6560
srcs := r.AttrStrings("srcs")
6661
provides := make([]resolve.ImportSpec, 0, len(srcs)+1)
6762
for _, src := range srcs {

0 commit comments

Comments
 (0)