From 1eea0a93d33b53e39c2b7653b8e7da7065eb5611 Mon Sep 17 00:00:00 2001 From: Mathieu Sabourin Date: Fri, 7 Apr 2023 23:52:41 -0700 Subject: [PATCH 1/8] fix: respect kind mapping (#1158) When using the kind `gazelle:map_kind` directive, `gazelle` will correctly generate the buildfile on the first pass (or if no target of that type / name are present). However, when running gazelle a second time (or if a target of the mapped kind with the same name is present), `gazelle` will error out saying that it kind create a target of the original kind because a target of mapped kind is present and has the same name. Ex: Given the directive `# gazelle:map_kind py_test py_pytest_test //src/bazel/rules/python:py_pytest_test.bzl`, `gazelle` will correctly generate a `py_pytest_test` target where it would have generated a `py_test` target. But on a second invocation of `gazelle` (and subsequent invocations) it will error our with: ``` gazelle: ERROR: failed to generate target "//test/python/common:common_test" of kind "py_test": a target of kind "py_pytest_test" with the same name already exists. Use the '# gazelle:python_test_naming_convention' directive to change the naming convention. ``` --- gazelle/generate.go | 44 +++++++++++++++---- .../testdata/respect_kind_mapping/BUILD.in | 15 +++++++ .../testdata/respect_kind_mapping/BUILD.out | 20 +++++++++ .../testdata/respect_kind_mapping/README.md | 3 ++ .../testdata/respect_kind_mapping/WORKSPACE | 1 + .../testdata/respect_kind_mapping/__init__.py | 17 +++++++ .../testdata/respect_kind_mapping/__test__.py | 26 +++++++++++ .../testdata/respect_kind_mapping/foo.py | 16 +++++++ .../testdata/respect_kind_mapping/test.yaml | 17 +++++++ 9 files changed, 150 insertions(+), 9 deletions(-) create mode 100644 gazelle/python/testdata/respect_kind_mapping/BUILD.in create mode 100644 gazelle/python/testdata/respect_kind_mapping/BUILD.out create mode 100644 gazelle/python/testdata/respect_kind_mapping/README.md create mode 100644 gazelle/python/testdata/respect_kind_mapping/WORKSPACE create mode 100644 gazelle/python/testdata/respect_kind_mapping/__init__.py create mode 100644 gazelle/python/testdata/respect_kind_mapping/__test__.py create mode 100644 gazelle/python/testdata/respect_kind_mapping/foo.py create mode 100644 gazelle/python/testdata/respect_kind_mapping/test.yaml diff --git a/gazelle/generate.go b/gazelle/generate.go index 077acb821a..9d9bb2f22f 100644 --- a/gazelle/generate.go +++ b/gazelle/generate.go @@ -26,12 +26,20 @@ const ( pyBinaryEntrypointFilename = "__main__.py" pyTestEntrypointFilename = "__test__.py" pyTestEntrypointTargetname = "__test__" + conftestTargetname = "conftest.py" ) var ( buildFilenames = []string{"BUILD", "BUILD.bazel"} ) +func GetActualKindName(kind string, args language.GenerateArgs) string { + if kindOverride, ok := args.Config.KindMap[kind]; ok { + return kindOverride.KindName + } + return kind +} + // GenerateRules extracts build metadata from source files in a directory. // GenerateRules is called in each directory where an update is requested // in depth-first post-order. @@ -56,6 +64,10 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } } + actualPyBinaryKind := GetActualKindName(pyBinaryKind, args) + actualPyLibraryKind := GetActualKindName(pyLibraryKind, args) + actualPyTestKind := GetActualKindName(pyTestKind, args) + pythonProjectRoot := cfg.PythonProjectRoot() packageName := filepath.Base(args.Dir) @@ -202,12 +214,12 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes // correctly. if args.File != nil { for _, t := range args.File.Rules { - if t.Name() == pyLibraryTargetName && t.Kind() != pyLibraryKind { + if t.Name() == pyLibraryTargetName && t.Kind() != actualPyLibraryKind { fqTarget := label.New("", args.Rel, pyLibraryTargetName) err := fmt.Errorf("failed to generate target %q of kind %q: "+ "a target of kind %q with the same name already exists. "+ "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), pyLibraryKind, t.Kind(), pythonconfig.LibraryNamingConvention) + fqTarget.String(), actualPyLibraryKind, t.Kind(), pythonconfig.LibraryNamingConvention) collisionErrors.Add(err) } } @@ -239,12 +251,12 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes // correctly. if args.File != nil { for _, t := range args.File.Rules { - if t.Name() == pyBinaryTargetName && t.Kind() != pyBinaryKind { + if t.Name() == pyBinaryTargetName && t.Kind() != actualPyBinaryKind { fqTarget := label.New("", args.Rel, pyBinaryTargetName) err := fmt.Errorf("failed to generate target %q of kind %q: "+ "a target of kind %q with the same name already exists. "+ "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), pyBinaryKind, t.Kind(), pythonconfig.BinaryNamingConvention) + fqTarget.String(), actualPyBinaryKind, t.Kind(), pythonconfig.BinaryNamingConvention) collisionErrors.Add(err) } } @@ -278,7 +290,21 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes log.Fatalf("ERROR: %v\n", err) } - pyTestTargetName := cfg.RenderTestName(packageName) + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. + if args.File != nil { + for _, t := range args.File.Rules { + if t.Name() == conftestTargetname && t.Kind() != actualPyLibraryKind { + fqTarget := label.New("", args.Rel, conftestTargetname) + err := fmt.Errorf("failed to generate target %q of kind %q: "+ + "a target of kind %q with the same name already exists.", + fqTarget.String(), actualPyLibraryKind, t.Kind()) + collisionErrors.Add(err) + } + } + } // Check if a target with the same name we are generating alredy exists, // and if it is of a different kind from the one we are generating. If @@ -286,18 +312,18 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes // correctly. if args.File != nil { for _, t := range args.File.Rules { - if t.Name() == pyTestTargetName && t.Kind() != pyTestKind { - fqTarget := label.New("", args.Rel, pyTestTargetName) + if t.Name() == pyTestEntrypointFilename && t.Kind() != actualPyTestKind { + fqTarget := label.New("", args.Rel, pyTestEntrypointFilename) err := fmt.Errorf("failed to generate target %q of kind %q: "+ "a target of kind %q with the same name already exists. "+ "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), pyTestKind, t.Kind(), pythonconfig.TestNamingConvention) + fqTarget.String(), actualPyTestKind, t.Kind(), pythonconfig.TestNamingConvention) collisionErrors.Add(err) } } } - pyTestTarget := newTargetBuilder(pyTestKind, pyTestTargetName, pythonProjectRoot, args.Rel). + pyTestTarget := newTargetBuilder(pyTestKind, pyTestEntrypointFilename, pythonProjectRoot, args.Rel). addSrcs(pyTestFilenames). addModuleDependencies(deps). generateImportsAttribute() diff --git a/gazelle/python/testdata/respect_kind_mapping/BUILD.in b/gazelle/python/testdata/respect_kind_mapping/BUILD.in new file mode 100644 index 0000000000..6a06737623 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/BUILD.in @@ -0,0 +1,15 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:map_kind py_test my_test :mytest.bzl + +py_library( + name = "respect_kind_mapping", + srcs = ["__init__.py"], +) + +my_test( + name = "respect_kind_mapping_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [":respect_kind_mapping"], +) diff --git a/gazelle/python/testdata/respect_kind_mapping/BUILD.out b/gazelle/python/testdata/respect_kind_mapping/BUILD.out new file mode 100644 index 0000000000..7c5fb0bd20 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/BUILD.out @@ -0,0 +1,20 @@ +load(":mytest.bzl", "my_test") +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:map_kind py_test my_test :mytest.bzl + +py_library( + name = "respect_kind_mapping", + srcs = [ + "__init__.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +my_test( + name = "respect_kind_mapping_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [":respect_kind_mapping"], +) diff --git a/gazelle/python/testdata/respect_kind_mapping/README.md b/gazelle/python/testdata/respect_kind_mapping/README.md new file mode 100644 index 0000000000..9f0fa6cf39 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/README.md @@ -0,0 +1,3 @@ +# Respect Kind Mapping + +This test case asserts that when using a kind mapping, gazelle will respect that mapping when parsing a BUILD file containing a mapped kind. diff --git a/gazelle/python/testdata/respect_kind_mapping/WORKSPACE b/gazelle/python/testdata/respect_kind_mapping/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/respect_kind_mapping/__init__.py b/gazelle/python/testdata/respect_kind_mapping/__init__.py new file mode 100644 index 0000000000..b274b0d921 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from foo import foo + +_ = foo diff --git a/gazelle/python/testdata/respect_kind_mapping/__test__.py b/gazelle/python/testdata/respect_kind_mapping/__test__.py new file mode 100644 index 0000000000..2b180a5f53 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/__test__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from __init__ import foo + + +class FooTest(unittest.TestCase): + def test_foo(self): + self.assertEqual("foo", foo()) + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/respect_kind_mapping/foo.py b/gazelle/python/testdata/respect_kind_mapping/foo.py new file mode 100644 index 0000000000..932de45b74 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/foo.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def foo(): + return "foo" diff --git a/gazelle/python/testdata/respect_kind_mapping/test.yaml b/gazelle/python/testdata/respect_kind_mapping/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/respect_kind_mapping/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 From df919d7678b5eaaeb51d272c93d00639e5eeb2d4 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 04:55:02 +0000 Subject: [PATCH 2/8] Bugfix: Try removing entrypoint target dependency from rule generation --- gazelle/generate.go | 1 - 1 file changed, 1 deletion(-) diff --git a/gazelle/generate.go b/gazelle/generate.go index 9d9bb2f22f..dd5eadfb0a 100644 --- a/gazelle/generate.go +++ b/gazelle/generate.go @@ -333,7 +333,6 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes main := fmt.Sprintf(":%s", pyTestEntrypointFilename) pyTestTarget. addSrc(entrypointTarget). - addResolvedDependency(entrypointTarget). setMain(main) } else { pyTestTarget.setMain(pyTestEntrypointFilename) From adeec048c33e022d7ce3cbbf332e5c280194b230 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 05:12:50 +0000 Subject: [PATCH 3/8] Try even more aggressive gazelle updates --- gazelle/generate.go | 84 ++++++++++++++++++++++++++++++++------------- gazelle/target.go | 57 ++++++++++++++++++++---------- 2 files changed, 99 insertions(+), 42 deletions(-) diff --git a/gazelle/generate.go b/gazelle/generate.go index dd5eadfb0a..43000c8ae8 100644 --- a/gazelle/generate.go +++ b/gazelle/generate.go @@ -16,7 +16,6 @@ import ( "github.com/emirpasic/gods/lists/singlylinkedlist" "github.com/emirpasic/gods/sets/treeset" godsutils "github.com/emirpasic/gods/utils" - "github.com/google/uuid" "github.com/bazelbuild/rules_python/gazelle/pythonconfig" ) @@ -26,7 +25,8 @@ const ( pyBinaryEntrypointFilename = "__main__.py" pyTestEntrypointFilename = "__test__.py" pyTestEntrypointTargetname = "__test__" - conftestTargetname = "conftest.py" + conftestFilename = "conftest.py" + conftestTargetname = "conftest" ) var ( @@ -74,6 +74,7 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes pyLibraryFilenames := treeset.NewWith(godsutils.StringComparator) pyTestFilenames := treeset.NewWith(godsutils.StringComparator) + pyFileNames := treeset.NewWith(godsutils.StringComparator) // hasPyBinary controls whether a py_binary target should be generated for // this package or not. @@ -83,16 +84,23 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes // be generated for this package or not. hasPyTestFile := false hasPyTestTarget := false + hasConftestFile := false for _, f := range args.RegularFiles { if cfg.IgnoresFile(filepath.Base(f)) { continue } + ext := filepath.Ext(f) + if ext == ".py" { + pyFileNames.Add(f) + } if !hasPyBinary && f == pyBinaryEntrypointFilename { hasPyBinary = true } else if !hasPyTestFile && f == pyTestEntrypointFilename { hasPyTestFile = true + } else if !hasConftestFile && f == conftestTargetname { + hasConftestFile = true } else if strings.HasSuffix(f, "_test.py") || (strings.HasPrefix(f, "test_") && ext == ".py") { pyTestFilenames.Add(f) } else if ext == ".py" { @@ -225,8 +233,7 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } } - pyLibrary = newTargetBuilder(pyLibraryKind, pyLibraryTargetName, pythonProjectRoot, args.Rel). - setUUID(uuid.Must(uuid.NewUUID()).String()). + pyLibrary = newTargetBuilder(pyLibraryKind, pyLibraryTargetName, pythonProjectRoot, args.Rel, pyFileNames). addVisibility(visibility). addSrcs(pyLibraryFilenames). addModuleDependencies(deps). @@ -262,7 +269,7 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } } - pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel). + pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames). setMain(pyBinaryEntrypointFilename). addVisibility(visibility). addSrc(pyBinaryEntrypointFilename). @@ -279,13 +286,9 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes result.Imports = append(result.Imports, pyBinary.PrivateAttr(config.GazelleImportsKey)) } - if hasPyTestFile || hasPyTestTarget { - if hasPyTestFile { - // Only add the pyTestEntrypointFilename to the pyTestFilenames if - // the file exists on disk. - pyTestFilenames.Add(pyTestEntrypointFilename) - } - deps, err := parser.parse(pyTestFilenames) + var conftest *rule.Rule + if hasConftestFile { + deps, err := parser.parseSingle(conftestFilename) if err != nil { log.Fatalf("ERROR: %v\n", err) } @@ -306,14 +309,33 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } } - // Check if a target with the same name we are generating alredy exists, - // and if it is of a different kind from the one we are generating. If - // so, we have to throw an error since Gazelle won't generate it - // correctly. + conftestTarget := newTargetBuilder(pyLibraryKind, conftestTargetname, pythonProjectRoot, args.Rel, pyFileNames). + addSrc(conftestFilename). + addModuleDependencies(deps). + addVisibility(visibility). + setTestonly(). + generateImportsAttribute() + + conftest = conftestTarget.build() + + result.Gen = append(result.Gen, conftest) + result.Imports = append(result.Imports, conftest.PrivateAttr(config.GazelleImportsKey)) + } + + var pyTestTargets []*targetBuilder + newPyTestTargetBuilder := func(srcs *treeset.Set, pyTestTargetName string) *targetBuilder { + deps, err := parser.parse(srcs) + if err != nil { + log.Fatalf("ERROR: %v\n", err) + } + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. if args.File != nil { for _, t := range args.File.Rules { - if t.Name() == pyTestEntrypointFilename && t.Kind() != actualPyTestKind { - fqTarget := label.New("", args.Rel, pyTestEntrypointFilename) + if t.Name() == pyTestTargetName && t.Kind() != actualPyTestKind { + fqTarget := label.New("", args.Rel, pyTestTargetName) err := fmt.Errorf("failed to generate target %q of kind %q: "+ "a target of kind %q with the same name already exists. "+ "Use the '# gazelle:%s' directive to change the naming convention.", @@ -322,26 +344,40 @@ func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateRes } } } - - pyTestTarget := newTargetBuilder(pyTestKind, pyTestEntrypointFilename, pythonProjectRoot, args.Rel). - addSrcs(pyTestFilenames). + return newTargetBuilder(pyTestKind, pyTestTargetName, pythonProjectRoot, args.Rel, pyFileNames). + addSrcs(srcs). addModuleDependencies(deps). generateImportsAttribute() + } + if hasPyTestTarget { + + pyTestTargetName := cfg.RenderTestName(packageName) + pyTestTarget := newPyTestTargetBuilder(pyTestFilenames, pyTestTargetName) if hasPyTestTarget { entrypointTarget := fmt.Sprintf(":%s", pyTestEntrypointTargetname) main := fmt.Sprintf(":%s", pyTestEntrypointFilename) pyTestTarget. addSrc(entrypointTarget). + addResolvedDependency(entrypointTarget). setMain(main) } else { pyTestTarget.setMain(pyTestEntrypointFilename) } + pyTestTargets = append(pyTestTargets, pyTestTarget) + } else { + // Create one py_test target per file + pyTestFilenames.Each(func(index int, testFile interface{}) { + srcs := treeset.NewWith(godsutils.StringComparator, testFile) + pyTestTargetName := strings.TrimSuffix(filepath.Base(testFile.(string)), ".py") + pyTestTargets = append(pyTestTargets, newPyTestTargetBuilder(srcs, pyTestTargetName)) + }) + } - if pyLibrary != nil { - pyTestTarget.addModuleDependency(module{Name: pyLibrary.PrivateAttr(uuidKey).(string)}) + for _, pyTestTarget := range pyTestTargets { + if conftest != nil { + pyTestTarget.addModuleDependency(module{Name: strings.TrimSuffix(conftestFilename, ".py")}) } - pyTest := pyTestTarget.build() result.Gen = append(result.Gen, pyTest) diff --git a/gazelle/target.go b/gazelle/target.go index 2b260679b6..2b41248cc2 100644 --- a/gazelle/target.go +++ b/gazelle/target.go @@ -1,12 +1,25 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package python import ( - "path/filepath" - "github.com/bazelbuild/bazel-gazelle/config" "github.com/bazelbuild/bazel-gazelle/rule" "github.com/emirpasic/gods/sets/treeset" godsutils "github.com/emirpasic/gods/utils" + "path/filepath" ) // targetBuilder builds targets to be generated by Gazelle. @@ -15,38 +28,31 @@ type targetBuilder struct { name string pythonProjectRoot string bzlPackage string - uuid string srcs *treeset.Set + siblingSrcs *treeset.Set deps *treeset.Set resolvedDeps *treeset.Set visibility *treeset.Set main *string imports []string + testonly bool } // newTargetBuilder constructs a new targetBuilder. -func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string) *targetBuilder { +func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string, siblingSrcs *treeset.Set) *targetBuilder { return &targetBuilder{ kind: kind, name: name, pythonProjectRoot: pythonProjectRoot, bzlPackage: bzlPackage, srcs: treeset.NewWith(godsutils.StringComparator), + siblingSrcs: siblingSrcs, deps: treeset.NewWith(moduleComparator), resolvedDeps: treeset.NewWith(godsutils.StringComparator), visibility: treeset.NewWith(godsutils.StringComparator), } } -// setUUID sets the given UUID for the target. It's used to index the generated -// target based on this value in addition to the other ways the targets can be -// imported. py_{binary,test} targets in the same Bazel package can add a -// virtual dependency to this UUID that gets resolved in the Resolver interface. -func (t *targetBuilder) setUUID(uuid string) *targetBuilder { - t.uuid = uuid - return t -} - // addSrc adds a single src to the target. func (t *targetBuilder) addSrc(src string) *targetBuilder { t.srcs.Add(src) @@ -64,6 +70,15 @@ func (t *targetBuilder) addSrcs(srcs *treeset.Set) *targetBuilder { // addModuleDependency adds a single module dep to the target. func (t *targetBuilder) addModuleDependency(dep module) *targetBuilder { + fileName := dep.Name + ".py" + if dep.From != "" { + fileName = dep.From + ".py" + } + if t.siblingSrcs.Contains(fileName) && fileName != filepath.Base(dep.Filepath) { + // importing another module from the same package, converting to absolute imports to make + // dependency resolution easier + dep.Name = importSpecFromSrc(t.pythonProjectRoot, t.bzlPackage, fileName).Imp + } t.deps.Add(dep) return t } @@ -72,7 +87,7 @@ func (t *targetBuilder) addModuleDependency(dep module) *targetBuilder { func (t *targetBuilder) addModuleDependencies(deps *treeset.Set) *targetBuilder { it := deps.Iterator() for it.Next() { - t.deps.Add(it.Value().(module)) + t.addModuleDependency(it.Value().(module)) } return t } @@ -96,6 +111,12 @@ func (t *targetBuilder) setMain(main string) *targetBuilder { return t } +// setTestonly sets the testonly attribute to true. +func (t *targetBuilder) setTestonly() *targetBuilder { + t.testonly = true + return t +} + // generateImportsAttribute generates the imports attribute. // These are a list of import directories to be added to the PYTHONPATH. In our // case, the value we add is on Bazel sub-packages to be able to perform imports @@ -113,9 +134,6 @@ func (t *targetBuilder) generateImportsAttribute() *targetBuilder { // build returns the assembled *rule.Rule for the target. func (t *targetBuilder) build() *rule.Rule { r := rule.NewRule(t.kind, t.name) - if t.uuid != "" { - r.SetPrivateAttr(uuidKey, t.uuid) - } if !t.srcs.Empty() { r.SetAttr("srcs", t.srcs.Values()) } @@ -131,6 +149,9 @@ func (t *targetBuilder) build() *rule.Rule { if !t.deps.Empty() { r.SetPrivateAttr(config.GazelleImportsKey, t.deps) } + if t.testonly { + r.SetAttr("testonly", true) + } r.SetPrivateAttr(resolvedDepsKey, t.resolvedDeps) return r -} +} \ No newline at end of file From e9648e26802066c1f89780c6b765a8c645933968 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 05:15:07 +0000 Subject: [PATCH 4/8] Update gazelle plugin to latest --- gazelle/.bazelrc | 13 + gazelle/.gitignore | 12 + gazelle/BUILD.bazel | 94 +- gazelle/MODULE.bazel | 20 + gazelle/README.md | 139 +- gazelle/WORKSPACE | 47 + gazelle/def.bzl | 18 +- gazelle/deps.bzl | 79 +- gazelle/go.mod | 17 + gazelle/go.sum | 92 + gazelle/manifest/BUILD.bazel | 10 + gazelle/manifest/defs.bzl | 112 +- gazelle/manifest/generate/BUILD.bazel | 15 +- gazelle/manifest/generate/generate.go | 68 +- gazelle/manifest/hasher/BUILD.bazel | 20 + gazelle/manifest/hasher/main.go | 44 + gazelle/manifest/manifest.go | 62 +- gazelle/manifest/manifest_test.go | 37 +- gazelle/manifest/test/BUILD.bazel | 20 +- gazelle/manifest/test/test.go | 73 +- gazelle/manifest/testdata/gazelle_python.yaml | 2 +- gazelle/modules_mapping/BUILD.bazel | 6 + gazelle/modules_mapping/def.bzl | 26 +- gazelle/modules_mapping/generator.py | 105 +- gazelle/python/BUILD.bazel | 79 + gazelle/python/configure.go | 178 ++ gazelle/python/fix.go | 27 + gazelle/python/generate.go | 444 +++++ gazelle/python/kinds.go | 102 + gazelle/python/language.go | 32 + gazelle/python/parse.py | 106 ++ gazelle/python/parser.go | 277 +++ gazelle/python/python_test.go | 206 ++ gazelle/python/resolve.go | 304 +++ gazelle/python/std_modules.go | 112 ++ gazelle/python/std_modules.py | 51 + gazelle/python/target.go | 157 ++ gazelle/python/testdata/README.md | 12 + .../dependency_resolution_order/BUILD.in | 1 + .../dependency_resolution_order/BUILD.out | 14 + .../dependency_resolution_order/README.md | 7 + .../dependency_resolution_order/WORKSPACE | 1 + .../dependency_resolution_order/__init__.py | 24 + .../dependency_resolution_order/bar/BUILD.in | 0 .../dependency_resolution_order/bar/BUILD.out | 8 + .../bar/__init__.py | 17 + .../dependency_resolution_order/baz/BUILD.in | 0 .../dependency_resolution_order/baz/BUILD.out | 8 + .../baz/__init__.py | 17 + .../dependency_resolution_order/foo/BUILD.in | 0 .../dependency_resolution_order/foo/BUILD.out | 8 + .../foo/__init__.py | 17 + .../gazelle_python.yaml | 18 + .../somewhere/bar/BUILD.in | 0 .../somewhere/bar/BUILD.out | 8 + .../somewhere/bar/__init__.py | 17 + .../dependency_resolution_order/test.yaml | 15 + .../BUILD.in | 1 + .../BUILD.out | 9 + .../README.md | 3 + .../WORKSPACE | 1 + .../__init__.py | 17 + .../test.yaml | 17 + .../testdata/dont_rename_target/BUILD.in | 5 + .../testdata/dont_rename_target/BUILD.out | 7 + .../testdata/dont_rename_target/README.md | 4 + .../testdata/dont_rename_target/WORKSPACE | 1 + .../testdata/dont_rename_target/__init__.py | 14 + .../testdata/dont_rename_target/test.yaml | 15 + .../BUILD.in | 0 .../BUILD.out | 11 + .../README.md | 4 + .../WORKSPACE | 1 + .../__init__.py | 15 + .../gazelle_python.yaml | 18 + .../rest_framework.py | 17 + .../test.yaml | 15 + .../first_party_dependencies/BUILD.in | 0 .../first_party_dependencies/BUILD.out | 0 .../first_party_dependencies/README.md | 11 + .../first_party_dependencies/WORKSPACE | 1 + .../first_party_dependencies/one/BUILD.in | 1 + .../first_party_dependencies/one/BUILD.out | 15 + .../first_party_dependencies/one/__main__.py | 26 + .../first_party_dependencies/one/bar/BUILD.in | 10 + .../one/bar/BUILD.out | 11 + .../one/bar/__init__.py | 19 + .../one/bar/baz/BUILD.in | 10 + .../one/bar/baz/BUILD.out | 11 + .../one/bar/baz/__init__.py | 19 + .../first_party_dependencies/one/foo/BUILD.in | 11 + .../one/foo/BUILD.out | 12 + .../one/foo/__init__.py | 19 + .../first_party_dependencies/test.yaml | 15 + .../first_party_dependencies/three/BUILD.in | 1 + .../first_party_dependencies/three/BUILD.out | 14 + .../three/__init__.py | 24 + .../first_party_dependencies/two/BUILD.in | 1 + .../first_party_dependencies/two/BUILD.out | 10 + .../first_party_dependencies/two/__init__.py | 20 + .../BUILD.in | 1 + .../BUILD.out | 25 + .../README.md | 9 + .../WORKSPACE | 1 + .../__main__.py | 25 + .../baz.py | 16 + .../foo.py | 16 + .../foo/BUILD.in | 0 .../foo/BUILD.out | 12 + .../foo/__init__.py | 15 + .../foo/bar.py | 21 + .../one/BUILD.in | 0 .../one/BUILD.out | 11 + .../one/__init__.py | 15 + .../one/two.py | 16 + .../test.yaml | 15 + .../undiscoverable/BUILD.in | 1 + .../undiscoverable/BUILD.out | 1 + .../package1/subpackage1/BUILD.in | 12 + .../package1/subpackage1/BUILD.out | 12 + .../package1/subpackage1/__init__.py | 15 + .../package1/subpackage1/module1.py | 16 + gazelle/python/testdata/from_imports/BUILD.in | 1 + .../python/testdata/from_imports/BUILD.out | 1 + .../python/testdata/from_imports/README.md | 7 + .../python/testdata/from_imports/WORKSPACE | 1 + .../python/testdata/from_imports/foo/BUILD.in | 1 + .../testdata/from_imports/foo/BUILD.out | 8 + .../testdata/from_imports/foo/__init__.py | 15 + .../testdata/from_imports/foo/bar/BUILD.in | 21 + .../testdata/from_imports/foo/bar/BUILD.out | 21 + .../testdata/from_imports/foo/bar/__init__.py | 15 + .../testdata/from_imports/foo/bar/baz.py | 15 + .../testdata/from_imports/gazelle_python.yaml | 19 + .../from_imports/import_from_init_py/BUILD.in | 0 .../import_from_init_py/BUILD.out | 9 + .../import_from_init_py/__init__.py | 16 + .../import_from_multiple/BUILD.in | 0 .../import_from_multiple/BUILD.out | 12 + .../import_from_multiple/__init__.py | 16 + .../from_imports/import_nested_file/BUILD.in | 0 .../from_imports/import_nested_file/BUILD.out | 9 + .../import_nested_file/__init__.py | 16 + .../import_nested_module/BUILD.in | 0 .../import_nested_module/BUILD.out | 9 + .../import_nested_module/__init__.py | 16 + .../from_imports/import_nested_var/BUILD.in | 0 .../from_imports/import_nested_var/BUILD.out | 9 + .../import_nested_var/__init__.py | 16 + .../import_top_level_var/BUILD.in | 0 .../import_top_level_var/BUILD.out | 9 + .../import_top_level_var/__init__.py | 16 + .../testdata/from_imports/std_module/BUILD.in | 0 .../from_imports/std_module/BUILD.out | 8 + .../from_imports/std_module/__init__.py | 17 + .../python/testdata/from_imports/test.yaml | 15 + .../generated_test_entrypoint/BUILD.in | 10 + .../generated_test_entrypoint/BUILD.out | 21 + .../generated_test_entrypoint/README.md | 4 + .../generated_test_entrypoint/WORKSPACE | 1 + .../generated_test_entrypoint/__init__.py | 17 + .../testdata/generated_test_entrypoint/foo.py | 16 + .../generated_test_entrypoint/test.yaml | 15 + .../ignored_invalid_imported_module/BUILD.in | 0 .../ignored_invalid_imported_module/BUILD.out | 8 + .../ignored_invalid_imported_module/README.md | 3 + .../ignored_invalid_imported_module/WORKSPACE | 1 + .../__init__.py | 36 + .../gazelle_python.yaml | 18 + .../ignored_invalid_imported_module/test.yaml | 17 + .../testdata/invalid_annotation/BUILD.in | 0 .../testdata/invalid_annotation/BUILD.out | 0 .../testdata/invalid_annotation/README.md | 2 + .../testdata/invalid_annotation/WORKSPACE | 1 + .../testdata/invalid_annotation/__init__.py | 15 + .../testdata/invalid_annotation/test.yaml | 19 + .../testdata/invalid_imported_module/BUILD.in | 0 .../invalid_imported_module/BUILD.out | 0 .../invalid_imported_module/README.md | 3 + .../invalid_imported_module/WORKSPACE | 1 + .../invalid_imported_module/__init__.py | 22 + .../invalid_imported_module/test.yaml | 22 + gazelle/python/testdata/monorepo/BUILD.in | 1 + gazelle/python/testdata/monorepo/BUILD.out | 1 + gazelle/python/testdata/monorepo/README.md | 4 + gazelle/python/testdata/monorepo/WORKSPACE | 1 + gazelle/python/testdata/monorepo/a/BUILD.in | 1 + gazelle/python/testdata/monorepo/a/BUILD.out | 1 + gazelle/python/testdata/monorepo/a/README.md | 3 + .../testdata/monorepo/coarse_grained/BUILD.in | 12 + .../monorepo/coarse_grained/BUILD.out | 20 + .../monorepo/coarse_grained/__init__.py | 26 + .../coarse_grained/_boundary/BUILD.in | 1 + .../coarse_grained/_boundary/BUILD.out | 10 + .../coarse_grained/_boundary/README.md | 5 + .../coarse_grained/_boundary/__init__.py | 14 + .../monorepo/coarse_grained/bar/__init__.py | 23 + .../coarse_grained/bar/baz/__init__.py | 19 + .../coarse_grained/bar/baz/first_excluded.py | 15 + .../monorepo/coarse_grained/bar/baz/hue.py | 15 + .../coarse_grained/bar/baz/second_excluded.py | 15 + .../monorepo/coarse_grained/foo/__init__.py | 19 + .../testdata/monorepo/gazelle_python.yaml | 19 + gazelle/python/testdata/monorepo/one/BUILD.in | 2 + .../python/testdata/monorepo/one/BUILD.out | 17 + .../python/testdata/monorepo/one/__main__.py | 29 + .../python/testdata/monorepo/one/bar/BUILD.in | 10 + .../testdata/monorepo/one/bar/BUILD.out | 12 + .../testdata/monorepo/one/bar/__init__.py | 23 + .../testdata/monorepo/one/bar/baz/BUILD.in | 10 + .../testdata/monorepo/one/bar/baz/BUILD.out | 11 + .../testdata/monorepo/one/bar/baz/__init__.py | 19 + .../python/testdata/monorepo/one/foo/BUILD.in | 11 + .../testdata/monorepo/one/foo/BUILD.out | 12 + .../testdata/monorepo/one/foo/__init__.py | 19 + .../testdata/monorepo/one/gazelle_python.yaml | 18 + gazelle/python/testdata/monorepo/test.yaml | 15 + .../python/testdata/monorepo/three/BUILD.in | 5 + .../python/testdata/monorepo/three/BUILD.out | 21 + .../testdata/monorepo/three/__init__.py | 30 + .../monorepo/three/gazelle_python.yaml | 19 + gazelle/python/testdata/monorepo/two/BUILD.in | 3 + .../python/testdata/monorepo/two/BUILD.out | 15 + .../python/testdata/monorepo/two/__init__.py | 22 + .../testdata/monorepo/two/gazelle_python.yaml | 18 + .../testdata/monorepo/wont_generate/BUILD.in | 0 .../testdata/monorepo/wont_generate/BUILD.out | 0 .../monorepo/wont_generate/__main__.py | 26 + .../monorepo/wont_generate/bar/BUILD.in | 0 .../monorepo/wont_generate/bar/BUILD.out | 0 .../monorepo/wont_generate/bar/__init__.py | 19 + .../monorepo/wont_generate/bar/baz/BUILD.in | 0 .../monorepo/wont_generate/bar/baz/BUILD.out | 0 .../wont_generate/bar/baz/__init__.py | 19 + .../monorepo/wont_generate/foo/BUILD.in | 0 .../monorepo/wont_generate/foo/BUILD.out | 0 .../monorepo/wont_generate/foo/__init__.py | 19 + .../python/testdata/multiple_tests/BUILD.in | 12 + .../python/testdata/multiple_tests/BUILD.out | 17 + .../python/testdata/multiple_tests/README.md | 3 + .../python/testdata/multiple_tests/WORKSPACE | 1 + .../testdata/multiple_tests/__init__.py | 0 .../testdata/multiple_tests/bar_test.py | 24 + .../testdata/multiple_tests/foo_test.py | 24 + .../python/testdata/multiple_tests/test.yaml | 17 + .../testdata/naming_convention/BUILD.in | 3 + .../testdata/naming_convention/BUILD.out | 26 + .../testdata/naming_convention/README.md | 4 + .../testdata/naming_convention/WORKSPACE | 1 + .../testdata/naming_convention/__init__.py | 15 + .../testdata/naming_convention/__main__.py | 16 + .../testdata/naming_convention/__test__.py | 16 + .../naming_convention/dont_rename/BUILD.in | 7 + .../naming_convention/dont_rename/BUILD.out | 25 + .../naming_convention/dont_rename/__init__.py | 15 + .../naming_convention/dont_rename/__main__.py | 16 + .../naming_convention/dont_rename/__test__.py | 16 + .../resolve_conflict/BUILD.in | 5 + .../resolve_conflict/BUILD.out | 31 + .../resolve_conflict/__init__.py | 15 + .../resolve_conflict/__main__.py | 16 + .../resolve_conflict/__test__.py | 16 + .../testdata/naming_convention/test.yaml | 15 + .../naming_convention_binary_fail/BUILD.in | 1 + .../naming_convention_binary_fail/BUILD.out | 1 + .../naming_convention_binary_fail/README.md | 4 + .../naming_convention_binary_fail/WORKSPACE | 1 + .../naming_convention_binary_fail/__main__.py | 15 + .../naming_convention_binary_fail/test.yaml | 21 + .../naming_convention_library_fail/BUILD.in | 1 + .../naming_convention_library_fail/BUILD.out | 1 + .../naming_convention_library_fail/README.md | 4 + .../naming_convention_library_fail/WORKSPACE | 1 + .../__init__.py | 15 + .../naming_convention_library_fail/test.yaml | 21 + .../naming_convention_test_fail/BUILD.in | 1 + .../naming_convention_test_fail/BUILD.out | 1 + .../naming_convention_test_fail/README.md | 4 + .../naming_convention_test_fail/WORKSPACE | 1 + .../naming_convention_test_fail/__test__.py | 15 + .../naming_convention_test_fail/test.yaml | 21 + .../BUILD.in | 2 + .../BUILD.out | 11 + .../README.md | 4 + .../WORKSPACE | 1 + .../__init__.py | 25 + .../gazelle_python.yaml | 18 + .../test.yaml | 15 + .../python_ignore_files_directive/BUILD.in | 1 + .../python_ignore_files_directive/BUILD.out | 9 + .../python_ignore_files_directive/README.md | 3 + .../python_ignore_files_directive/WORKSPACE | 1 + .../python_ignore_files_directive/__init__.py | 15 + .../bar/BUILD.in | 0 .../bar/BUILD.out | 8 + .../python_ignore_files_directive/bar/baz.py | 15 + .../bar/some_other.py | 15 + .../foo/BUILD.in | 1 + .../foo/BUILD.out | 1 + .../python_ignore_files_directive/foo/baz.py | 15 + .../python_ignore_files_directive/setup.py | 15 + .../some_other.py | 15 + .../python_ignore_files_directive/test.yaml | 15 + .../python_target_with_test_in_name/BUILD.in | 0 .../python_target_with_test_in_name/BUILD.out | 22 + .../python_target_with_test_in_name/README.md | 3 + .../python_target_with_test_in_name/WORKSPACE | 0 .../__init__.py | 15 + .../gazelle_python.yaml | 18 + .../real_test.py | 18 + .../python_target_with_test_in_name/test.yaml | 15 + .../test_reality.py | 16 + .../python/testdata/relative_imports/BUILD.in | 0 .../testdata/relative_imports/BUILD.out | 21 + .../testdata/relative_imports/README.md | 4 + .../testdata/relative_imports/WORKSPACE | 1 + .../testdata/relative_imports/__main__.py | 19 + .../relative_imports/package1/module1.py | 19 + .../relative_imports/package1/module2.py | 16 + .../relative_imports/package2/BUILD.in | 0 .../relative_imports/package2/BUILD.out | 13 + .../relative_imports/package2/__init__.py | 17 + .../relative_imports/package2/module3.py | 21 + .../relative_imports/package2/module4.py | 16 + .../package2/subpackage1/module5.py | 19 + .../testdata/relative_imports/test.yaml | 15 + .../python/testdata/sibling_imports/README.md | 3 + .../python/testdata/sibling_imports/WORKSPACE | 1 + .../testdata/sibling_imports/pkg/BUILD.in | 0 .../testdata/sibling_imports/pkg/BUILD.out | 29 + .../testdata/sibling_imports/pkg/__init__.py | 0 .../python/testdata/sibling_imports/pkg/a.py | 0 .../python/testdata/sibling_imports/pkg/b.py | 2 + .../testdata/sibling_imports/pkg/test_util.py | 0 .../testdata/sibling_imports/pkg/unit_test.py | 3 + .../python/testdata/sibling_imports/test.yaml | 1 + .../python/testdata/simple_binary/BUILD.in | 0 .../python/testdata/simple_binary/BUILD.out | 8 + .../python/testdata/simple_binary/README.md | 3 + .../python/testdata/simple_binary/WORKSPACE | 1 + .../python/testdata/simple_binary/__main__.py | 15 + .../python/testdata/simple_binary/test.yaml | 15 + .../simple_binary_with_library/BUILD.in | 18 + .../simple_binary_with_library/BUILD.out | 27 + .../simple_binary_with_library/README.md | 4 + .../simple_binary_with_library/WORKSPACE | 1 + .../simple_binary_with_library/__init__.py | 15 + .../simple_binary_with_library/__main__.py | 16 + .../simple_binary_with_library/bar.py | 15 + .../simple_binary_with_library/foo.py | 15 + .../simple_binary_with_library/test.yaml | 15 + .../python/testdata/simple_library/BUILD.in | 0 .../python/testdata/simple_library/BUILD.out | 7 + .../python/testdata/simple_library/README.md | 3 + .../python/testdata/simple_library/WORKSPACE | 1 + .../testdata/simple_library/__init__.py | 15 + .../python/testdata/simple_library/test.yaml | 15 + .../simple_library_without_init/BUILD.in | 0 .../simple_library_without_init/BUILD.out | 0 .../simple_library_without_init/README.md | 4 + .../simple_library_without_init/WORKSPACE | 1 + .../simple_library_without_init/foo/BUILD.in | 0 .../simple_library_without_init/foo/BUILD.out | 8 + .../simple_library_without_init/foo/foo.py | 15 + .../simple_library_without_init/test.yaml | 15 + gazelle/python/testdata/simple_test/BUILD.in | 6 + gazelle/python/testdata/simple_test/BUILD.out | 17 + gazelle/python/testdata/simple_test/README.md | 3 + gazelle/python/testdata/simple_test/WORKSPACE | 1 + .../python/testdata/simple_test/__init__.py | 17 + .../python/testdata/simple_test/__test__.py | 26 + gazelle/python/testdata/simple_test/foo.py | 16 + gazelle/python/testdata/simple_test/test.yaml | 17 + .../simple_test_with_conftest/BUILD.in | 1 + .../simple_test_with_conftest/BUILD.out | 27 + .../simple_test_with_conftest/README.md | 4 + .../simple_test_with_conftest/WORKSPACE | 1 + .../simple_test_with_conftest/__init__.py | 17 + .../simple_test_with_conftest/__test__.py | 26 + .../simple_test_with_conftest/bar/BUILD.in | 1 + .../simple_test_with_conftest/bar/BUILD.out | 30 + .../simple_test_with_conftest/bar/__init__.py | 17 + .../simple_test_with_conftest/bar/__test__.py | 26 + .../simple_test_with_conftest/bar/bar.py | 17 + .../simple_test_with_conftest/bar/conftest.py | 13 + .../simple_test_with_conftest/conftest.py | 14 + .../testdata/simple_test_with_conftest/foo.py | 16 + .../simple_test_with_conftest/test.yaml | 17 + .../python/testdata/subdir_sources/BUILD.in | 0 .../python/testdata/subdir_sources/BUILD.out | 12 + .../python/testdata/subdir_sources/README.md | 5 + .../python/testdata/subdir_sources/WORKSPACE | 1 + .../testdata/subdir_sources/__main__.py | 21 + .../testdata/subdir_sources/foo/BUILD.in | 0 .../testdata/subdir_sources/foo/BUILD.out | 13 + .../testdata/subdir_sources/foo/__init__.py | 15 + .../testdata/subdir_sources/foo/bar/bar.py | 15 + .../testdata/subdir_sources/foo/baz/baz.py | 15 + .../python/testdata/subdir_sources/foo/foo.py | 17 + .../subdir_sources/foo/has_build/BUILD.in | 0 .../subdir_sources/foo/has_build/BUILD.out | 8 + .../foo/has_build/python/my_module.py | 15 + .../foo/has_build_bazel/BUILD.bazel.in | 0 .../foo/has_build_bazel/python/my_module.py | 15 + .../subdir_sources/foo/has_init/BUILD.in | 0 .../subdir_sources/foo/has_init/BUILD.out | 11 + .../subdir_sources/foo/has_init/__init__.py | 15 + .../foo/has_init/python/my_module.py | 15 + .../subdir_sources/foo/has_main/BUILD.in | 0 .../subdir_sources/foo/has_main/BUILD.out | 17 + .../subdir_sources/foo/has_main/__main__.py | 16 + .../foo/has_main/python/my_module.py | 15 + .../subdir_sources/foo/has_test/BUILD.in | 0 .../subdir_sources/foo/has_test/BUILD.out | 16 + .../subdir_sources/foo/has_test/__test__.py | 16 + .../foo/has_test/python/my_module.py | 15 + .../testdata/subdir_sources/one/BUILD.in | 0 .../testdata/subdir_sources/one/BUILD.out | 8 + .../testdata/subdir_sources/one/__init__.py | 15 + .../testdata/subdir_sources/one/two/BUILD.in | 0 .../testdata/subdir_sources/one/two/BUILD.out | 12 + .../testdata/subdir_sources/one/two/README.md | 2 + .../subdir_sources/one/two/__init__.py | 18 + .../testdata/subdir_sources/one/two/three.py | 15 + .../python/testdata/subdir_sources/test.yaml | 15 + .../with_nested_import_statements/BUILD.in | 0 .../with_nested_import_statements/BUILD.out | 8 + .../with_nested_import_statements/README.md | 4 + .../with_nested_import_statements/WORKSPACE | 1 + .../with_nested_import_statements/__init__.py | 25 + .../gazelle_python.yaml | 18 + .../with_nested_import_statements/test.yaml | 15 + .../testdata/with_std_requirements/BUILD.in | 0 .../testdata/with_std_requirements/BUILD.out | 7 + .../testdata/with_std_requirements/README.md | 4 + .../testdata/with_std_requirements/WORKSPACE | 1 + .../with_std_requirements/__init__.py | 19 + .../testdata/with_std_requirements/test.yaml | 15 + .../with_third_party_requirements/BUILD.in | 0 .../with_third_party_requirements/BUILD.out | 24 + .../with_third_party_requirements/README.md | 7 + .../with_third_party_requirements/WORKSPACE | 1 + .../with_third_party_requirements/__init__.py | 15 + .../with_third_party_requirements/__main__.py | 19 + .../with_third_party_requirements/bar.py | 25 + .../with_third_party_requirements/foo.py | 25 + .../gazelle_python.yaml | 21 + .../with_third_party_requirements/test.yaml | 15 + .../BUILD.in | 0 .../BUILD.out | 25 + .../README.md | 15 + .../WORKSPACE | 1 + .../__init__.py | 15 + .../__main__.py | 20 + .../bar.py | 20 + .../gazelle_python.yaml | 1678 +++++++++++++++++ .../test.yaml | 15 + gazelle/pythonconfig/BUILD.bazel | 16 +- gazelle/pythonconfig/pythonconfig.go | 43 +- gazelle/pythonconfig/pythonconfig_test.go | 28 + gazelle/pythonconfig/types.go | 14 + 461 files changed, 9117 insertions(+), 322 deletions(-) create mode 100644 gazelle/.bazelrc create mode 100644 gazelle/.gitignore create mode 100644 gazelle/MODULE.bazel create mode 100644 gazelle/WORKSPACE create mode 100644 gazelle/go.mod create mode 100644 gazelle/go.sum create mode 100644 gazelle/manifest/hasher/BUILD.bazel create mode 100644 gazelle/manifest/hasher/main.go create mode 100644 gazelle/python/BUILD.bazel create mode 100644 gazelle/python/configure.go create mode 100644 gazelle/python/fix.go create mode 100644 gazelle/python/generate.go create mode 100644 gazelle/python/kinds.go create mode 100644 gazelle/python/language.go create mode 100644 gazelle/python/parse.py create mode 100644 gazelle/python/parser.go create mode 100644 gazelle/python/python_test.go create mode 100644 gazelle/python/resolve.go create mode 100644 gazelle/python/std_modules.go create mode 100644 gazelle/python/std_modules.py create mode 100644 gazelle/python/target.go create mode 100644 gazelle/python/testdata/README.md create mode 100644 gazelle/python/testdata/dependency_resolution_order/BUILD.in create mode 100644 gazelle/python/testdata/dependency_resolution_order/BUILD.out create mode 100644 gazelle/python/testdata/dependency_resolution_order/README.md create mode 100644 gazelle/python/testdata/dependency_resolution_order/WORKSPACE create mode 100644 gazelle/python/testdata/dependency_resolution_order/__init__.py create mode 100644 gazelle/python/testdata/dependency_resolution_order/bar/BUILD.in create mode 100644 gazelle/python/testdata/dependency_resolution_order/bar/BUILD.out create mode 100644 gazelle/python/testdata/dependency_resolution_order/bar/__init__.py create mode 100644 gazelle/python/testdata/dependency_resolution_order/baz/BUILD.in create mode 100644 gazelle/python/testdata/dependency_resolution_order/baz/BUILD.out create mode 100644 gazelle/python/testdata/dependency_resolution_order/baz/__init__.py create mode 100644 gazelle/python/testdata/dependency_resolution_order/foo/BUILD.in create mode 100644 gazelle/python/testdata/dependency_resolution_order/foo/BUILD.out create mode 100644 gazelle/python/testdata/dependency_resolution_order/foo/__init__.py create mode 100644 gazelle/python/testdata/dependency_resolution_order/gazelle_python.yaml create mode 100644 gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.in create mode 100644 gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.out create mode 100644 gazelle/python/testdata/dependency_resolution_order/somewhere/bar/__init__.py create mode 100644 gazelle/python/testdata/dependency_resolution_order/test.yaml create mode 100644 gazelle/python/testdata/disable_import_statements_validation/BUILD.in create mode 100644 gazelle/python/testdata/disable_import_statements_validation/BUILD.out create mode 100644 gazelle/python/testdata/disable_import_statements_validation/README.md create mode 100644 gazelle/python/testdata/disable_import_statements_validation/WORKSPACE create mode 100644 gazelle/python/testdata/disable_import_statements_validation/__init__.py create mode 100644 gazelle/python/testdata/disable_import_statements_validation/test.yaml create mode 100644 gazelle/python/testdata/dont_rename_target/BUILD.in create mode 100644 gazelle/python/testdata/dont_rename_target/BUILD.out create mode 100644 gazelle/python/testdata/dont_rename_target/README.md create mode 100644 gazelle/python/testdata/dont_rename_target/WORKSPACE create mode 100644 gazelle/python/testdata/dont_rename_target/__init__.py create mode 100644 gazelle/python/testdata/dont_rename_target/test.yaml create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/BUILD.in create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/BUILD.out create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/README.md create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/WORKSPACE create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/__init__.py create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/gazelle_python.yaml create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/rest_framework.py create mode 100644 gazelle/python/testdata/file_name_matches_import_statement/test.yaml create mode 100644 gazelle/python/testdata/first_party_dependencies/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/README.md create mode 100644 gazelle/python/testdata/first_party_dependencies/WORKSPACE create mode 100644 gazelle/python/testdata/first_party_dependencies/one/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/one/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/one/__main__.py create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/__init__.py create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/one/bar/baz/__init__.py create mode 100644 gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/one/foo/__init__.py create mode 100644 gazelle/python/testdata/first_party_dependencies/test.yaml create mode 100644 gazelle/python/testdata/first_party_dependencies/three/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/three/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/three/__init__.py create mode 100644 gazelle/python/testdata/first_party_dependencies/two/BUILD.in create mode 100644 gazelle/python/testdata/first_party_dependencies/two/BUILD.out create mode 100644 gazelle/python/testdata/first_party_dependencies/two/__init__.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.in create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.out create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/README.md create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/WORKSPACE create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/__main__.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/baz.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/foo.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.in create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.out create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/foo/__init__.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/foo/bar.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.in create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.out create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/one/__init__.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/test.yaml create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py create mode 100644 gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py create mode 100644 gazelle/python/testdata/from_imports/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/README.md create mode 100644 gazelle/python/testdata/from_imports/WORKSPACE create mode 100644 gazelle/python/testdata/from_imports/foo/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/foo/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/foo/__init__.py create mode 100644 gazelle/python/testdata/from_imports/foo/bar/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/foo/bar/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/foo/bar/__init__.py create mode 100644 gazelle/python/testdata/from_imports/foo/bar/baz.py create mode 100644 gazelle/python/testdata/from_imports/gazelle_python.yaml create mode 100644 gazelle/python/testdata/from_imports/import_from_init_py/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_from_init_py/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_from_init_py/__init__.py create mode 100644 gazelle/python/testdata/from_imports/import_from_multiple/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_from_multiple/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_from_multiple/__init__.py create mode 100644 gazelle/python/testdata/from_imports/import_nested_file/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_nested_file/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_nested_file/__init__.py create mode 100644 gazelle/python/testdata/from_imports/import_nested_module/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_nested_module/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_nested_module/__init__.py create mode 100644 gazelle/python/testdata/from_imports/import_nested_var/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_nested_var/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_nested_var/__init__.py create mode 100644 gazelle/python/testdata/from_imports/import_top_level_var/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/import_top_level_var/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/import_top_level_var/__init__.py create mode 100644 gazelle/python/testdata/from_imports/std_module/BUILD.in create mode 100644 gazelle/python/testdata/from_imports/std_module/BUILD.out create mode 100644 gazelle/python/testdata/from_imports/std_module/__init__.py create mode 100644 gazelle/python/testdata/from_imports/test.yaml create mode 100644 gazelle/python/testdata/generated_test_entrypoint/BUILD.in create mode 100644 gazelle/python/testdata/generated_test_entrypoint/BUILD.out create mode 100644 gazelle/python/testdata/generated_test_entrypoint/README.md create mode 100644 gazelle/python/testdata/generated_test_entrypoint/WORKSPACE create mode 100644 gazelle/python/testdata/generated_test_entrypoint/__init__.py create mode 100644 gazelle/python/testdata/generated_test_entrypoint/foo.py create mode 100644 gazelle/python/testdata/generated_test_entrypoint/test.yaml create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/BUILD.in create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/BUILD.out create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/README.md create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/WORKSPACE create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/__init__.py create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/gazelle_python.yaml create mode 100644 gazelle/python/testdata/ignored_invalid_imported_module/test.yaml create mode 100644 gazelle/python/testdata/invalid_annotation/BUILD.in create mode 100644 gazelle/python/testdata/invalid_annotation/BUILD.out create mode 100644 gazelle/python/testdata/invalid_annotation/README.md create mode 100644 gazelle/python/testdata/invalid_annotation/WORKSPACE create mode 100644 gazelle/python/testdata/invalid_annotation/__init__.py create mode 100644 gazelle/python/testdata/invalid_annotation/test.yaml create mode 100644 gazelle/python/testdata/invalid_imported_module/BUILD.in create mode 100644 gazelle/python/testdata/invalid_imported_module/BUILD.out create mode 100644 gazelle/python/testdata/invalid_imported_module/README.md create mode 100644 gazelle/python/testdata/invalid_imported_module/WORKSPACE create mode 100644 gazelle/python/testdata/invalid_imported_module/__init__.py create mode 100644 gazelle/python/testdata/invalid_imported_module/test.yaml create mode 100644 gazelle/python/testdata/monorepo/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/README.md create mode 100644 gazelle/python/testdata/monorepo/WORKSPACE create mode 100644 gazelle/python/testdata/monorepo/a/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/a/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/a/README.md create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/__init__.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/_boundary/README.md create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/bar/__init__.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/bar/baz/__init__.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/bar/baz/hue.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py create mode 100644 gazelle/python/testdata/monorepo/coarse_grained/foo/__init__.py create mode 100644 gazelle/python/testdata/monorepo/gazelle_python.yaml create mode 100644 gazelle/python/testdata/monorepo/one/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/one/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/one/__main__.py create mode 100644 gazelle/python/testdata/monorepo/one/bar/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/one/bar/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/one/bar/__init__.py create mode 100644 gazelle/python/testdata/monorepo/one/bar/baz/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/one/bar/baz/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/one/bar/baz/__init__.py create mode 100644 gazelle/python/testdata/monorepo/one/foo/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/one/foo/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/one/foo/__init__.py create mode 100644 gazelle/python/testdata/monorepo/one/gazelle_python.yaml create mode 100644 gazelle/python/testdata/monorepo/test.yaml create mode 100644 gazelle/python/testdata/monorepo/three/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/three/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/three/__init__.py create mode 100644 gazelle/python/testdata/monorepo/three/gazelle_python.yaml create mode 100644 gazelle/python/testdata/monorepo/two/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/two/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/two/__init__.py create mode 100644 gazelle/python/testdata/monorepo/two/gazelle_python.yaml create mode 100644 gazelle/python/testdata/monorepo/wont_generate/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/wont_generate/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/wont_generate/__main__.py create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/__init__.py create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/wont_generate/bar/baz/__init__.py create mode 100644 gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.in create mode 100644 gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.out create mode 100644 gazelle/python/testdata/monorepo/wont_generate/foo/__init__.py create mode 100644 gazelle/python/testdata/multiple_tests/BUILD.in create mode 100644 gazelle/python/testdata/multiple_tests/BUILD.out create mode 100644 gazelle/python/testdata/multiple_tests/README.md create mode 100644 gazelle/python/testdata/multiple_tests/WORKSPACE create mode 100644 gazelle/python/testdata/multiple_tests/__init__.py create mode 100644 gazelle/python/testdata/multiple_tests/bar_test.py create mode 100644 gazelle/python/testdata/multiple_tests/foo_test.py create mode 100644 gazelle/python/testdata/multiple_tests/test.yaml create mode 100644 gazelle/python/testdata/naming_convention/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention/README.md create mode 100644 gazelle/python/testdata/naming_convention/WORKSPACE create mode 100644 gazelle/python/testdata/naming_convention/__init__.py create mode 100644 gazelle/python/testdata/naming_convention/__main__.py create mode 100644 gazelle/python/testdata/naming_convention/__test__.py create mode 100644 gazelle/python/testdata/naming_convention/dont_rename/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention/dont_rename/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention/dont_rename/__init__.py create mode 100644 gazelle/python/testdata/naming_convention/dont_rename/__main__.py create mode 100644 gazelle/python/testdata/naming_convention/dont_rename/__test__.py create mode 100644 gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention/resolve_conflict/__init__.py create mode 100644 gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py create mode 100644 gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py create mode 100644 gazelle/python/testdata/naming_convention/test.yaml create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/README.md create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/WORKSPACE create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/__main__.py create mode 100644 gazelle/python/testdata/naming_convention_binary_fail/test.yaml create mode 100644 gazelle/python/testdata/naming_convention_library_fail/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention_library_fail/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention_library_fail/README.md create mode 100644 gazelle/python/testdata/naming_convention_library_fail/WORKSPACE create mode 100644 gazelle/python/testdata/naming_convention_library_fail/__init__.py create mode 100644 gazelle/python/testdata/naming_convention_library_fail/test.yaml create mode 100644 gazelle/python/testdata/naming_convention_test_fail/BUILD.in create mode 100644 gazelle/python/testdata/naming_convention_test_fail/BUILD.out create mode 100644 gazelle/python/testdata/naming_convention_test_fail/README.md create mode 100644 gazelle/python/testdata/naming_convention_test_fail/WORKSPACE create mode 100644 gazelle/python/testdata/naming_convention_test_fail/__test__.py create mode 100644 gazelle/python/testdata/naming_convention_test_fail/test.yaml create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.in create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.out create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/README.md create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/WORKSPACE create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/__init__.py create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/gazelle_python.yaml create mode 100644 gazelle/python/testdata/python_ignore_dependencies_directive/test.yaml create mode 100644 gazelle/python/testdata/python_ignore_files_directive/BUILD.in create mode 100644 gazelle/python/testdata/python_ignore_files_directive/BUILD.out create mode 100644 gazelle/python/testdata/python_ignore_files_directive/README.md create mode 100644 gazelle/python/testdata/python_ignore_files_directive/WORKSPACE create mode 100644 gazelle/python/testdata/python_ignore_files_directive/__init__.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.in create mode 100644 gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.out create mode 100644 gazelle/python/testdata/python_ignore_files_directive/bar/baz.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/bar/some_other.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.in create mode 100644 gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.out create mode 100644 gazelle/python/testdata/python_ignore_files_directive/foo/baz.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/setup.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/some_other.py create mode 100644 gazelle/python/testdata/python_ignore_files_directive/test.yaml create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/BUILD.in create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/BUILD.out create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/README.md create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/WORKSPACE create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/__init__.py create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/gazelle_python.yaml create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/real_test.py create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/test.yaml create mode 100644 gazelle/python/testdata/python_target_with_test_in_name/test_reality.py create mode 100644 gazelle/python/testdata/relative_imports/BUILD.in create mode 100644 gazelle/python/testdata/relative_imports/BUILD.out create mode 100644 gazelle/python/testdata/relative_imports/README.md create mode 100644 gazelle/python/testdata/relative_imports/WORKSPACE create mode 100644 gazelle/python/testdata/relative_imports/__main__.py create mode 100644 gazelle/python/testdata/relative_imports/package1/module1.py create mode 100644 gazelle/python/testdata/relative_imports/package1/module2.py create mode 100644 gazelle/python/testdata/relative_imports/package2/BUILD.in create mode 100644 gazelle/python/testdata/relative_imports/package2/BUILD.out create mode 100644 gazelle/python/testdata/relative_imports/package2/__init__.py create mode 100644 gazelle/python/testdata/relative_imports/package2/module3.py create mode 100644 gazelle/python/testdata/relative_imports/package2/module4.py create mode 100644 gazelle/python/testdata/relative_imports/package2/subpackage1/module5.py create mode 100644 gazelle/python/testdata/relative_imports/test.yaml create mode 100644 gazelle/python/testdata/sibling_imports/README.md create mode 100644 gazelle/python/testdata/sibling_imports/WORKSPACE create mode 100644 gazelle/python/testdata/sibling_imports/pkg/BUILD.in create mode 100644 gazelle/python/testdata/sibling_imports/pkg/BUILD.out create mode 100644 gazelle/python/testdata/sibling_imports/pkg/__init__.py create mode 100644 gazelle/python/testdata/sibling_imports/pkg/a.py create mode 100644 gazelle/python/testdata/sibling_imports/pkg/b.py create mode 100644 gazelle/python/testdata/sibling_imports/pkg/test_util.py create mode 100644 gazelle/python/testdata/sibling_imports/pkg/unit_test.py create mode 100644 gazelle/python/testdata/sibling_imports/test.yaml create mode 100644 gazelle/python/testdata/simple_binary/BUILD.in create mode 100644 gazelle/python/testdata/simple_binary/BUILD.out create mode 100644 gazelle/python/testdata/simple_binary/README.md create mode 100644 gazelle/python/testdata/simple_binary/WORKSPACE create mode 100644 gazelle/python/testdata/simple_binary/__main__.py create mode 100644 gazelle/python/testdata/simple_binary/test.yaml create mode 100644 gazelle/python/testdata/simple_binary_with_library/BUILD.in create mode 100644 gazelle/python/testdata/simple_binary_with_library/BUILD.out create mode 100644 gazelle/python/testdata/simple_binary_with_library/README.md create mode 100644 gazelle/python/testdata/simple_binary_with_library/WORKSPACE create mode 100644 gazelle/python/testdata/simple_binary_with_library/__init__.py create mode 100644 gazelle/python/testdata/simple_binary_with_library/__main__.py create mode 100644 gazelle/python/testdata/simple_binary_with_library/bar.py create mode 100644 gazelle/python/testdata/simple_binary_with_library/foo.py create mode 100644 gazelle/python/testdata/simple_binary_with_library/test.yaml create mode 100644 gazelle/python/testdata/simple_library/BUILD.in create mode 100644 gazelle/python/testdata/simple_library/BUILD.out create mode 100644 gazelle/python/testdata/simple_library/README.md create mode 100644 gazelle/python/testdata/simple_library/WORKSPACE create mode 100644 gazelle/python/testdata/simple_library/__init__.py create mode 100644 gazelle/python/testdata/simple_library/test.yaml create mode 100644 gazelle/python/testdata/simple_library_without_init/BUILD.in create mode 100644 gazelle/python/testdata/simple_library_without_init/BUILD.out create mode 100644 gazelle/python/testdata/simple_library_without_init/README.md create mode 100644 gazelle/python/testdata/simple_library_without_init/WORKSPACE create mode 100644 gazelle/python/testdata/simple_library_without_init/foo/BUILD.in create mode 100644 gazelle/python/testdata/simple_library_without_init/foo/BUILD.out create mode 100644 gazelle/python/testdata/simple_library_without_init/foo/foo.py create mode 100644 gazelle/python/testdata/simple_library_without_init/test.yaml create mode 100644 gazelle/python/testdata/simple_test/BUILD.in create mode 100644 gazelle/python/testdata/simple_test/BUILD.out create mode 100644 gazelle/python/testdata/simple_test/README.md create mode 100644 gazelle/python/testdata/simple_test/WORKSPACE create mode 100644 gazelle/python/testdata/simple_test/__init__.py create mode 100644 gazelle/python/testdata/simple_test/__test__.py create mode 100644 gazelle/python/testdata/simple_test/foo.py create mode 100644 gazelle/python/testdata/simple_test/test.yaml create mode 100644 gazelle/python/testdata/simple_test_with_conftest/BUILD.in create mode 100644 gazelle/python/testdata/simple_test_with_conftest/BUILD.out create mode 100644 gazelle/python/testdata/simple_test_with_conftest/README.md create mode 100644 gazelle/python/testdata/simple_test_with_conftest/WORKSPACE create mode 100644 gazelle/python/testdata/simple_test_with_conftest/__init__.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/__test__.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.in create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.out create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/__init__.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/__test__.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/bar.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/bar/conftest.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/conftest.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/foo.py create mode 100644 gazelle/python/testdata/simple_test_with_conftest/test.yaml create mode 100644 gazelle/python/testdata/subdir_sources/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/README.md create mode 100644 gazelle/python/testdata/subdir_sources/WORKSPACE create mode 100644 gazelle/python/testdata/subdir_sources/__main__.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/foo/__init__.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/bar/bar.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/baz/baz.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/foo.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_build/python/my_module.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_init/__init__.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_init/python/my_module.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_main/python/my_module.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py create mode 100644 gazelle/python/testdata/subdir_sources/foo/has_test/python/my_module.py create mode 100644 gazelle/python/testdata/subdir_sources/one/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/one/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/one/__init__.py create mode 100644 gazelle/python/testdata/subdir_sources/one/two/BUILD.in create mode 100644 gazelle/python/testdata/subdir_sources/one/two/BUILD.out create mode 100644 gazelle/python/testdata/subdir_sources/one/two/README.md create mode 100644 gazelle/python/testdata/subdir_sources/one/two/__init__.py create mode 100644 gazelle/python/testdata/subdir_sources/one/two/three.py create mode 100644 gazelle/python/testdata/subdir_sources/test.yaml create mode 100644 gazelle/python/testdata/with_nested_import_statements/BUILD.in create mode 100644 gazelle/python/testdata/with_nested_import_statements/BUILD.out create mode 100644 gazelle/python/testdata/with_nested_import_statements/README.md create mode 100644 gazelle/python/testdata/with_nested_import_statements/WORKSPACE create mode 100644 gazelle/python/testdata/with_nested_import_statements/__init__.py create mode 100644 gazelle/python/testdata/with_nested_import_statements/gazelle_python.yaml create mode 100644 gazelle/python/testdata/with_nested_import_statements/test.yaml create mode 100644 gazelle/python/testdata/with_std_requirements/BUILD.in create mode 100644 gazelle/python/testdata/with_std_requirements/BUILD.out create mode 100644 gazelle/python/testdata/with_std_requirements/README.md create mode 100644 gazelle/python/testdata/with_std_requirements/WORKSPACE create mode 100644 gazelle/python/testdata/with_std_requirements/__init__.py create mode 100644 gazelle/python/testdata/with_std_requirements/test.yaml create mode 100644 gazelle/python/testdata/with_third_party_requirements/BUILD.in create mode 100644 gazelle/python/testdata/with_third_party_requirements/BUILD.out create mode 100644 gazelle/python/testdata/with_third_party_requirements/README.md create mode 100644 gazelle/python/testdata/with_third_party_requirements/WORKSPACE create mode 100644 gazelle/python/testdata/with_third_party_requirements/__init__.py create mode 100644 gazelle/python/testdata/with_third_party_requirements/__main__.py create mode 100644 gazelle/python/testdata/with_third_party_requirements/bar.py create mode 100644 gazelle/python/testdata/with_third_party_requirements/foo.py create mode 100644 gazelle/python/testdata/with_third_party_requirements/gazelle_python.yaml create mode 100644 gazelle/python/testdata/with_third_party_requirements/test.yaml create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.in create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.out create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/README.md create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/WORKSPACE create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/__init__.py create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/__main__.py create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/bar.py create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml create mode 100644 gazelle/python/testdata/with_third_party_requirements_from_imports/test.yaml create mode 100644 gazelle/pythonconfig/pythonconfig_test.go diff --git a/gazelle/.bazelrc b/gazelle/.bazelrc new file mode 100644 index 0000000000..f48d0a97ee --- /dev/null +++ b/gazelle/.bazelrc @@ -0,0 +1,13 @@ +test --test_output=errors + +# Do NOT implicitly create empty __init__.py files in the runfiles tree. +# By default, these are created in every directory containing Python source code +# or shared libraries, and every parent directory of those directories, +# excluding the repo root directory. With this flag set, we are responsible for +# creating (possibly empty) __init__.py files and adding them to the srcs of +# Python targets as required. +build --incompatible_default_to_explicit_init_py + +# Windows makes use of runfiles for some rules +build --enable_runfiles +startup --windows_enable_symlinks diff --git a/gazelle/.gitignore b/gazelle/.gitignore new file mode 100644 index 0000000000..8481c9668c --- /dev/null +++ b/gazelle/.gitignore @@ -0,0 +1,12 @@ +# Bazel directories +/bazel-* +/bazel-bin +/bazel-genfiles +/bazel-out +/bazel-testlogs +user.bazelrc + +# Go/Gazelle files +# These otherwise match patterns above +!go.mod +!BUILD.out diff --git a/gazelle/BUILD.bazel b/gazelle/BUILD.bazel index c24a086a50..6016145516 100644 --- a/gazelle/BUILD.bazel +++ b/gazelle/BUILD.bazel @@ -1,71 +1,35 @@ -load("@bazel_gazelle//:def.bzl", "gazelle_binary") -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") -load("@rules_python//python:defs.bzl", "py_binary") +load("@bazel_gazelle//:def.bzl", "gazelle") -go_library( - name = "gazelle", - srcs = [ - "configure.go", - "fix.go", - "generate.go", - "kinds.go", - "language.go", - "parser.go", - "resolve.go", - "std_modules.go", - "target.go", - ], - importpath = "github.com/bazelbuild/rules_python/gazelle", - visibility = ["//visibility:public"], - deps = [ - "//gazelle/manifest", - "//gazelle/pythonconfig", - "@bazel_gazelle//config:go_default_library", - "@bazel_gazelle//label:go_default_library", - "@bazel_gazelle//language:go_default_library", - "@bazel_gazelle//repo:go_default_library", - "@bazel_gazelle//resolve:go_default_library", - "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build:go_default_library", - "@com_github_bmatcuk_doublestar//:doublestar", - "@com_github_emirpasic_gods//lists/singlylinkedlist", - "@com_github_emirpasic_gods//sets/treeset", - "@com_github_emirpasic_gods//utils", - "@com_github_google_uuid//:uuid", - "@io_bazel_rules_go//go/tools/bazel:go_default_library", - ], -) - -py_binary( - name = "parse", - srcs = ["parse.py"], - visibility = ["//visibility:public"], -) - -py_binary( - name = "std_modules", - srcs = ["std_modules.py"], - visibility = ["//visibility:public"], -) +# Gazelle configuration options. +# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel +# gazelle:prefix github.com/bazelbuild/rules_python/gazelle +# gazelle:exclude bazel-out +gazelle(name = "gazelle") -go_test( - name = "gazelle_test", - srcs = ["python_test.go"], - data = [ - ":gazelle_python_binary", - ":parse", - ":std_modules", - ] + glob(["testdata/**"]), - deps = [ - "@bazel_gazelle//testtools:go_default_library", - "@com_github_emirpasic_gods//lists/singlylinkedlist", - "@com_github_ghodss_yaml//:yaml", - "@io_bazel_rules_go//go/tools/bazel:go_default_library", +gazelle( + name = "gazelle_update_repos", + args = [ + "-from_file=go.mod", + "-to_macro=deps.bzl%gazelle_deps", + "-prune", ], + command = "update-repos", ) -gazelle_binary( - name = "gazelle_python_binary", - languages = ["//gazelle"], - visibility = ["//visibility:public"], +filegroup( + name = "distribution", + srcs = [ + ":BUILD.bazel", + ":README.md", + ":WORKSPACE", + ":def.bzl", + ":deps.bzl", + ":go.mod", + ":go.sum", + "//manifest:distribution", + "//modules_mapping:distribution", + "//python:distribution", + "//pythonconfig:distribution", + ], + visibility = ["@rules_python//:__pkg__"], ) diff --git a/gazelle/MODULE.bazel b/gazelle/MODULE.bazel new file mode 100644 index 0000000000..bd634020f3 --- /dev/null +++ b/gazelle/MODULE.bazel @@ -0,0 +1,20 @@ +module( + name = "rules_python_gazelle_plugin", + version = "0.0.0", + compatibility_level = 1, +) + +bazel_dep(name = "rules_python", version = "0.18.0") +bazel_dep(name = "rules_go", version = "0.38.1", repo_name = "io_bazel_rules_go") +bazel_dep(name = "gazelle", version = "0.29.0", repo_name = "bazel_gazelle") + +go_deps = use_extension("@bazel_gazelle//:extensions.bzl", "go_deps") +go_deps.from_file(go_mod = "//:go.mod") +use_repo( + go_deps, + "com_github_bazelbuild_buildtools", + "com_github_bmatcuk_doublestar", + "com_github_emirpasic_gods", + "com_github_ghodss_yaml", + "in_gopkg_yaml_v2", +) diff --git a/gazelle/README.md b/gazelle/README.md index e622db991a..e36f3a303a 100644 --- a/gazelle/README.md +++ b/gazelle/README.md @@ -1,29 +1,79 @@ # Python Gazelle plugin +[Gazelle](https://github.com/bazelbuild/bazel-gazelle) +is a build file generator for Bazel projects. It can create new BUILD.bazel files for a project that follows language conventions, and it can update existing build files to include new sources, dependencies, and options. + +Gazelle may be run by Bazel using the gazelle rule, or it may be installed and run as a command line tool. + This directory contains a plugin for [Gazelle](https://github.com/bazelbuild/bazel-gazelle) -that generates BUILD file content for Python code. +that generates BUILD files content for Python code. + +The following instructions are for when you use [bzlmod](https://docs.bazel.build/versions/5.0.0/bzlmod.html). +Please refer to older documentation that includes instructions on how to use Gazelle +without using bzlmod as your dependency manager. + +## Example + +We have an example of using Gazelle with Python located [here](https://github.com/bazelbuild/rules_python/tree/main/examples/bzlmod). +A fully-working example without using bzlmod is in [`examples/build_file_generation`](../examples/build_file_generation). -It requires Go 1.16+ to compile. +The following documentation covers using bzlmod. -## Installation +## Adding Gazelle to your project -First, you'll need to add Gazelle to your `WORKSPACE` file. -Follow the instructions at https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel +First, you'll need to add Gazelle to your `MODULES.bazel` file. +Get the current version of Gazelle from there releases here: https://github.com/bazelbuild/bazel-gazelle/releases/. -Next, we need to fetch the third-party Go libraries that the python extension -depends on. -Add this to your `WORKSPACE`: +See the installation `MODULE.bazel` snippet on the Releases page: +https://github.com/bazelbuild/rules_python/releases in order to configure rules_python. + +You will also need to add the `bazel_dep` for configuration for `rules_python_gazelle_plugin`. + +Here is a snippet of a `MODULE.bazel` file. ```starlark -# To compile the rules_python gazelle extension from source, -# we must fetch some third-party go dependencies that it uses. -load("@rules_python//gazelle:deps.bzl", _py_gazelle_deps = "gazelle_deps") +# The following stanza defines the dependency rules_python. +bazel_dep(name = "rules_python", version = "0.20.0") -_py_gazelle_deps() -``` +# The following stanza defines the dependency rules_python. +# For typical setups you set the version. +bazel_dep(name = "rules_python_gazelle_plugin", version = "0.20.0") + +# The following stanza defines the dependency rules_python. +bazel_dep(name = "gazelle", version = "0.30.0", repo_name = "bazel_gazelle") + +# Import the python repositories generated by the given module extension into the scope of the current module. +use_repo(python, "python3_9") +use_repo(python, "python3_9_toolchains") + +# Register an already-defined toolchain so that Bazel can use it during toolchain resolution. +register_toolchains( + "@python3_9_toolchains//:all", +) + +# Use the pip extension +pip = use_extension("@rules_python//python:extensions.bzl", "pip") + +# Use the extension to call the `pip_repository` rule that invokes `pip`, with `incremental` set. +# Accepts a locked/compiled requirements file and installs the dependencies listed within. +# Those dependencies become available in a generated `requirements.bzl` file. +# You can instead check this `requirements.bzl` file into your repo. +# Because this project has different requirements for windows vs other +# operating systems, we have requirements for each. +pip.parse( + name = "pip", + # When using gazelle you must use set the following flag + # in order for the generation of gazelle dependency resolution. + incompatible_generate_aliases = True, + requirements_lock = "//:requirements_lock.txt", + requirements_windows = "//:requirements_windows.txt", +) +# Imports the pip toolchain generated by the given module extension into the scope of the current module. +use_repo(pip, "pip") +``` Next, we'll fetch metadata about your Python dependencies, so that gazelle can determine which package a given import statement comes from. This is provided by the `modules_mapping` rule. We'll make a target for consuming this @@ -40,8 +90,8 @@ To keep the metadata updated, put this in your `BUILD.bazel` file next to `gazel ```starlark load("@pip//:requirements.bzl", "all_whl_requirements") -load("@rules_python//gazelle/manifest:defs.bzl", "gazelle_python_manifest") -load("@rules_python//gazelle/modules_mapping:def.bzl", "modules_mapping") +load("@rules_python_gazelle_plugin//manifest:defs.bzl", "gazelle_python_manifest") +load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping") # This rule fetches the metadata for python packages we depend on. That data is # required for the gazelle_python_manifest rule to update our manifest file. @@ -63,11 +113,12 @@ gazelle_python_manifest( # This is what we called our `pip_install` rule, where third-party # python libraries are loaded in BUILD files. pip_repository_name = "pip", - # When using pip_parse instead of pip_install, set the following. - # pip_repository_incremental = True, # This should point to wherever we declare our python dependencies # (the same as what we passed to the modules_mapping rule in WORKSPACE) requirements = "//:requirements_lock.txt", + # NOTE: we can use this flag in order to make our setup compatible with + # bzlmod. + use_pip_repository_aliases = True, ) ``` @@ -75,9 +126,9 @@ Finally, you create a target that you'll invoke to run the Gazelle tool with the rules_python extension included. This typically goes in your root `/BUILD.bazel` file: -``` +```starlark load("@bazel_gazelle//:def.bzl", "gazelle") -load("@rules_python//gazelle:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS") +load("@rules_python_gazelle_plugin//:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS") # Our gazelle target points to the python gazelle binary. # This is the simple case where we only need one language supported. @@ -87,15 +138,13 @@ load("@rules_python//gazelle:def.bzl", "GAZELLE_PYTHON_RUNTIME_DEPS") gazelle( name = "gazelle", data = GAZELLE_PYTHON_RUNTIME_DEPS, - gazelle = "@rules_python//gazelle:gazelle_python_binary", + gazelle = "@rules_python_gazelle_plugin//python:gazelle_binary", ) ``` That's it, now you can finally run `bazel run //:gazelle` anytime you edit Python code, and it should update your `BUILD` files correctly. -A fully-working example is in [`examples/build_file_generation`](../examples/build_file_generation). - ## Usage Gazelle is non-destructive. @@ -166,11 +215,29 @@ Next, all source files are collected into the `srcs` of the `py_library`. Finally, the `import` statements in the source files are parsed, and dependencies are added to the `deps` attribute. -### Tests +### Unit Tests + +A `py_test` target is added to the BUILD file when gazelle encounters +a file named `__test__.py`. +Often, Python unit test files are named with the suffix `_test`. +For example, if we had a folder that is a package named "foo" we could have a Python file named `foo_test.py` +and gazelle would create a `py_test` block for the file. + +The following is an example of a `py_test` target that gazelle would add when +it encounters a file named `__test__.py`. -Python test files are those ending in `_test.py`. +```starlark +py_test( + name = "build_file_generation_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [":build_file_generation"], +) +``` -A `py_test` target is added containing all test files as `srcs`. +You can control the naming convention for test targets by adding a gazelle directive named +`# gazelle:python_test_naming_convention`. See the instructions in the section above that +covers directives. ### Binaries @@ -179,16 +246,18 @@ of a Python program. A `py_binary` target will be created, named `[package]_bin`. -## Developing on the extension +## Developer Notes -Gazelle extensions are written in Go. Ours is a hybrid, which also spawns -a Python interpreter as a subprocess to parse python files. +Gazelle extensions are written in Go. This gazelle plugin is a hybrid, as it uses Go to execute a +Python interpreter as a subprocess to parse Python source files. +See the gazelle documentation https://github.com/bazelbuild/bazel-gazelle/blob/master/extend.md +for more information on extending Gazelle. -The Go dependencies are managed by the go.mod file. -After changing that file, run `go mod tidy` to get a `go.sum` file, -then run `bazel run //:update_go_deps` to convert that to the `gazelle/deps.bzl` file. -The latter is loaded in our `/WORKSPACE` to define the external repos -that we can load Go dependencies from. +If you add new Go dependencies to the plugin source code, you need to "tidy" the go.mod file. +After changing that file, run `go mod tidy` or `bazel run @go_sdk//:bin/go -- mod tidy` +to update the go.mod and go.sum files. Then run `bazel run //:update_go_deps` to have gazelle +add the new dependenies to the deps.bzl file. The deps.bzl file is used as defined in our /WORKSPACE +to include the external repos Bazel loads Go dependencies from. -Then after editing Go code, run `bazel run //:gazelle` to generate/update -go_* rules in the BUILD.bazel files in our repo. +Then after editing Go code, run `bazel run //:gazelle` to generate/update the rules in the +BUILD.bazel files in our repo. diff --git a/gazelle/WORKSPACE b/gazelle/WORKSPACE new file mode 100644 index 0000000000..55cf1b0d40 --- /dev/null +++ b/gazelle/WORKSPACE @@ -0,0 +1,47 @@ +workspace(name = "rules_python_gazelle_plugin") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", + ], +) + +http_archive( + name = "bazel_gazelle", + sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz", + ], +) + +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") + +go_rules_dependencies() + +go_register_toolchains(version = "1.19.4") + +gazelle_dependencies() + +local_repository( + name = "rules_python", + path = "..", +) + +load("@rules_python//python:repositories.bzl", "python_register_toolchains") + +python_register_toolchains( + name = "python39", + python_version = "3.9", +) + +load("//:deps.bzl", _py_gazelle_deps = "gazelle_deps") + +# gazelle:repository_macro deps.bzl%gazelle_deps +_py_gazelle_deps() diff --git a/gazelle/def.bzl b/gazelle/def.bzl index a402fc74c4..80b11576e6 100644 --- a/gazelle/def.bzl +++ b/gazelle/def.bzl @@ -1,7 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """This module contains the Gazelle runtime dependencies for the Python extension. """ GAZELLE_PYTHON_RUNTIME_DEPS = [ - "@rules_python//gazelle:parse", - "@rules_python//gazelle:std_modules", + "@rules_python_gazelle_plugin//python:parse", + "@rules_python_gazelle_plugin//python:std_modules", ] diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 15150c9afb..26f8c66aec 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -1,4 +1,18 @@ -"This file managed by `bazel run //:update_go_deps`" +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"This file managed by `bazel run //:gazelle_update_repos`" load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") @@ -14,12 +28,7 @@ def gazelle_deps(): sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=", version = "v0.0.0-20190523083050-ea95bdfd59fc", ) - go_repository( - name = "com_github_bazelbuild_bazel_gazelle", - importpath = "github.com/bazelbuild/bazel-gazelle", - sum = "h1:+/ZhUxlDy4XnyMIGeKkbRZoIGssy1eO51GijwIvvuwE=", - version = "v0.27.0", - ) + go_repository( name = "com_github_bazelbuild_buildtools", build_naming_convention = "go_default_library", @@ -27,24 +36,14 @@ def gazelle_deps(): sum = "h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8=", version = "v0.0.0-20221004120235-7186f635531b", ) - go_repository( - name = "com_github_bazelbuild_rules_go", - importpath = "github.com/bazelbuild/rules_go", - sum = "h1:ViPR65vOrg74JKntAUFY6qZkheBKGB6to7wFd8gCRU4=", - version = "v0.35.0", - ) + go_repository( name = "com_github_bmatcuk_doublestar", importpath = "github.com/bmatcuk/doublestar", sum = "h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=", version = "v1.3.4", ) - go_repository( - name = "com_github_bmatcuk_doublestar_v4", - importpath = "github.com/bmatcuk/doublestar/v4", - sum = "h1:Qu+u9wR3Vd89LnlLMHvnZ5coJMWKQamqdz9/p5GNthA=", - version = "v4.2.0", - ) + go_repository( name = "com_github_burntsushi_toml", importpath = "github.com/BurntSushi/toml", @@ -99,12 +98,7 @@ def gazelle_deps(): sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", version = "v0.1.0", ) - go_repository( - name = "com_github_fsnotify_fsnotify", - importpath = "github.com/fsnotify/fsnotify", - sum = "h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=", - version = "v1.5.4", - ) + go_repository( name = "com_github_ghodss_yaml", importpath = "github.com/ghodss/yaml", @@ -120,14 +114,14 @@ def gazelle_deps(): go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", - sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", - version = "v1.6.0", + sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=", + version = "v1.1.1", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", - sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", - version = "v1.5.2", + sum = "h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=", + version = "v1.4.3", ) go_repository( name = "com_github_google_go_cmp", @@ -135,24 +129,7 @@ def gazelle_deps(): sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", version = "v0.5.9", ) - go_repository( - name = "com_github_google_uuid", - importpath = "github.com/google/uuid", - sum = "h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=", - version = "v1.3.0", - ) - go_repository( - name = "com_github_pelletier_go_toml", - importpath = "github.com/pelletier/go-toml", - sum = "h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=", - version = "v1.9.5", - ) - go_repository( - name = "com_github_pmezard_go_difflib", - importpath = "github.com/pmezard/go-difflib", - sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", - version = "v1.0.0", - ) + go_repository( name = "com_github_prometheus_client_model", importpath = "github.com/prometheus/client_model", @@ -210,8 +187,8 @@ def gazelle_deps(): go_repository( name = "org_golang_google_protobuf", importpath = "google.golang.org/protobuf", - sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=", - version = "v1.28.0", + sum = "h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=", + version = "v1.25.0", ) go_repository( name = "org_golang_x_crypto", @@ -252,8 +229,8 @@ def gazelle_deps(): go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", - sum = "h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=", - version = "v0.0.0-20220907140024-f12130a52804", + sum = "h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=", + version = "v0.0.0-20220722155255-886fb9371eb4", ) go_repository( name = "org_golang_x_sys", diff --git a/gazelle/go.mod b/gazelle/go.mod new file mode 100644 index 0000000000..94f19e801f --- /dev/null +++ b/gazelle/go.mod @@ -0,0 +1,17 @@ +module github.com/bazelbuild/rules_python/gazelle + +go 1.19 + +require ( + github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b + github.com/bmatcuk/doublestar v1.3.4 + github.com/emirpasic/gods v1.18.1 + github.com/ghodss/yaml v1.0.0 + gopkg.in/yaml.v2 v2.4.0 +) + +require ( + github.com/google/go-cmp v0.5.9 // indirect + golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect + golang.org/x/tools v0.1.12 // indirect +) diff --git a/gazelle/go.sum b/gazelle/go.sum new file mode 100644 index 0000000000..ed8ceae5ec --- /dev/null +++ b/gazelle/go.sum @@ -0,0 +1,92 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/bazelbuild/bazel-gazelle v0.27.0 h1:+/ZhUxlDy4XnyMIGeKkbRZoIGssy1eO51GijwIvvuwE= +github.com/bazelbuild/bazel-gazelle v0.27.0/go.mod h1:2K6B42/loq8ext4JObmam4gTYx4En1MUSzHFKQF8hPM= +github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8= +github.com/bazelbuild/buildtools v0.0.0-20221004120235-7186f635531b/go.mod h1:689QdV3hBP7Vo9dJMmzhoYIyo/9iMhEmHkJcnaPRCbo= +github.com/bazelbuild/rules_go v0.35.0 h1:ViPR65vOrg74JKntAUFY6qZkheBKGB6to7wFd8gCRU4= +github.com/bazelbuild/rules_go v0.35.0/go.mod h1:ahciH68Viyxtm/gvCQplaAiu8buhf/b+gWswcPjFixI= +github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0= +github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +go.starlark.net v0.0.0-20210223155950-e043a3d3c984/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc= +golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/gazelle/manifest/BUILD.bazel b/gazelle/manifest/BUILD.bazel index 281bcd29cf..fc7fa09632 100644 --- a/gazelle/manifest/BUILD.bazel +++ b/gazelle/manifest/BUILD.bazel @@ -17,3 +17,13 @@ go_test( data = glob(["testdata/**"]), deps = [":manifest"], ) + +filegroup( + name = "distribution", + srcs = glob(["**"]) + [ + "//manifest/generate:distribution", + "//manifest/hasher:distribution", + "//manifest/test:distribution", + ], + visibility = ["//:__pkg__"], +) diff --git a/gazelle/manifest/defs.bzl b/gazelle/manifest/defs.bzl index 8439319238..05562a1583 100644 --- a/gazelle/manifest/defs.bzl +++ b/gazelle/manifest/defs.bzl @@ -1,24 +1,39 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """This module provides the gazelle_python_manifest macro that contains targets for updating and testing the Gazelle manifest file. """ -load("@io_bazel_rules_go//go:def.bzl", "go_binary") +load("@io_bazel_rules_go//go:def.bzl", "GoSource", "go_binary", "go_test") def gazelle_python_manifest( name, requirements, modules_mapping, pip_repository_name = "", - pip_repository_incremental = False, pip_deps_repository_name = "", - manifest = ":gazelle_python.yaml"): + manifest = ":gazelle_python.yaml", + use_pip_repository_aliases = False): """A macro for defining the updating and testing targets for the Gazelle manifest file. Args: name: the name used as a base for the targets. requirements: the target for the requirements.txt file. pip_repository_name: the name of the pip_install or pip_repository target. - pip_repository_incremental: the incremental property of pip_repository. + use_pip_repository_aliases: boolean flag to enable using user-friendly + python package aliases. pip_deps_repository_name: deprecated - the old pip_install target name. modules_mapping: the target for the generated modules_mapping.json file. manifest: the target for the Gazelle manifest file. @@ -38,7 +53,11 @@ def gazelle_python_manifest( update_target = "{}.update".format(name) update_target_label = "//{}:{}".format(native.package_name(), update_target) + manifest_generator_hash = Label("//manifest/generate:generate_lib_sources_hash") + update_args = [ + "--manifest-generator-hash", + "$(rootpath {})".format(manifest_generator_hash), "--requirements", "$(rootpath {})".format(requirements), "--pip-repository-name", @@ -50,45 +69,43 @@ def gazelle_python_manifest( "--update-target", update_target_label, ] - if pip_repository_incremental: - update_args.append("--pip-repository-incremental") + + if use_pip_repository_aliases: + update_args += [ + "--use-pip-repository-aliases", + "true", + ] go_binary( name = update_target, - embed = ["@rules_python//gazelle/manifest/generate:generate_lib"], + embed = [Label("//manifest/generate:generate_lib")], data = [ manifest, modules_mapping, requirements, + manifest_generator_hash, ], args = update_args, visibility = ["//visibility:private"], tags = ["manual"], ) - test_binary = "_{}_test_bin".format(name) - - go_binary( - name = test_binary, - embed = ["@rules_python//gazelle/manifest/test:test_lib"], - visibility = ["//visibility:private"], - ) - - native.sh_test( + go_test( name = "{}.test".format(name), - srcs = ["@rules_python//gazelle/manifest/test:run.sh"], + srcs = [Label("//manifest/test:test.go")], data = [ - ":{}".format(test_binary), manifest, requirements, + manifest_generator_hash, ], env = { - "_TEST_BINARY": "$(rootpath :{})".format(test_binary), "_TEST_MANIFEST": "$(rootpath {})".format(manifest), + "_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash), "_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements), }, - visibility = ["//visibility:private"], - timeout = "short", + rundir = ".", + deps = [Label("//manifest")], + size = "small", ) native.filegroup( @@ -97,3 +114,56 @@ def gazelle_python_manifest( tags = ["manual"], visibility = ["//visibility:public"], ) + +# buildifier: disable=provider-params +AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the target and dependencies."}) + +_rules_python_workspace = Label("@rules_python//:WORKSPACE") + +def _get_all_sources_impl(target, ctx): + is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name + if not is_rules_python: + # Avoid adding third-party dependency files to the checksum of the srcs. + return AllSourcesInfo(all_srcs = depset()) + srcs = depset( + target[GoSource].orig_srcs, + transitive = [dep[AllSourcesInfo].all_srcs for dep in ctx.rule.attr.deps], + ) + return [AllSourcesInfo(all_srcs = srcs)] + +_get_all_sources = aspect( + implementation = _get_all_sources_impl, + attr_aspects = ["deps"], +) + +def _sources_hash_impl(ctx): + all_srcs = ctx.attr.go_library[AllSourcesInfo].all_srcs + hash_file = ctx.actions.declare_file(ctx.attr.name + ".hash") + args = ctx.actions.args() + args.add(hash_file) + args.add_all(all_srcs) + ctx.actions.run( + outputs = [hash_file], + inputs = all_srcs, + arguments = [args], + executable = ctx.executable._hasher, + ) + return [DefaultInfo( + files = depset([hash_file]), + runfiles = ctx.runfiles([hash_file]), + )] + +sources_hash = rule( + _sources_hash_impl, + attrs = { + "go_library": attr.label( + aspects = [_get_all_sources], + providers = [GoSource], + ), + "_hasher": attr.label( + cfg = "exec", + default = Label("//manifest/hasher"), + executable = True, + ), + }, +) diff --git a/gazelle/manifest/generate/BUILD.bazel b/gazelle/manifest/generate/BUILD.bazel index 29b9f15628..96248f4e08 100644 --- a/gazelle/manifest/generate/BUILD.bazel +++ b/gazelle/manifest/generate/BUILD.bazel @@ -1,11 +1,18 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +load("//manifest:defs.bzl", "sources_hash") go_library( name = "generate_lib", srcs = ["generate.go"], importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/generate", visibility = ["//visibility:public"], - deps = ["//gazelle/manifest"], + deps = ["//manifest"], +) + +sources_hash( + name = "generate_lib_sources_hash", + go_library = ":generate_lib", + visibility = ["//visibility:public"], ) go_binary( @@ -13,3 +20,9 @@ go_binary( embed = [":generate_lib"], visibility = ["//visibility:public"], ) + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//manifest:__pkg__"], +) diff --git a/gazelle/manifest/generate/generate.go b/gazelle/manifest/generate/generate.go index 04d7441fd2..1f56e630cc 100644 --- a/gazelle/manifest/generate/generate.go +++ b/gazelle/manifest/generate/generate.go @@ -1,3 +1,17 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* generate.go is a program that generates the Gazelle YAML manifest. @@ -24,12 +38,21 @@ func init() { } func main() { - var requirementsPath string - var pipRepositoryName string - var pipRepositoryIncremental bool - var modulesMappingPath string - var outputPath string - var updateTarget string + var ( + manifestGeneratorHashPath string + requirementsPath string + pipRepositoryName string + usePipRepositoryAliases bool + modulesMappingPath string + outputPath string + updateTarget string + ) + flag.StringVar( + &manifestGeneratorHashPath, + "manifest-generator-hash", + "", + "The file containing the hash for the source code of the manifest generator."+ + "This is important to force manifest updates when the generator logic changes.") flag.StringVar( &requirementsPath, "requirements", @@ -41,10 +64,10 @@ func main() { "", "The name of the pip_install or pip_repository target.") flag.BoolVar( - &pipRepositoryIncremental, - "pip-repository-incremental", + &usePipRepositoryAliases, + "use-pip-repository-aliases", false, - "The value for the incremental option in pip_repository.") + "Whether to use the pip-repository aliases, which are generated when passing 'incompatible_generate_aliases = True'.") flag.StringVar( &modulesMappingPath, "modules-mapping", @@ -88,11 +111,17 @@ func main() { manifestFile := manifest.NewFile(&manifest.Manifest{ ModulesMapping: modulesMapping, PipRepository: &manifest.PipRepository{ - Name: pipRepositoryName, - Incremental: pipRepositoryIncremental, + Name: pipRepositoryName, + UsePipRepositoryAliases: usePipRepositoryAliases, }, }) - if err := writeOutput(outputPath, header, manifestFile, requirementsPath); err != nil { + if err := writeOutput( + outputPath, + header, + manifestFile, + manifestGeneratorHashPath, + requirementsPath, + ); err != nil { log.Fatalf("ERROR: %v\n", err) } } @@ -129,6 +158,7 @@ func writeOutput( outputPath string, header string, manifestFile *manifest.File, + manifestGeneratorHashPath string, requirementsPath string, ) error { stat, err := os.Stat(outputPath) @@ -146,7 +176,19 @@ func writeOutput( return fmt.Errorf("failed to write output: %w", err) } - if err := manifestFile.Encode(outputFile, requirementsPath); err != nil { + manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath) + if err != nil { + return fmt.Errorf("failed to write output: %w", err) + } + defer manifestGeneratorHash.Close() + + requirements, err := os.Open(requirementsPath) + if err != nil { + return fmt.Errorf("failed to write output: %w", err) + } + defer requirements.Close() + + if err := manifestFile.Encode(outputFile, manifestGeneratorHash, requirements); err != nil { return fmt.Errorf("failed to write output: %w", err) } diff --git a/gazelle/manifest/hasher/BUILD.bazel b/gazelle/manifest/hasher/BUILD.bazel new file mode 100644 index 0000000000..2e7b125cc0 --- /dev/null +++ b/gazelle/manifest/hasher/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") + +go_library( + name = "hasher_lib", + srcs = ["main.go"], + importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/hasher", + visibility = ["//visibility:private"], +) + +go_binary( + name = "hasher", + embed = [":hasher_lib"], + visibility = ["//visibility:public"], +) + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//manifest:__pkg__"], +) diff --git a/gazelle/manifest/hasher/main.go b/gazelle/manifest/hasher/main.go new file mode 100644 index 0000000000..61f8952904 --- /dev/null +++ b/gazelle/manifest/hasher/main.go @@ -0,0 +1,44 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "crypto/sha256" + "io" + "log" + "os" +) + +func main() { + h := sha256.New() + out, err := os.Create(os.Args[1]) + if err != nil { + log.Fatal(err) + } + defer out.Close() + for _, filename := range os.Args[2:] { + f, err := os.Open(filename) + if err != nil { + log.Fatal(err) + } + defer f.Close() + if _, err := io.Copy(h, f); err != nil { + log.Fatal(err) + } + } + if _, err := out.Write(h.Sum(nil)); err != nil { + log.Fatal(err) + } +} diff --git a/gazelle/manifest/manifest.go b/gazelle/manifest/manifest.go index e19162bd5d..c49951dd3e 100644 --- a/gazelle/manifest/manifest.go +++ b/gazelle/manifest/manifest.go @@ -1,3 +1,17 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package manifest import ( @@ -26,12 +40,8 @@ func NewFile(manifest *Manifest) *File { } // Encode encodes the manifest file to the given writer. -func (f *File) Encode(w io.Writer, requirementsPath string) error { - requirementsChecksum, err := sha256File(requirementsPath) - if err != nil { - return fmt.Errorf("failed to encode manifest file: %w", err) - } - integrityBytes, err := f.calculateIntegrity(requirementsChecksum) +func (f *File) Encode(w io.Writer, manifestGeneratorHashFile, requirements io.Reader) error { + integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements) if err != nil { return fmt.Errorf("failed to encode manifest file: %w", err) } @@ -45,12 +55,8 @@ func (f *File) Encode(w io.Writer, requirementsPath string) error { } // VerifyIntegrity verifies if the integrity set in the File is valid. -func (f *File) VerifyIntegrity(requirementsPath string) (bool, error) { - requirementsChecksum, err := sha256File(requirementsPath) - if err != nil { - return false, fmt.Errorf("failed to verify integrity: %w", err) - } - integrityBytes, err := f.calculateIntegrity(requirementsChecksum) +func (f *File) VerifyIntegrity(manifestGeneratorHashFile, requirements io.Reader) (bool, error) { + integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements) if err != nil { return false, fmt.Errorf("failed to verify integrity: %w", err) } @@ -62,7 +68,9 @@ func (f *File) VerifyIntegrity(requirementsPath string) (bool, error) { // provided checksum for the requirements.txt file used as input to the modules // mapping, plus the manifest structure in the manifest file. This integrity // calculation ensures the manifest files are kept up-to-date. -func (f *File) calculateIntegrity(requirementsChecksum []byte) ([]byte, error) { +func (f *File) calculateIntegrity( + manifestGeneratorHash, requirements io.Reader, +) ([]byte, error) { hash := sha256.New() // Sum the manifest part of the file. @@ -72,8 +80,13 @@ func (f *File) calculateIntegrity(requirementsChecksum []byte) ([]byte, error) { return nil, fmt.Errorf("failed to calculate integrity: %w", err) } + // Sum the manifest generator checksum bytes. + if _, err := io.Copy(hash, manifestGeneratorHash); err != nil { + return nil, fmt.Errorf("failed to calculate integrity: %w", err) + } + // Sum the requirements.txt checksum bytes. - if _, err := hash.Write(requirementsChecksum); err != nil { + if _, err := io.Copy(hash, requirements); err != nil { return nil, fmt.Errorf("failed to calculate integrity: %w", err) } @@ -131,22 +144,7 @@ type Manifest struct { type PipRepository struct { // The name of the pip_install or pip_repository target. Name string - // The incremental property of pip_repository. - Incremental bool -} - -// sha256File calculates the checksum of a given file path. -func sha256File(filePath string) ([]byte, error) { - file, err := os.Open(filePath) - if err != nil { - return nil, fmt.Errorf("failed to calculate sha256 sum for file: %w", err) - } - defer file.Close() - - hash := sha256.New() - if _, err := io.Copy(hash, file); err != nil { - return nil, fmt.Errorf("failed to calculate sha256 sum for file: %w", err) - } - - return hash.Sum(nil), nil + // UsePipRepositoryAliases allows to use aliases generated pip_repository + // when passing incompatible_generate_aliases = True. + UsePipRepositoryAliases bool `yaml:"use_pip_repository_aliases,omitempty"` } diff --git a/gazelle/manifest/manifest_test.go b/gazelle/manifest/manifest_test.go index 3b50fd1b3e..43c4099aa1 100644 --- a/gazelle/manifest/manifest_test.go +++ b/gazelle/manifest/manifest_test.go @@ -1,10 +1,25 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package manifest_test import ( "bytes" - "io/ioutil" "log" + "os" "reflect" + "strings" "testing" "github.com/bazelbuild/rules_python/gazelle/manifest" @@ -31,11 +46,18 @@ func TestFile(t *testing.T) { PipDepsRepositoryName: pipDepsRepositoryName, }) var b bytes.Buffer - if err := f.Encode(&b, "testdata/requirements.txt"); err != nil { + manifestGeneratorHashFile := strings.NewReader("") + requirements, err := os.Open("testdata/requirements.txt") + if err != nil { + log.Println(err) + t.FailNow() + } + defer requirements.Close() + if err := f.Encode(&b, manifestGeneratorHashFile, requirements); err != nil { log.Println(err) t.FailNow() } - expected, err := ioutil.ReadFile("testdata/gazelle_python.yaml") + expected, err := os.ReadFile("testdata/gazelle_python.yaml") if err != nil { log.Println(err) t.FailNow() @@ -66,7 +88,14 @@ func TestFile(t *testing.T) { log.Println(err) t.FailNow() } - valid, err := f.VerifyIntegrity("testdata/requirements.txt") + manifestGeneratorHashFile := strings.NewReader("") + requirements, err := os.Open("testdata/requirements.txt") + if err != nil { + log.Println(err) + t.FailNow() + } + defer requirements.Close() + valid, err := f.VerifyIntegrity(manifestGeneratorHashFile, requirements) if err != nil { log.Println(err) t.FailNow() diff --git a/gazelle/manifest/test/BUILD.bazel b/gazelle/manifest/test/BUILD.bazel index f14845f756..28c6c548d9 100644 --- a/gazelle/manifest/test/BUILD.bazel +++ b/gazelle/manifest/test/BUILD.bazel @@ -1,17 +1,9 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") +# gazelle:ignore -go_library( - name = "test_lib", - srcs = ["test.go"], - importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/test", - visibility = ["//visibility:public"], - deps = ["//gazelle/manifest"], -) +exports_files(["test.go"]) -go_binary( - name = "test", - embed = [":test_lib"], - visibility = ["//visibility:public"], +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//manifest:__pkg__"], ) - -exports_files(["run.sh"]) diff --git a/gazelle/manifest/test/test.go b/gazelle/manifest/test/test.go index 518fe06eb6..72cb260d4d 100644 --- a/gazelle/manifest/test/test.go +++ b/gazelle/manifest/test/test.go @@ -1,63 +1,78 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + /* -test.go is a program that asserts the Gazelle YAML manifest is up-to-date in +test.go is a unit test that asserts the Gazelle YAML manifest is up-to-date in regards to the requirements.txt. It re-hashes the requirements.txt and compares it to the recorded one in the existing generated Gazelle manifest. */ -package main +package test import ( - "flag" - "log" + "os" "path/filepath" + "testing" "github.com/bazelbuild/rules_python/gazelle/manifest" ) -func main() { - var requirementsPath string - var manifestPath string - flag.StringVar( - &requirementsPath, - "requirements", - "", - "The requirements.txt file.") - flag.StringVar( - &manifestPath, - "manifest", - "", - "The manifest YAML file.") - flag.Parse() - +func TestGazelleManifestIsUpdated(t *testing.T) { + requirementsPath := os.Getenv("_TEST_REQUIREMENTS") if requirementsPath == "" { - log.Fatalln("ERROR: --requirements must be set") + t.Fatalf("_TEST_REQUIREMENTS must be set") } + manifestPath := os.Getenv("_TEST_MANIFEST") if manifestPath == "" { - log.Fatalln("ERROR: --manifest must be set") + t.Fatalf("_TEST_MANIFEST must be set") } manifestFile := new(manifest.File) if err := manifestFile.Decode(manifestPath); err != nil { - log.Fatalf("ERROR: %v\n", err) + t.Fatalf("decoding manifest file: %v", err) } if manifestFile.Integrity == "" { - log.Fatalln("ERROR: failed to find the Gazelle manifest file integrity") + t.Fatal("failed to find the Gazelle manifest file integrity") + } + + manifestGeneratorHashPath := os.Getenv("_TEST_MANIFEST_GENERATOR_HASH") + manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath) + if err != nil { + t.Fatalf("opening %q: %v", manifestGeneratorHashPath, err) + } + defer manifestGeneratorHash.Close() + + requirements, err := os.Open(requirementsPath) + if err != nil { + t.Fatalf("opening %q: %v", requirementsPath, err) } + defer requirements.Close() - valid, err := manifestFile.VerifyIntegrity(requirementsPath) + valid, err := manifestFile.VerifyIntegrity(manifestGeneratorHash, requirements) if err != nil { - log.Fatalf("ERROR: %v\n", err) + t.Fatalf("verifying integrity: %v", err) } if !valid { manifestRealpath, err := filepath.EvalSymlinks(manifestPath) if err != nil { - log.Fatalf("ERROR: %v\n", err) + t.Fatalf("evaluating symlink %q: %v", manifestPath, err) } - log.Fatalf( - "ERROR: %q is out-of-date, follow the intructions on this file for updating.\n", + t.Errorf( + "%q is out-of-date. Follow the update instructions in that file to resolve this", manifestRealpath) } -} \ No newline at end of file +} diff --git a/gazelle/manifest/testdata/gazelle_python.yaml b/gazelle/manifest/testdata/gazelle_python.yaml index 4dc1f2c545..70f7aff19a 100644 --- a/gazelle/manifest/testdata/gazelle_python.yaml +++ b/gazelle/manifest/testdata/gazelle_python.yaml @@ -10,4 +10,4 @@ manifest: arrow.parser: arrow arrow.util: arrow pip_deps_repository_name: test_repository_name -integrity: 624f5f6c078eb44b907efd5a64e308354ac3620c568232b815668bcdf3e3366a +integrity: eedf187f8b7ec27cdfc682feee4206e063b51d13d78f77c05d3a30ec11bd7411 diff --git a/gazelle/modules_mapping/BUILD.bazel b/gazelle/modules_mapping/BUILD.bazel index d1cd42e7d9..1855551a80 100644 --- a/gazelle/modules_mapping/BUILD.bazel +++ b/gazelle/modules_mapping/BUILD.bazel @@ -5,3 +5,9 @@ py_binary( srcs = ["generator.py"], visibility = ["//visibility:public"], ) + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//:__pkg__"], +) diff --git a/gazelle/modules_mapping/def.bzl b/gazelle/modules_mapping/def.bzl index 04ea50facd..54fc8add80 100644 --- a/gazelle/modules_mapping/def.bzl +++ b/gazelle/modules_mapping/def.bzl @@ -1,3 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Definitions for the modules_mapping.json generation. The modules_mapping.json file is a mapping from Python modules to the wheel @@ -12,8 +26,9 @@ module name doesn't match the wheel distribution name. def _modules_mapping_impl(ctx): modules_mapping = ctx.actions.declare_file(ctx.attr.modules_mapping_name) args = ctx.actions.args() - args.add(modules_mapping.path) - args.add_all([whl.path for whl in ctx.files.wheels]) + args.add("--output_file", modules_mapping.path) + args.add_all("--exclude_patterns", ctx.attr.exclude_patterns) + args.add_all("--wheels", [whl.path for whl in ctx.files.wheels]) ctx.actions.run( inputs = ctx.files.wheels, outputs = [modules_mapping], @@ -26,6 +41,11 @@ def _modules_mapping_impl(ctx): modules_mapping = rule( _modules_mapping_impl, attrs = { + "exclude_patterns": attr.string_list( + default = ["^_|(\\._)+"], + doc = "A set of regex patterns to match against each calculated module path. By default, exclude the modules starting with underscores.", + mandatory = False, + ), "modules_mapping_name": attr.string( default = "modules_mapping.json", doc = "The name for the output JSON file.", @@ -38,7 +58,7 @@ modules_mapping = rule( ), "_generator": attr.label( cfg = "exec", - default = "//gazelle/modules_mapping:generator", + default = "//modules_mapping:generator", executable = True, ), }, diff --git a/gazelle/modules_mapping/generator.py b/gazelle/modules_mapping/generator.py index ec3133af0e..be57eac3bc 100644 --- a/gazelle/modules_mapping/generator.py +++ b/gazelle/modules_mapping/generator.py @@ -1,5 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse import json import pathlib +import re import sys import zipfile @@ -8,36 +24,69 @@ class Generator: stderr = None output_file = None + excluded_patterns = None + mapping = {} - def __init__(self, stderr, output_file): + def __init__(self, stderr, output_file, excluded_patterns): self.stderr = stderr self.output_file = output_file + self.excluded_patterns = [re.compile(pattern) for pattern in excluded_patterns] # dig_wheel analyses the wheel .whl file determining the modules it provides # by looking at the directory structure. def dig_wheel(self, whl): - mapping = {} with zipfile.ZipFile(whl, "r") as zip_file: for path in zip_file.namelist(): if is_metadata(path): if data_has_purelib_or_platlib(path): - module_for_path(path, whl, mapping) + self.module_for_path(path, whl) else: continue else: - module_for_path(path, whl, mapping) - return mapping + self.module_for_path(path, whl) + + def module_for_path(self, path, whl): + ext = pathlib.Path(path).suffix + if ext == ".py" or ext == ".so": + if "purelib" in path or "platlib" in path: + root = "/".join(path.split("/")[2:]) + else: + root = path + + wheel_name = get_wheel_name(whl) + + if root.endswith("/__init__.py"): + # Note the '/' here means that the __init__.py is not in the + # root of the wheel, therefore we can index the directory + # where this file is as an importable package. + module = root[: -len("/__init__.py")].replace("/", ".") + if not self.is_excluded(module): + self.mapping[module] = wheel_name + + # Always index the module file. + if ext == ".so": + # Also remove extra metadata that is embeded as part of + # the file name as an extra extension. + ext = "".join(pathlib.Path(root).suffixes) + module = root[: -len(ext)].replace("/", ".") + if not self.is_excluded(module): + self.mapping[module] = wheel_name + + def is_excluded(self, module): + for pattern in self.excluded_patterns: + if pattern.search(module): + return True + return False # run is the entrypoint for the generator. def run(self, wheels): - mapping = {} for whl in wheels: try: - mapping.update(self.dig_wheel(whl)) + self.dig_wheel(whl) except AssertionError as error: print(error, file=self.stderr) return 1 - mapping_json = json.dumps(mapping) + mapping_json = json.dumps(self.mapping) with open(self.output_file, "w") as f: f.write(mapping_json) return 0 @@ -71,34 +120,14 @@ def data_has_purelib_or_platlib(path): return is_metadata(path) and (maybe_lib == "purelib" or maybe_lib == "platlib") -def module_for_path(path, whl, mapping): - ext = pathlib.Path(path).suffix - if ext == ".py" or ext == ".so": - if "purelib" in path or "platlib" in path: - root = "/".join(path.split("/")[2:]) - else: - root = path - - wheel_name = get_wheel_name(whl) - - if root.endswith("/__init__.py"): - # Note the '/' here means that the __init__.py is not in the - # root of the wheel, therefore we can index the directory - # where this file is as an importable package. - module = root[: -len("/__init__.py")].replace("/", ".") - mapping[module] = wheel_name - - # Always index the module file. - if ext == ".so": - # Also remove extra metadata that is embeded as part of - # the file name as an extra extension. - ext = "".join(pathlib.Path(root).suffixes) - module = root[: -len(ext)].replace("/", ".") - mapping[module] = wheel_name - - if __name__ == "__main__": - output_file = sys.argv[1] - wheels = sys.argv[2:] - generator = Generator(sys.stderr, output_file) - exit(generator.run(wheels)) + parser = argparse.ArgumentParser( + prog="generator", + description="Generates the modules mapping used by the Gazelle manifest.", + ) + parser.add_argument("--output_file", type=str) + parser.add_argument("--exclude_patterns", nargs="+", default=[]) + parser.add_argument("--wheels", nargs="+", default=[]) + args = parser.parse_args() + generator = Generator(sys.stderr, args.output_file, args.exclude_patterns) + exit(generator.run(args.wheels)) diff --git a/gazelle/python/BUILD.bazel b/gazelle/python/BUILD.bazel new file mode 100644 index 0000000000..ddcad2785d --- /dev/null +++ b/gazelle/python/BUILD.bazel @@ -0,0 +1,79 @@ +load("@bazel_gazelle//:def.bzl", "gazelle_binary") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@rules_python//python:defs.bzl", "py_binary") + +go_library( + name = "python", + srcs = [ + "configure.go", + "fix.go", + "generate.go", + "kinds.go", + "language.go", + "parser.go", + "resolve.go", + "std_modules.go", + "target.go", + ], + data = [ + ":parse", + ":std_modules", + ], + importpath = "github.com/bazelbuild/rules_python/gazelle/python", + visibility = ["//visibility:public"], + deps = [ + "//manifest", + "//pythonconfig", + "@bazel_gazelle//config:go_default_library", + "@bazel_gazelle//label:go_default_library", + "@bazel_gazelle//language:go_default_library", + "@bazel_gazelle//repo:go_default_library", + "@bazel_gazelle//resolve:go_default_library", + "@bazel_gazelle//rule:go_default_library", + "@com_github_bazelbuild_buildtools//build:go_default_library", + "@com_github_bmatcuk_doublestar//:doublestar", + "@com_github_emirpasic_gods//lists/singlylinkedlist", + "@com_github_emirpasic_gods//sets/treeset", + "@com_github_emirpasic_gods//utils", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", + ], +) + +py_binary( + name = "parse", + srcs = ["parse.py"], + visibility = ["//visibility:public"], +) + +py_binary( + name = "std_modules", + srcs = ["std_modules.py"], + visibility = ["//visibility:public"], +) + +go_test( + name = "python_test", + srcs = ["python_test.go"], + data = [ + ":gazelle_binary", + ":parse", + ":std_modules", + ] + glob(["testdata/**"]), + deps = [ + "@bazel_gazelle//testtools:go_default_library", + "@com_github_ghodss_yaml//:yaml", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", + ], +) + +gazelle_binary( + name = "gazelle_binary", + languages = [":python"], + visibility = ["//visibility:public"], +) + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//:__pkg__"], +) diff --git a/gazelle/python/configure.go b/gazelle/python/configure.go new file mode 100644 index 0000000000..32f9ab0a11 --- /dev/null +++ b/gazelle/python/configure.go @@ -0,0 +1,178 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "flag" + "fmt" + "log" + "os" + "path/filepath" + "strconv" + "strings" + + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/rule" + + "github.com/bazelbuild/rules_python/gazelle/manifest" + "github.com/bazelbuild/rules_python/gazelle/pythonconfig" +) + +// Configurer satisfies the config.Configurer interface. It's the +// language-specific configuration extension. +type Configurer struct{} + +// RegisterFlags registers command-line flags used by the extension. This +// method is called once with the root configuration when Gazelle +// starts. RegisterFlags may set an initial values in Config.Exts. When flags +// are set, they should modify these values. +func (py *Configurer) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {} + +// CheckFlags validates the configuration after command line flags are parsed. +// This is called once with the root configuration when Gazelle starts. +// CheckFlags may set default values in flags or make implied changes. +func (py *Configurer) CheckFlags(fs *flag.FlagSet, c *config.Config) error { + return nil +} + +// KnownDirectives returns a list of directive keys that this Configurer can +// interpret. Gazelle prints errors for directives that are not recoginized by +// any Configurer. +func (py *Configurer) KnownDirectives() []string { + return []string{ + pythonconfig.PythonExtensionDirective, + pythonconfig.PythonRootDirective, + pythonconfig.PythonManifestFileNameDirective, + pythonconfig.IgnoreFilesDirective, + pythonconfig.IgnoreDependenciesDirective, + pythonconfig.ValidateImportStatementsDirective, + pythonconfig.GenerationMode, + pythonconfig.LibraryNamingConvention, + pythonconfig.BinaryNamingConvention, + pythonconfig.TestNamingConvention, + } +} + +// Configure modifies the configuration using directives and other information +// extracted from a build file. Configure is called in each directory. +// +// c is the configuration for the current directory. It starts out as a copy +// of the configuration for the parent directory. +// +// rel is the slash-separated relative path from the repository root to +// the current directory. It is "" for the root directory itself. +// +// f is the build file for the current directory or nil if there is no +// existing build file. +func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) { + // Create the root config. + if _, exists := c.Exts[languageName]; !exists { + rootConfig := pythonconfig.New(c.RepoRoot, "") + c.Exts[languageName] = pythonconfig.Configs{"": rootConfig} + } + + configs := c.Exts[languageName].(pythonconfig.Configs) + + config, exists := configs[rel] + if !exists { + parent := configs.ParentForPackage(rel) + config = parent.NewChild() + configs[rel] = config + } + + if f == nil { + return + } + + gazelleManifestFilename := "gazelle_python.yaml" + + for _, d := range f.Directives { + switch d.Key { + case "exclude": + // We record the exclude directive for coarse-grained packages + // since we do manual tree traversal in this mode. + config.AddExcludedPattern(filepath.Join(rel, strings.TrimSpace(d.Value))) + case pythonconfig.PythonExtensionDirective: + switch d.Value { + case "enabled": + config.SetExtensionEnabled(true) + case "disabled": + config.SetExtensionEnabled(false) + default: + err := fmt.Errorf("invalid value for directive %q: %s: possible values are enabled/disabled", + pythonconfig.PythonExtensionDirective, d.Value) + log.Fatal(err) + } + case pythonconfig.PythonRootDirective: + config.SetPythonProjectRoot(rel) + case pythonconfig.PythonManifestFileNameDirective: + gazelleManifestFilename = strings.TrimSpace(d.Value) + case pythonconfig.IgnoreFilesDirective: + for _, ignoreFile := range strings.Split(d.Value, ",") { + config.AddIgnoreFile(ignoreFile) + } + case pythonconfig.IgnoreDependenciesDirective: + for _, ignoreDependency := range strings.Split(d.Value, ",") { + config.AddIgnoreDependency(ignoreDependency) + } + case pythonconfig.ValidateImportStatementsDirective: + v, err := strconv.ParseBool(strings.TrimSpace(d.Value)) + if err != nil { + log.Fatal(err) + } + config.SetValidateImportStatements(v) + case pythonconfig.GenerationMode: + switch pythonconfig.GenerationModeType(strings.TrimSpace(d.Value)) { + case pythonconfig.GenerationModePackage: + config.SetCoarseGrainedGeneration(false) + case pythonconfig.GenerationModeProject: + config.SetCoarseGrainedGeneration(true) + default: + err := fmt.Errorf("invalid value for directive %q: %s", + pythonconfig.GenerationMode, d.Value) + log.Fatal(err) + } + case pythonconfig.LibraryNamingConvention: + config.SetLibraryNamingConvention(strings.TrimSpace(d.Value)) + case pythonconfig.BinaryNamingConvention: + config.SetBinaryNamingConvention(strings.TrimSpace(d.Value)) + case pythonconfig.TestNamingConvention: + config.SetTestNamingConvention(strings.TrimSpace(d.Value)) + } + } + + gazelleManifestPath := filepath.Join(c.RepoRoot, rel, gazelleManifestFilename) + gazelleManifest, err := py.loadGazelleManifest(gazelleManifestPath) + if err != nil { + log.Fatal(err) + } + if gazelleManifest != nil { + config.SetGazelleManifest(gazelleManifest) + } +} + +func (py *Configurer) loadGazelleManifest(gazelleManifestPath string) (*manifest.Manifest, error) { + if _, err := os.Stat(gazelleManifestPath); err != nil { + if os.IsNotExist(err) { + return nil, nil + } + return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err) + } + manifestFile := new(manifest.File) + if err := manifestFile.Decode(gazelleManifestPath); err != nil { + return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err) + } + return manifestFile.Manifest, nil +} diff --git a/gazelle/python/fix.go b/gazelle/python/fix.go new file mode 100644 index 0000000000..1ca42571ab --- /dev/null +++ b/gazelle/python/fix.go @@ -0,0 +1,27 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/rule" +) + +// Fix repairs deprecated usage of language-specific rules in f. This is +// called before the file is indexed. Unless c.ShouldFix is true, fixes +// that delete or rename rules should not be performed. +func (py *Python) Fix(c *config.Config, f *rule.File) { + // TODO(f0rmiga): implement. +} diff --git a/gazelle/python/generate.go b/gazelle/python/generate.go new file mode 100644 index 0000000000..fb41324fd6 --- /dev/null +++ b/gazelle/python/generate.go @@ -0,0 +1,444 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "fmt" + "io/fs" + "log" + "os" + "path/filepath" + "strings" + + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/label" + "github.com/bazelbuild/bazel-gazelle/language" + "github.com/bazelbuild/bazel-gazelle/rule" + "github.com/bazelbuild/rules_python/gazelle/pythonconfig" + "github.com/bmatcuk/doublestar" + "github.com/emirpasic/gods/lists/singlylinkedlist" + "github.com/emirpasic/gods/sets/treeset" + godsutils "github.com/emirpasic/gods/utils" +) + +const ( + pyLibraryEntrypointFilename = "__init__.py" + pyBinaryEntrypointFilename = "__main__.py" + pyTestEntrypointFilename = "__test__.py" + pyTestEntrypointTargetname = "__test__" + conftestFilename = "conftest.py" + conftestTargetname = "conftest" +) + +var ( + buildFilenames = []string{"BUILD", "BUILD.bazel"} +) + +func GetActualKindName(kind string, args language.GenerateArgs) string { + if kindOverride, ok := args.Config.KindMap[kind]; ok { + return kindOverride.KindName + } + return kind +} + +// GenerateRules extracts build metadata from source files in a directory. +// GenerateRules is called in each directory where an update is requested +// in depth-first post-order. +func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult { + cfgs := args.Config.Exts[languageName].(pythonconfig.Configs) + cfg := cfgs[args.Rel] + + if !cfg.ExtensionEnabled() { + return language.GenerateResult{} + } + + if !isBazelPackage(args.Dir) { + if cfg.CoarseGrainedGeneration() { + // Determine if the current directory is the root of the coarse-grained + // generation. If not, return without generating anything. + parent := cfg.Parent() + if parent != nil && parent.CoarseGrainedGeneration() { + return language.GenerateResult{} + } + } else if !hasEntrypointFile(args.Dir) { + return language.GenerateResult{} + } + } + + actualPyBinaryKind := GetActualKindName(pyBinaryKind, args) + actualPyLibraryKind := GetActualKindName(pyLibraryKind, args) + actualPyTestKind := GetActualKindName(pyTestKind, args) + + pythonProjectRoot := cfg.PythonProjectRoot() + + packageName := filepath.Base(args.Dir) + + pyLibraryFilenames := treeset.NewWith(godsutils.StringComparator) + pyTestFilenames := treeset.NewWith(godsutils.StringComparator) + pyFileNames := treeset.NewWith(godsutils.StringComparator) + + // hasPyBinary controls whether a py_binary target should be generated for + // this package or not. + hasPyBinary := false + + // hasPyTestEntryPointFile and hasPyTestEntryPointTarget control whether a py_test target should + // be generated for this package or not. + hasPyTestEntryPointFile := false + hasPyTestEntryPointTarget := false + hasConftestFile := false + + for _, f := range args.RegularFiles { + if cfg.IgnoresFile(filepath.Base(f)) { + continue + } + ext := filepath.Ext(f) + if ext == ".py" { + pyFileNames.Add(f) + if !hasPyBinary && f == pyBinaryEntrypointFilename { + hasPyBinary = true + } else if !hasPyTestEntryPointFile && f == pyTestEntrypointFilename { + hasPyTestEntryPointFile = true + } else if f == conftestFilename { + hasConftestFile = true + } else if strings.HasSuffix(f, "_test.py") || strings.HasPrefix(f, "test_") { + pyTestFilenames.Add(f) + } else { + pyLibraryFilenames.Add(f) + } + } + } + + // If a __test__.py file was not found on disk, search for targets that are + // named __test__. + if !hasPyTestEntryPointFile && args.File != nil { + for _, rule := range args.File.Rules { + if rule.Name() == pyTestEntrypointTargetname { + hasPyTestEntryPointTarget = true + break + } + } + } + + // Add files from subdirectories if they meet the criteria. + for _, d := range args.Subdirs { + // boundaryPackages represents child Bazel packages that are used as a + // boundary to stop processing under that tree. + boundaryPackages := make(map[string]struct{}) + err := filepath.WalkDir( + filepath.Join(args.Dir, d), + func(path string, entry fs.DirEntry, err error) error { + if err != nil { + return err + } + // Ignore the path if it crosses any boundary package. Walking + // the tree is still important because subsequent paths can + // represent files that have not crossed any boundaries. + for bp := range boundaryPackages { + if strings.HasPrefix(path, bp) { + return nil + } + } + if entry.IsDir() { + // If we are visiting a directory, we determine if we should + // halt digging the tree based on a few criterias: + // 1. The directory has a BUILD or BUILD.bazel files. Then + // it doesn't matter at all what it has since it's a + // separate Bazel package. + // 2. (only for fine-grained generation) The directory has + // an __init__.py, __main__.py or __test__.py, meaning + // a BUILD file will be generated. + if isBazelPackage(path) { + boundaryPackages[path] = struct{}{} + return nil + } + + if !cfg.CoarseGrainedGeneration() && hasEntrypointFile(path) { + return fs.SkipDir + } + + return nil + } + if filepath.Ext(path) == ".py" { + if cfg.CoarseGrainedGeneration() || !isEntrypointFile(path) { + srcPath, _ := filepath.Rel(args.Dir, path) + repoPath := filepath.Join(args.Rel, srcPath) + excludedPatterns := cfg.ExcludedPatterns() + if excludedPatterns != nil { + it := excludedPatterns.Iterator() + for it.Next() { + excludedPattern := it.Value().(string) + isExcluded, err := doublestar.Match(excludedPattern, repoPath) + if err != nil { + return err + } + if isExcluded { + return nil + } + } + } + baseName := filepath.Base(path) + if strings.HasSuffix(baseName, "_test.py") || strings.HasPrefix(baseName, "test_") { + pyTestFilenames.Add(srcPath) + } else { + pyLibraryFilenames.Add(srcPath) + } + } + } + return nil + }, + ) + if err != nil { + log.Printf("ERROR: %v\n", err) + return language.GenerateResult{} + } + } + + parser := newPython3Parser(args.Config.RepoRoot, args.Rel, cfg.IgnoresDependency) + visibility := fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot) + + var result language.GenerateResult + result.Gen = make([]*rule.Rule, 0) + + collisionErrors := singlylinkedlist.New() + + var pyLibrary *rule.Rule + if !pyLibraryFilenames.Empty() { + deps, err := parser.parse(pyLibraryFilenames) + if err != nil { + log.Fatalf("ERROR: %v\n", err) + } + + pyLibraryTargetName := cfg.RenderLibraryName(packageName) + + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. + if args.File != nil { + for _, t := range args.File.Rules { + if t.Name() == pyLibraryTargetName && t.Kind() != actualPyLibraryKind { + fqTarget := label.New("", args.Rel, pyLibraryTargetName) + err := fmt.Errorf("failed to generate target %q of kind %q: "+ + "a target of kind %q with the same name already exists. "+ + "Use the '# gazelle:%s' directive to change the naming convention.", + fqTarget.String(), actualPyLibraryKind, t.Kind(), pythonconfig.LibraryNamingConvention) + collisionErrors.Add(err) + } + } + } + + pyLibrary = newTargetBuilder(pyLibraryKind, pyLibraryTargetName, pythonProjectRoot, args.Rel, pyFileNames). + addVisibility(visibility). + addSrcs(pyLibraryFilenames). + addModuleDependencies(deps). + generateImportsAttribute(). + build() + + result.Gen = append(result.Gen, pyLibrary) + result.Imports = append(result.Imports, pyLibrary.PrivateAttr(config.GazelleImportsKey)) + } + + if hasPyBinary { + deps, err := parser.parseSingle(pyBinaryEntrypointFilename) + if err != nil { + log.Fatalf("ERROR: %v\n", err) + } + + pyBinaryTargetName := cfg.RenderBinaryName(packageName) + + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. + if args.File != nil { + for _, t := range args.File.Rules { + if t.Name() == pyBinaryTargetName && t.Kind() != actualPyBinaryKind { + fqTarget := label.New("", args.Rel, pyBinaryTargetName) + err := fmt.Errorf("failed to generate target %q of kind %q: "+ + "a target of kind %q with the same name already exists. "+ + "Use the '# gazelle:%s' directive to change the naming convention.", + fqTarget.String(), actualPyBinaryKind, t.Kind(), pythonconfig.BinaryNamingConvention) + collisionErrors.Add(err) + } + } + } + + pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames). + setMain(pyBinaryEntrypointFilename). + addVisibility(visibility). + addSrc(pyBinaryEntrypointFilename). + addModuleDependencies(deps). + generateImportsAttribute() + + pyBinary := pyBinaryTarget.build() + + result.Gen = append(result.Gen, pyBinary) + result.Imports = append(result.Imports, pyBinary.PrivateAttr(config.GazelleImportsKey)) + } + + var conftest *rule.Rule + if hasConftestFile { + deps, err := parser.parseSingle(conftestFilename) + if err != nil { + log.Fatalf("ERROR: %v\n", err) + } + + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. + if args.File != nil { + for _, t := range args.File.Rules { + if t.Name() == conftestTargetname && t.Kind() != actualPyLibraryKind { + fqTarget := label.New("", args.Rel, conftestTargetname) + err := fmt.Errorf("failed to generate target %q of kind %q: "+ + "a target of kind %q with the same name already exists.", + fqTarget.String(), actualPyLibraryKind, t.Kind()) + collisionErrors.Add(err) + } + } + } + + conftestTarget := newTargetBuilder(pyLibraryKind, conftestTargetname, pythonProjectRoot, args.Rel, pyFileNames). + addSrc(conftestFilename). + addModuleDependencies(deps). + addVisibility(visibility). + setTestonly(). + generateImportsAttribute() + + conftest = conftestTarget.build() + + result.Gen = append(result.Gen, conftest) + result.Imports = append(result.Imports, conftest.PrivateAttr(config.GazelleImportsKey)) + } + + var pyTestTargets []*targetBuilder + newPyTestTargetBuilder := func(srcs *treeset.Set, pyTestTargetName string) *targetBuilder { + deps, err := parser.parse(srcs) + if err != nil { + log.Fatalf("ERROR: %v\n", err) + } + // Check if a target with the same name we are generating already + // exists, and if it is of a different kind from the one we are + // generating. If so, we have to throw an error since Gazelle won't + // generate it correctly. + if args.File != nil { + for _, t := range args.File.Rules { + if t.Name() == pyTestTargetName && t.Kind() != actualPyTestKind { + fqTarget := label.New("", args.Rel, pyTestTargetName) + err := fmt.Errorf("failed to generate target %q of kind %q: "+ + "a target of kind %q with the same name already exists. "+ + "Use the '# gazelle:%s' directive to change the naming convention.", + fqTarget.String(), actualPyTestKind, t.Kind(), pythonconfig.TestNamingConvention) + collisionErrors.Add(err) + } + } + } + return newTargetBuilder(pyTestKind, pyTestTargetName, pythonProjectRoot, args.Rel, pyFileNames). + addSrcs(srcs). + addModuleDependencies(deps). + generateImportsAttribute() + } + if hasPyTestEntryPointFile || hasPyTestEntryPointTarget { + if hasPyTestEntryPointFile { + // Only add the pyTestEntrypointFilename to the pyTestFilenames if + // the file exists on disk. + pyTestFilenames.Add(pyTestEntrypointFilename) + } + pyTestTargetName := cfg.RenderTestName(packageName) + pyTestTarget := newPyTestTargetBuilder(pyTestFilenames, pyTestTargetName) + + if hasPyTestEntryPointTarget { + entrypointTarget := fmt.Sprintf(":%s", pyTestEntrypointTargetname) + main := fmt.Sprintf(":%s", pyTestEntrypointFilename) + pyTestTarget. + addSrc(entrypointTarget). + addResolvedDependency(entrypointTarget). + setMain(main) + } else { + pyTestTarget.setMain(pyTestEntrypointFilename) + } + pyTestTargets = append(pyTestTargets, pyTestTarget) + } else { + // Create one py_test target per file + pyTestFilenames.Each(func(index int, testFile interface{}) { + srcs := treeset.NewWith(godsutils.StringComparator, testFile) + pyTestTargetName := strings.TrimSuffix(filepath.Base(testFile.(string)), ".py") + pyTestTargets = append(pyTestTargets, newPyTestTargetBuilder(srcs, pyTestTargetName)) + }) + } + + for _, pyTestTarget := range pyTestTargets { + if conftest != nil { + pyTestTarget.addModuleDependency(module{Name: strings.TrimSuffix(conftestFilename, ".py")}) + } + pyTest := pyTestTarget.build() + + result.Gen = append(result.Gen, pyTest) + result.Imports = append(result.Imports, pyTest.PrivateAttr(config.GazelleImportsKey)) + } + + if !collisionErrors.Empty() { + it := collisionErrors.Iterator() + for it.Next() { + log.Printf("ERROR: %v\n", it.Value()) + } + os.Exit(1) + } + + return result +} + +// isBazelPackage determines if the directory is a Bazel package by probing for +// the existence of a known BUILD file name. +func isBazelPackage(dir string) bool { + for _, buildFilename := range buildFilenames { + path := filepath.Join(dir, buildFilename) + if _, err := os.Stat(path); err == nil { + return true + } + } + return false +} + +// hasEntrypointFile determines if the directory has any of the established +// entrypoint filenames. +func hasEntrypointFile(dir string) bool { + for _, entrypointFilename := range []string{ + pyLibraryEntrypointFilename, + pyBinaryEntrypointFilename, + pyTestEntrypointFilename, + } { + path := filepath.Join(dir, entrypointFilename) + if _, err := os.Stat(path); err == nil { + return true + } + } + return false +} + +// isEntrypointFile returns whether the given path is an entrypoint file. The +// given path can be absolute or relative. +func isEntrypointFile(path string) bool { + basePath := filepath.Base(path) + switch basePath { + case pyLibraryEntrypointFilename, + pyBinaryEntrypointFilename, + pyTestEntrypointFilename: + return true + default: + return false + } +} diff --git a/gazelle/python/kinds.go b/gazelle/python/kinds.go new file mode 100644 index 0000000000..ab1afb7d55 --- /dev/null +++ b/gazelle/python/kinds.go @@ -0,0 +1,102 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "github.com/bazelbuild/bazel-gazelle/rule" +) + +const ( + pyBinaryKind = "py_binary" + pyLibraryKind = "py_library" + pyTestKind = "py_test" +) + +// Kinds returns a map that maps rule names (kinds) and information on how to +// match and merge attributes that may be found in rules of those kinds. +func (*Python) Kinds() map[string]rule.KindInfo { + return pyKinds +} + +var pyKinds = map[string]rule.KindInfo{ + pyBinaryKind: { + MatchAny: true, + NonEmptyAttrs: map[string]bool{ + "deps": true, + "main": true, + "srcs": true, + "imports": true, + "visibility": true, + }, + SubstituteAttrs: map[string]bool{}, + MergeableAttrs: map[string]bool{ + "srcs": true, + }, + ResolveAttrs: map[string]bool{ + "deps": true, + }, + }, + pyLibraryKind: { + MatchAny: true, + NonEmptyAttrs: map[string]bool{ + "deps": true, + "srcs": true, + "imports": true, + "visibility": true, + }, + SubstituteAttrs: map[string]bool{}, + MergeableAttrs: map[string]bool{ + "srcs": true, + }, + ResolveAttrs: map[string]bool{ + "deps": true, + }, + }, + pyTestKind: { + MatchAny: false, + NonEmptyAttrs: map[string]bool{ + "deps": true, + "main": true, + "srcs": true, + "imports": true, + "visibility": true, + }, + SubstituteAttrs: map[string]bool{}, + MergeableAttrs: map[string]bool{ + "srcs": true, + }, + ResolveAttrs: map[string]bool{ + "deps": true, + }, + }, +} + +// Loads returns .bzl files and symbols they define. Every rule generated by +// GenerateRules, now or in the past, should be loadable from one of these +// files. +func (py *Python) Loads() []rule.LoadInfo { + return pyLoads +} + +var pyLoads = []rule.LoadInfo{ + { + Name: "@rules_python//python:defs.bzl", + Symbols: []string{ + pyBinaryKind, + pyLibraryKind, + pyTestKind, + }, + }, +} diff --git a/gazelle/python/language.go b/gazelle/python/language.go new file mode 100644 index 0000000000..56eb97b043 --- /dev/null +++ b/gazelle/python/language.go @@ -0,0 +1,32 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "github.com/bazelbuild/bazel-gazelle/language" +) + +// Python satisfies the language.Language interface. It is the Gazelle extension +// for Python rules. +type Python struct { + Configurer + Resolver +} + +// NewLanguage initializes a new Python that satisfies the language.Language +// interface. This is the entrypoint for the extension initialization. +func NewLanguage() language.Language { + return &Python{} +} diff --git a/gazelle/python/parse.py b/gazelle/python/parse.py new file mode 100644 index 0000000000..6c0ef69598 --- /dev/null +++ b/gazelle/python/parse.py @@ -0,0 +1,106 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# parse.py is a long-living program that communicates over STDIN and STDOUT. +# STDIN receives parse requests, one per line. It outputs the parsed modules and +# comments from all the files from each request. + +import ast +import concurrent.futures +import json +import os +import sys +from io import BytesIO +from tokenize import COMMENT, tokenize + + +def parse_import_statements(content, filepath): + modules = list() + tree = ast.parse(content, filename=filepath) + for node in ast.walk(tree): + if isinstance(node, ast.Import): + for subnode in node.names: + module = { + "name": subnode.name, + "lineno": node.lineno, + "filepath": filepath, + "from": "", + } + modules.append(module) + elif isinstance(node, ast.ImportFrom) and node.level == 0: + for subnode in node.names: + module = { + "name": f"{node.module}.{subnode.name}", + "lineno": node.lineno, + "filepath": filepath, + "from": node.module, + } + modules.append(module) + return modules + + +def parse_comments(content): + comments = list() + g = tokenize(BytesIO(content.encode("utf-8")).readline) + for toknum, tokval, _, _, _ in g: + if toknum == COMMENT: + comments.append(tokval) + return comments + + +def parse(repo_root, rel_package_path, filename): + rel_filepath = os.path.join(rel_package_path, filename) + abs_filepath = os.path.join(repo_root, rel_filepath) + with open(abs_filepath, "r") as file: + content = file.read() + # From simple benchmarks, 2 workers gave the best performance here. + with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: + modules_future = executor.submit( + parse_import_statements, content, rel_filepath + ) + comments_future = executor.submit(parse_comments, content) + modules = modules_future.result() + comments = comments_future.result() + output = { + "modules": modules, + "comments": comments, + } + return output + + +def main(stdin, stdout): + with concurrent.futures.ProcessPoolExecutor() as executor: + for parse_request in stdin: + parse_request = json.loads(parse_request) + repo_root = parse_request["repo_root"] + rel_package_path = parse_request["rel_package_path"] + filenames = parse_request["filenames"] + outputs = list() + if len(filenames) == 1: + outputs.append(parse(repo_root, rel_package_path, filenames[0])) + else: + futures = [ + executor.submit(parse, repo_root, rel_package_path, filename) + for filename in filenames + if filename != "" + ] + for future in concurrent.futures.as_completed(futures): + outputs.append(future.result()) + print(json.dumps(outputs), end="", file=stdout, flush=True) + stdout.buffer.write(bytes([0])) + stdout.flush() + + +if __name__ == "__main__": + exit(main(sys.stdin, sys.stdout)) diff --git a/gazelle/python/parser.go b/gazelle/python/parser.go new file mode 100644 index 0000000000..33eb6f4b33 --- /dev/null +++ b/gazelle/python/parser.go @@ -0,0 +1,277 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "bufio" + "context" + "encoding/json" + "fmt" + "io" + "log" + "os" + "os/exec" + "strings" + "sync" + "time" + + "github.com/bazelbuild/rules_go/go/tools/bazel" + "github.com/emirpasic/gods/sets/treeset" + godsutils "github.com/emirpasic/gods/utils" +) + +var ( + parserStdin io.Writer + parserStdout io.Reader + parserMutex sync.Mutex +) + +func init() { + parseScriptRunfile, err := bazel.Runfile("python/parse") + if err != nil { + log.Printf("failed to initialize parser: %v\n", err) + os.Exit(1) + } + + ctx := context.Background() + ctx, parserCancel := context.WithTimeout(ctx, time.Minute*10) + cmd := exec.CommandContext(ctx, parseScriptRunfile) + + cmd.Stderr = os.Stderr + + stdin, err := cmd.StdinPipe() + if err != nil { + log.Printf("failed to initialize parser: %v\n", err) + os.Exit(1) + } + parserStdin = stdin + + stdout, err := cmd.StdoutPipe() + if err != nil { + log.Printf("failed to initialize parser: %v\n", err) + os.Exit(1) + } + parserStdout = stdout + + if err := cmd.Start(); err != nil { + log.Printf("failed to initialize parser: %v\n", err) + os.Exit(1) + } + + go func() { + defer parserCancel() + if err := cmd.Wait(); err != nil { + log.Printf("failed to wait for parser: %v\n", err) + os.Exit(1) + } + }() +} + +// python3Parser implements a parser for Python files that extracts the modules +// as seen in the import statements. +type python3Parser struct { + // The value of language.GenerateArgs.Config.RepoRoot. + repoRoot string + // The value of language.GenerateArgs.Rel. + relPackagePath string + // The function that determines if a dependency is ignored from a Gazelle + // directive. It's the signature of pythonconfig.Config.IgnoresDependency. + ignoresDependency func(dep string) bool +} + +// newPython3Parser constructs a new python3Parser. +func newPython3Parser( + repoRoot string, + relPackagePath string, + ignoresDependency func(dep string) bool, +) *python3Parser { + return &python3Parser{ + repoRoot: repoRoot, + relPackagePath: relPackagePath, + ignoresDependency: ignoresDependency, + } +} + +// parseSingle parses a single Python file and returns the extracted modules +// from the import statements as well as the parsed comments. +func (p *python3Parser) parseSingle(pyFilename string) (*treeset.Set, error) { + pyFilenames := treeset.NewWith(godsutils.StringComparator) + pyFilenames.Add(pyFilename) + return p.parse(pyFilenames) +} + +// parse parses multiple Python files and returns the extracted modules from +// the import statements as well as the parsed comments. +func (p *python3Parser) parse(pyFilenames *treeset.Set) (*treeset.Set, error) { + parserMutex.Lock() + defer parserMutex.Unlock() + + modules := treeset.NewWith(moduleComparator) + + req := map[string]interface{}{ + "repo_root": p.repoRoot, + "rel_package_path": p.relPackagePath, + "filenames": pyFilenames.Values(), + } + encoder := json.NewEncoder(parserStdin) + if err := encoder.Encode(&req); err != nil { + return nil, fmt.Errorf("failed to parse: %w", err) + } + + reader := bufio.NewReader(parserStdout) + data, err := reader.ReadBytes(0) + if err != nil { + return nil, fmt.Errorf("failed to parse: %w", err) + } + data = data[:len(data)-1] + var allRes []parserResponse + if err := json.Unmarshal(data, &allRes); err != nil { + return nil, fmt.Errorf("failed to parse: %w", err) + } + + for _, res := range allRes { + annotations, err := annotationsFromComments(res.Comments) + if err != nil { + return nil, fmt.Errorf("failed to parse annotations: %w", err) + } + + for _, m := range res.Modules { + // Check for ignored dependencies set via an annotation to the Python + // module. + if annotations.ignores(m.Name) || annotations.ignores(m.From) { + continue + } + + // Check for ignored dependencies set via a Gazelle directive in a BUILD + // file. + if p.ignoresDependency(m.Name) || p.ignoresDependency(m.From) { + continue + } + + modules.Add(m) + } + } + + return modules, nil +} + +// parserResponse represents a response returned by the parser.py for a given +// parsed Python module. +type parserResponse struct { + // The modules depended by the parsed module. + Modules []module `json:"modules"` + // The comments contained in the parsed module. This contains the + // annotations as they are comments in the Python module. + Comments []comment `json:"comments"` +} + +// module represents a fully-qualified, dot-separated, Python module as seen on +// the import statement, alongside the line number where it happened. +type module struct { + // The fully-qualified, dot-separated, Python module name as seen on import + // statements. + Name string `json:"name"` + // The line number where the import happened. + LineNumber uint32 `json:"lineno"` + // The path to the module file relative to the Bazel workspace root. + Filepath string `json:"filepath"` + // If this was a from import, e.g. from foo import bar, From indicates the module + // from which it is imported. + From string `json:"from"` +} + +// moduleComparator compares modules by name. +func moduleComparator(a, b interface{}) int { + return godsutils.StringComparator(a.(module).Name, b.(module).Name) +} + +// annotationKind represents Gazelle annotation kinds. +type annotationKind string + +const ( + // The Gazelle annotation prefix. + annotationPrefix string = "gazelle:" + // The ignore annotation kind. E.g. '# gazelle:ignore '. + annotationKindIgnore annotationKind = "ignore" +) + +// comment represents a Python comment. +type comment string + +// asAnnotation returns an annotation object if the comment has the +// annotationPrefix. +func (c *comment) asAnnotation() (*annotation, error) { + uncomment := strings.TrimLeft(string(*c), "# ") + if !strings.HasPrefix(uncomment, annotationPrefix) { + return nil, nil + } + withoutPrefix := strings.TrimPrefix(uncomment, annotationPrefix) + annotationParts := strings.SplitN(withoutPrefix, " ", 2) + if len(annotationParts) < 2 { + return nil, fmt.Errorf("`%s` requires a value", *c) + } + return &annotation{ + kind: annotationKind(annotationParts[0]), + value: annotationParts[1], + }, nil +} + +// annotation represents a single Gazelle annotation parsed from a Python +// comment. +type annotation struct { + kind annotationKind + value string +} + +// annotations represent the collection of all Gazelle annotations parsed out of +// the comments of a Python module. +type annotations struct { + // The parsed modules to be ignored by Gazelle. + ignore map[string]struct{} +} + +// annotationsFromComments returns all the annotations parsed out of the +// comments of a Python module. +func annotationsFromComments(comments []comment) (*annotations, error) { + ignore := make(map[string]struct{}) + for _, comment := range comments { + annotation, err := comment.asAnnotation() + if err != nil { + return nil, err + } + if annotation != nil { + if annotation.kind == annotationKindIgnore { + modules := strings.Split(annotation.value, ",") + for _, m := range modules { + if m == "" { + continue + } + m = strings.TrimSpace(m) + ignore[m] = struct{}{} + } + } + } + } + return &annotations{ + ignore: ignore, + }, nil +} + +// ignored returns true if the given module was ignored via the ignore +// annotation. +func (a *annotations) ignores(module string) bool { + _, ignores := a.ignore[module] + return ignores +} diff --git a/gazelle/python/python_test.go b/gazelle/python/python_test.go new file mode 100644 index 0000000000..79450ad584 --- /dev/null +++ b/gazelle/python/python_test.go @@ -0,0 +1,206 @@ +/* Copyright 2020 The Bazel Authors. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// This test file was first seen on: +// https://github.com/bazelbuild/bazel-skylib/blob/f80bc733d4b9f83d427ce3442be2e07427b2cc8d/gazelle/bzl/BUILD. +// It was modified for the needs of this extension. + +package python_test + +import ( + "bytes" + "context" + "errors" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/bazelbuild/bazel-gazelle/testtools" + "github.com/bazelbuild/rules_go/go/tools/bazel" + "github.com/ghodss/yaml" +) + +const ( + extensionDir = "python" + string(os.PathSeparator) + testDataPath = extensionDir + "testdata" + string(os.PathSeparator) + gazelleBinaryName = "gazelle_binary" +) + +var gazellePath = mustFindGazelle() + +func TestGazelleBinary(t *testing.T) { + tests := map[string][]bazel.RunfileEntry{} + + runfiles, err := bazel.ListRunfiles() + if err != nil { + t.Fatalf("bazel.ListRunfiles() error: %v", err) + } + for _, f := range runfiles { + if strings.HasPrefix(f.ShortPath, testDataPath) { + relativePath := strings.TrimPrefix(f.ShortPath, testDataPath) + parts := strings.SplitN(relativePath, string(os.PathSeparator), 2) + if len(parts) < 2 { + // This file is not a part of a testcase since it must be in a dir that + // is the test case and then have a path inside of that. + continue + } + + tests[parts[0]] = append(tests[parts[0]], f) + } + } + if len(tests) == 0 { + t.Fatal("no tests found") + } + + for testName, files := range tests { + testPath(t, testName, files) + } +} + +func testPath(t *testing.T, name string, files []bazel.RunfileEntry) { + t.Run(name, func(t *testing.T) { + t.Parallel() + var inputs, goldens []testtools.FileSpec + + var config *testYAML + for _, f := range files { + path := f.Path + trim := filepath.Join(testDataPath, name) + string(os.PathSeparator) + shortPath := strings.TrimPrefix(f.ShortPath, trim) + info, err := os.Stat(path) + if err != nil { + t.Fatalf("os.Stat(%q) error: %v", path, err) + } + + if info.IsDir() { + continue + } + + content, err := os.ReadFile(path) + if err != nil { + t.Errorf("os.ReadFile(%q) error: %v", path, err) + } + + if filepath.Base(shortPath) == "test.yaml" { + if config != nil { + t.Fatal("only 1 test.yaml is supported") + } + config = new(testYAML) + if err := yaml.Unmarshal(content, config); err != nil { + t.Fatal(err) + } + } + + if strings.HasSuffix(shortPath, ".in") { + inputs = append(inputs, testtools.FileSpec{ + Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".in")), + Content: string(content), + }) + continue + } + + if strings.HasSuffix(shortPath, ".out") { + goldens = append(goldens, testtools.FileSpec{ + Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".out")), + Content: string(content), + }) + continue + } + + inputs = append(inputs, testtools.FileSpec{ + Path: filepath.Join(name, shortPath), + Content: string(content), + }) + goldens = append(goldens, testtools.FileSpec{ + Path: filepath.Join(name, shortPath), + Content: string(content), + }) + } + + testdataDir, cleanup := testtools.CreateFiles(t, inputs) + t.Cleanup(cleanup) + t.Cleanup(func() { + if !t.Failed() { + return + } + + filepath.Walk(testdataDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + t.Logf("%q exists", strings.TrimPrefix(path, testdataDir)) + return nil + }) + }) + + workspaceRoot := filepath.Join(testdataDir, name) + + args := []string{"-build_file_name=BUILD,BUILD.bazel"} + + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) + t.Cleanup(cancel) + cmd := exec.CommandContext(ctx, gazellePath, args...) + var stdout, stderr bytes.Buffer + cmd.Stdout = &stdout + cmd.Stderr = &stderr + cmd.Dir = workspaceRoot + if err := cmd.Run(); err != nil { + var e *exec.ExitError + if !errors.As(err, &e) { + t.Fatal(err) + } + } + + actualExitCode := cmd.ProcessState.ExitCode() + if config.Expect.ExitCode != actualExitCode { + t.Errorf("expected gazelle exit code: %d\ngot: %d", + config.Expect.ExitCode, actualExitCode) + } + actualStdout := stdout.String() + if strings.TrimSpace(config.Expect.Stdout) != strings.TrimSpace(actualStdout) { + t.Errorf("expected gazelle stdout: %s\ngot: %s", + config.Expect.Stdout, actualStdout) + } + actualStderr := stderr.String() + if strings.TrimSpace(config.Expect.Stderr) != strings.TrimSpace(actualStderr) { + t.Errorf("expected gazelle stderr: %s\ngot: %s", + config.Expect.Stderr, actualStderr) + } + if t.Failed() { + t.FailNow() + } + + testtools.CheckFiles(t, testdataDir, goldens) + }) +} + +func mustFindGazelle() string { + gazellePath, ok := bazel.FindBinary(extensionDir, gazelleBinaryName) + if !ok { + panic("could not find gazelle binary") + } + return gazellePath +} + +type testYAML struct { + Expect struct { + ExitCode int `json:"exit_code"` + Stdout string `json:"stdout"` + Stderr string `json:"stderr"` + } `json:"expect"` +} diff --git a/gazelle/python/resolve.go b/gazelle/python/resolve.go new file mode 100644 index 0000000000..46014e50ec --- /dev/null +++ b/gazelle/python/resolve.go @@ -0,0 +1,304 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "fmt" + "log" + "os" + "path/filepath" + "strings" + + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/label" + "github.com/bazelbuild/bazel-gazelle/repo" + "github.com/bazelbuild/bazel-gazelle/resolve" + "github.com/bazelbuild/bazel-gazelle/rule" + bzl "github.com/bazelbuild/buildtools/build" + "github.com/emirpasic/gods/sets/treeset" + godsutils "github.com/emirpasic/gods/utils" + + "github.com/bazelbuild/rules_python/gazelle/pythonconfig" +) + +const languageName = "py" + +const ( + // resolvedDepsKey is the attribute key used to pass dependencies that don't + // need to be resolved by the dependency resolver in the Resolver step. + resolvedDepsKey = "_gazelle_python_resolved_deps" +) + +// Resolver satisfies the resolve.Resolver interface. It resolves dependencies +// in rules generated by this extension. +type Resolver struct{} + +// Name returns the name of the language. This is the prefix of the kinds of +// rules generated. E.g. py_library and py_binary. +func (*Resolver) Name() string { return languageName } + +// Imports returns a list of ImportSpecs that can be used to import the rule +// r. This is used to populate RuleIndex. +// +// If nil is returned, the rule will not be indexed. If any non-nil slice is +// returned, including an empty slice, the rule will be indexed. +func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec { + cfgs := c.Exts[languageName].(pythonconfig.Configs) + cfg := cfgs[f.Pkg] + srcs := r.AttrStrings("srcs") + provides := make([]resolve.ImportSpec, 0, len(srcs)+1) + for _, src := range srcs { + ext := filepath.Ext(src) + if ext == ".py" { + pythonProjectRoot := cfg.PythonProjectRoot() + provide := importSpecFromSrc(pythonProjectRoot, f.Pkg, src) + provides = append(provides, provide) + } + } + if len(provides) == 0 { + return nil + } + return provides +} + +// importSpecFromSrc determines the ImportSpec based on the target that contains the src so that +// the target can be indexed for import statements that match the calculated src relative to the its +// Python project root. +func importSpecFromSrc(pythonProjectRoot, bzlPkg, src string) resolve.ImportSpec { + pythonPkgDir := filepath.Join(bzlPkg, filepath.Dir(src)) + relPythonPkgDir, err := filepath.Rel(pythonProjectRoot, pythonPkgDir) + if err != nil { + panic(fmt.Errorf("unexpected failure: %v", err)) + } + if relPythonPkgDir == "." { + relPythonPkgDir = "" + } + pythonPkg := strings.ReplaceAll(relPythonPkgDir, "/", ".") + filename := filepath.Base(src) + if filename == pyLibraryEntrypointFilename { + if pythonPkg != "" { + return resolve.ImportSpec{ + Lang: languageName, + Imp: pythonPkg, + } + } + } + moduleName := strings.TrimSuffix(filename, ".py") + var imp string + if pythonPkg == "" { + imp = moduleName + } else { + imp = fmt.Sprintf("%s.%s", pythonPkg, moduleName) + } + return resolve.ImportSpec{ + Lang: languageName, + Imp: imp, + } +} + +// Embeds returns a list of labels of rules that the given rule embeds. If +// a rule is embedded by another importable rule of the same language, only +// the embedding rule will be indexed. The embedding rule will inherit +// the imports of the embedded rule. +func (py *Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label { + // TODO(f0rmiga): implement. + return make([]label.Label, 0) +} + +// Resolve translates imported libraries for a given rule into Bazel +// dependencies. Information about imported libraries is returned for each +// rule generated by language.GenerateRules in +// language.GenerateResult.Imports. Resolve generates a "deps" attribute (or +// the appropriate language-specific equivalent) for each import according to +// language-specific rules and heuristics. +func (py *Resolver) Resolve( + c *config.Config, + ix *resolve.RuleIndex, + rc *repo.RemoteCache, + r *rule.Rule, + modulesRaw interface{}, + from label.Label, +) { + // TODO(f0rmiga): may need to be defensive here once this Gazelle extension + // join with the main Gazelle binary with other rules. It may conflict with + // other generators that generate py_* targets. + deps := treeset.NewWith(godsutils.StringComparator) + if modulesRaw != nil { + cfgs := c.Exts[languageName].(pythonconfig.Configs) + cfg := cfgs[from.Pkg] + pythonProjectRoot := cfg.PythonProjectRoot() + modules := modulesRaw.(*treeset.Set) + it := modules.Iterator() + explainDependency := os.Getenv("EXPLAIN_DEPENDENCY") + hasFatalError := false + MODULES_LOOP: + for it.Next() { + mod := it.Value().(module) + moduleParts := strings.Split(mod.Name, ".") + possibleModules := []string{mod.Name} + for len(moduleParts) > 1 { + // Iterate back through the possible imports until + // a match is found. + // For example, "from foo.bar import baz" where bar is a variable, we should try + // `foo.bar.baz` first, then `foo.bar`, then `foo`. In the first case, the import could be file `baz.py` + // in the directory `foo/bar`. + // Or, the import could be variable `bar` in file `foo/bar.py`. + // The import could also be from a standard module, e.g. `six.moves`, where + // the dependency is actually `six`. + moduleParts = moduleParts[:len(moduleParts)-1] + possibleModules = append(possibleModules, strings.Join(moduleParts, ".")) + } + errs := []error{} + POSSIBLE_MODULE_LOOP: + for _, moduleName := range possibleModules { + imp := resolve.ImportSpec{Lang: languageName, Imp: moduleName} + if override, ok := resolve.FindRuleWithOverride(c, imp, languageName); ok { + if override.Repo == "" { + override.Repo = from.Repo + } + if !override.Equal(from) { + if override.Repo == from.Repo { + override.Repo = "" + } + dep := override.String() + deps.Add(dep) + if explainDependency == dep { + log.Printf("Explaining dependency (%s): "+ + "in the target %q, the file %q imports %q at line %d, "+ + "which resolves using the \"gazelle:resolve\" directive.\n", + explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber) + } + continue MODULES_LOOP + } + } else { + if dep, ok := cfg.FindThirdPartyDependency(moduleName); ok { + deps.Add(dep) + if explainDependency == dep { + log.Printf("Explaining dependency (%s): "+ + "in the target %q, the file %q imports %q at line %d, "+ + "which resolves from the third-party module %q from the wheel %q.\n", + explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber, mod.Name, dep) + } + continue MODULES_LOOP + } else { + matches := ix.FindRulesByImportWithConfig(c, imp, languageName) + if len(matches) == 0 { + // Check if the imported module is part of the standard library. + if isStd, err := isStdModule(module{Name: moduleName}); err != nil { + log.Println("Error checking if standard module: ", err) + hasFatalError = true + continue POSSIBLE_MODULE_LOOP + } else if isStd { + continue MODULES_LOOP + } else if cfg.ValidateImportStatements() { + err := fmt.Errorf( + "%[1]q at line %[2]d from %[3]q is an invalid dependency: possible solutions:\n"+ + "\t1. Add it as a dependency in the requirements.txt file.\n"+ + "\t2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.\n"+ + "\t3. Ignore it with a comment '# gazelle:ignore %[1]s' in the Python file.\n", + moduleName, mod.LineNumber, mod.Filepath, + ) + errs = append(errs, err) + continue POSSIBLE_MODULE_LOOP + } + } + filteredMatches := make([]resolve.FindResult, 0, len(matches)) + for _, match := range matches { + if match.IsSelfImport(from) { + // Prevent from adding itself as a dependency. + continue MODULES_LOOP + } + filteredMatches = append(filteredMatches, match) + } + if len(filteredMatches) == 0 { + continue POSSIBLE_MODULE_LOOP + } + if len(filteredMatches) > 1 { + sameRootMatches := make([]resolve.FindResult, 0, len(filteredMatches)) + for _, match := range filteredMatches { + if strings.HasPrefix(match.Label.Pkg, pythonProjectRoot) { + sameRootMatches = append(sameRootMatches, match) + } + } + if len(sameRootMatches) != 1 { + err := fmt.Errorf( + "multiple targets (%s) may be imported with %q at line %d in %q "+ + "- this must be fixed using the \"gazelle:resolve\" directive", + targetListFromResults(filteredMatches), moduleName, mod.LineNumber, mod.Filepath) + errs = append(errs, err) + continue POSSIBLE_MODULE_LOOP + } + filteredMatches = sameRootMatches + } + matchLabel := filteredMatches[0].Label.Rel(from.Repo, from.Pkg) + dep := matchLabel.String() + deps.Add(dep) + if explainDependency == dep { + log.Printf("Explaining dependency (%s): "+ + "in the target %q, the file %q imports %q at line %d, "+ + "which resolves from the first-party indexed labels.\n", + explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber) + } + continue MODULES_LOOP + } + } + } // End possible modules loop. + if len(errs) > 0 { + // If, after trying all possible modules, we still haven't found anything, error out. + joinedErrs := "" + for _, err := range errs { + joinedErrs = fmt.Sprintf("%s%s\n", joinedErrs, err) + } + log.Printf("ERROR: failed to validate dependencies for target %q: %v\n", from.String(), joinedErrs) + hasFatalError = true + } + } + if hasFatalError { + os.Exit(1) + } + } + resolvedDeps := r.PrivateAttr(resolvedDepsKey).(*treeset.Set) + if !resolvedDeps.Empty() { + it := resolvedDeps.Iterator() + for it.Next() { + deps.Add(it.Value()) + } + } + if !deps.Empty() { + r.SetAttr("deps", convertDependencySetToExpr(deps)) + } +} + +// targetListFromResults returns a string with the human-readable list of +// targets contained in the given results. +func targetListFromResults(results []resolve.FindResult) string { + list := make([]string, len(results)) + for i, result := range results { + list[i] = result.Label.String() + } + return strings.Join(list, ", ") +} + +// convertDependencySetToExpr converts the given set of dependencies to an +// expression to be used in the deps attribute. +func convertDependencySetToExpr(set *treeset.Set) bzl.Expr { + deps := make([]bzl.Expr, set.Size()) + it := set.Iterator() + for it.Next() { + dep := it.Value().(string) + deps[it.Index()] = &bzl.StringExpr{Value: dep} + } + return &bzl.ListExpr{List: deps} +} diff --git a/gazelle/python/std_modules.go b/gazelle/python/std_modules.go new file mode 100644 index 0000000000..94ef45666e --- /dev/null +++ b/gazelle/python/std_modules.go @@ -0,0 +1,112 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "bufio" + "context" + "fmt" + "io" + "log" + "os" + "os/exec" + "strconv" + "strings" + "sync" + "time" + + "github.com/bazelbuild/rules_go/go/tools/bazel" +) + +var ( + stdModulesStdin io.Writer + stdModulesStdout io.Reader + stdModulesMutex sync.Mutex + stdModulesSeen map[string]struct{} +) + +func init() { + stdModulesSeen = make(map[string]struct{}) + + stdModulesScriptRunfile, err := bazel.Runfile("python/std_modules") + if err != nil { + log.Printf("failed to initialize std_modules: %v\n", err) + os.Exit(1) + } + + ctx := context.Background() + ctx, stdModulesCancel := context.WithTimeout(ctx, time.Minute*10) + cmd := exec.CommandContext(ctx, stdModulesScriptRunfile) + + cmd.Stderr = os.Stderr + // All userland site-packages should be ignored. + cmd.Env = []string{"PYTHONNOUSERSITE=1"} + stdin, err := cmd.StdinPipe() + if err != nil { + log.Printf("failed to initialize std_modules: %v\n", err) + os.Exit(1) + } + stdModulesStdin = stdin + + stdout, err := cmd.StdoutPipe() + if err != nil { + log.Printf("failed to initialize std_modules: %v\n", err) + os.Exit(1) + } + stdModulesStdout = stdout + + if err := cmd.Start(); err != nil { + log.Printf("failed to initialize std_modules: %v\n", err) + os.Exit(1) + } + + go func() { + defer stdModulesCancel() + if err := cmd.Wait(); err != nil { + log.Printf("failed to wait for std_modules: %v\n", err) + os.Exit(1) + } + }() +} + +func isStdModule(m module) (bool, error) { + if _, seen := stdModulesSeen[m.Name]; seen { + return true, nil + } + stdModulesMutex.Lock() + defer stdModulesMutex.Unlock() + + fmt.Fprintf(stdModulesStdin, "%s\n", m.Name) + + stdoutReader := bufio.NewReader(stdModulesStdout) + line, err := stdoutReader.ReadString('\n') + if err != nil { + return false, err + } + if len(line) == 0 { + return false, fmt.Errorf("unexpected empty output from std_modules") + } + + isStd, err := strconv.ParseBool(strings.TrimSpace(line)) + if err != nil { + return false, err + } + + if isStd { + stdModulesSeen[m.Name] = struct{}{} + return true, nil + } + return false, nil +} diff --git a/gazelle/python/std_modules.py b/gazelle/python/std_modules.py new file mode 100644 index 0000000000..779a325508 --- /dev/null +++ b/gazelle/python/std_modules.py @@ -0,0 +1,51 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# std_modules.py is a long-living program that communicates over STDIN and +# STDOUT. STDIN receives module names, one per line. For each module statement +# it evaluates, it outputs true/false for whether the module is part of the +# standard library or not. + +import os +import sys +from contextlib import redirect_stdout + + +def is_std_modules(module): + # If for some reason a module (such as pygame, see https://github.com/pygame/pygame/issues/542) + # prints to stdout upon import, + # the output of this script should still be parseable by golang. + # Therefore, redirect stdout while running the import. + with redirect_stdout(os.devnull): + try: + __import__(module, globals(), locals(), [], 0) + return True + except Exception: + return False + + +def main(stdin, stdout): + for module in stdin: + module = module.strip() + # Don't print the boolean directly as it is capitalized in Python. + print( + "true" if is_std_modules(module) else "false", + end="\n", + file=stdout, + ) + stdout.flush() + + +if __name__ == "__main__": + exit(main(sys.stdin, sys.stdout)) diff --git a/gazelle/python/target.go b/gazelle/python/target.go new file mode 100644 index 0000000000..fdc99fc68c --- /dev/null +++ b/gazelle/python/target.go @@ -0,0 +1,157 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package python + +import ( + "github.com/bazelbuild/bazel-gazelle/config" + "github.com/bazelbuild/bazel-gazelle/rule" + "github.com/emirpasic/gods/sets/treeset" + godsutils "github.com/emirpasic/gods/utils" + "path/filepath" +) + +// targetBuilder builds targets to be generated by Gazelle. +type targetBuilder struct { + kind string + name string + pythonProjectRoot string + bzlPackage string + srcs *treeset.Set + siblingSrcs *treeset.Set + deps *treeset.Set + resolvedDeps *treeset.Set + visibility *treeset.Set + main *string + imports []string + testonly bool +} + +// newTargetBuilder constructs a new targetBuilder. +func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string, siblingSrcs *treeset.Set) *targetBuilder { + return &targetBuilder{ + kind: kind, + name: name, + pythonProjectRoot: pythonProjectRoot, + bzlPackage: bzlPackage, + srcs: treeset.NewWith(godsutils.StringComparator), + siblingSrcs: siblingSrcs, + deps: treeset.NewWith(moduleComparator), + resolvedDeps: treeset.NewWith(godsutils.StringComparator), + visibility: treeset.NewWith(godsutils.StringComparator), + } +} + +// addSrc adds a single src to the target. +func (t *targetBuilder) addSrc(src string) *targetBuilder { + t.srcs.Add(src) + return t +} + +// addSrcs copies all values from the provided srcs to the target. +func (t *targetBuilder) addSrcs(srcs *treeset.Set) *targetBuilder { + it := srcs.Iterator() + for it.Next() { + t.srcs.Add(it.Value().(string)) + } + return t +} + +// addModuleDependency adds a single module dep to the target. +func (t *targetBuilder) addModuleDependency(dep module) *targetBuilder { + fileName := dep.Name + ".py" + if dep.From != "" { + fileName = dep.From + ".py" + } + if t.siblingSrcs.Contains(fileName) && fileName != filepath.Base(dep.Filepath) { + // importing another module from the same package, converting to absolute imports to make + // dependency resolution easier + dep.Name = importSpecFromSrc(t.pythonProjectRoot, t.bzlPackage, fileName).Imp + } + t.deps.Add(dep) + return t +} + +// addModuleDependencies copies all values from the provided deps to the target. +func (t *targetBuilder) addModuleDependencies(deps *treeset.Set) *targetBuilder { + it := deps.Iterator() + for it.Next() { + t.addModuleDependency(it.Value().(module)) + } + return t +} + +// addResolvedDependency adds a single dependency the target that has already +// been resolved or generated. The Resolver step doesn't process it further. +func (t *targetBuilder) addResolvedDependency(dep string) *targetBuilder { + t.resolvedDeps.Add(dep) + return t +} + +// addVisibility adds a visibility to the target. +func (t *targetBuilder) addVisibility(visibility string) *targetBuilder { + t.visibility.Add(visibility) + return t +} + +// setMain sets the main file to the target. +func (t *targetBuilder) setMain(main string) *targetBuilder { + t.main = &main + return t +} + +// setTestonly sets the testonly attribute to true. +func (t *targetBuilder) setTestonly() *targetBuilder { + t.testonly = true + return t +} + +// generateImportsAttribute generates the imports attribute. +// These are a list of import directories to be added to the PYTHONPATH. In our +// case, the value we add is on Bazel sub-packages to be able to perform imports +// relative to the root project package. +func (t *targetBuilder) generateImportsAttribute() *targetBuilder { + p, _ := filepath.Rel(t.bzlPackage, t.pythonProjectRoot) + p = filepath.Clean(p) + if p == "." { + return t + } + t.imports = []string{p} + return t +} + +// build returns the assembled *rule.Rule for the target. +func (t *targetBuilder) build() *rule.Rule { + r := rule.NewRule(t.kind, t.name) + if !t.srcs.Empty() { + r.SetAttr("srcs", t.srcs.Values()) + } + if !t.visibility.Empty() { + r.SetAttr("visibility", t.visibility.Values()) + } + if t.main != nil { + r.SetAttr("main", *t.main) + } + if t.imports != nil { + r.SetAttr("imports", t.imports) + } + if !t.deps.Empty() { + r.SetPrivateAttr(config.GazelleImportsKey, t.deps) + } + if t.testonly { + r.SetAttr("testonly", true) + } + r.SetPrivateAttr(resolvedDepsKey, t.resolvedDeps) + return r +} diff --git a/gazelle/python/testdata/README.md b/gazelle/python/testdata/README.md new file mode 100644 index 0000000000..6c25d4894c --- /dev/null +++ b/gazelle/python/testdata/README.md @@ -0,0 +1,12 @@ +# Gazelle Python extension test cases + +Each directory is a test case that contains `BUILD.in` and `BUILD.out` files for +assertion. `BUILD.in` is used as how the build file looks before running +Gazelle, and `BUILD.out` how the build file should look like after running +Gazelle. + +Each test case is a Bazel workspace and Gazelle will run with its working +directory set to the root of this workspace, though, the test runner will find +`test.yaml` files and use them to determine the directory Gazelle should use for +each inner Python project. The `test.yaml` file is a manifest for the test - +check for the existing ones for examples. diff --git a/gazelle/python/testdata/dependency_resolution_order/BUILD.in b/gazelle/python/testdata/dependency_resolution_order/BUILD.in new file mode 100644 index 0000000000..71a5c5adda --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/BUILD.in @@ -0,0 +1 @@ +# gazelle:resolve py bar //somewhere/bar diff --git a/gazelle/python/testdata/dependency_resolution_order/BUILD.out b/gazelle/python/testdata/dependency_resolution_order/BUILD.out new file mode 100644 index 0000000000..3ea83eb5f1 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/BUILD.out @@ -0,0 +1,14 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:resolve py bar //somewhere/bar + +py_library( + name = "dependency_resolution_order", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], + deps = [ + "//baz", + "//somewhere/bar", + "@gazelle_python_test_some_foo//:pkg", + ], +) diff --git a/gazelle/python/testdata/dependency_resolution_order/README.md b/gazelle/python/testdata/dependency_resolution_order/README.md new file mode 100644 index 0000000000..75ceb0b1b5 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/README.md @@ -0,0 +1,7 @@ +# Dependency resolution order + +This asserts that the generator resolves the dependencies in the right order: + +1. Explicit resolution via gazelle:resolve. +2. Third-party dependencies matching in the `modules_mapping.json`. +3. Indexed generated first-party dependencies. diff --git a/gazelle/python/testdata/dependency_resolution_order/WORKSPACE b/gazelle/python/testdata/dependency_resolution_order/WORKSPACE new file mode 100644 index 0000000000..4959898cdd --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/WORKSPACE @@ -0,0 +1 @@ +# This is a test data Bazel workspace. diff --git a/gazelle/python/testdata/dependency_resolution_order/__init__.py b/gazelle/python/testdata/dependency_resolution_order/__init__.py new file mode 100644 index 0000000000..d9c6504deb --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/__init__.py @@ -0,0 +1,24 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +import bar +import baz +import foo + +_ = sys +_ = bar +_ = baz +_ = foo diff --git a/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.in b/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.out b/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.out new file mode 100644 index 0000000000..da9915ddbe --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/bar/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/dependency_resolution_order/bar/__init__.py b/gazelle/python/testdata/dependency_resolution_order/bar/__init__.py new file mode 100644 index 0000000000..1c0275c070 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/bar/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +_ = os diff --git a/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.in b/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.out b/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.out new file mode 100644 index 0000000000..749fd3d490 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/baz/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "baz", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/dependency_resolution_order/baz/__init__.py b/gazelle/python/testdata/dependency_resolution_order/baz/__init__.py new file mode 100644 index 0000000000..1c0275c070 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/baz/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +_ = os diff --git a/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.in b/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.out b/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.out new file mode 100644 index 0000000000..4404d30461 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/foo/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/dependency_resolution_order/foo/__init__.py b/gazelle/python/testdata/dependency_resolution_order/foo/__init__.py new file mode 100644 index 0000000000..1c0275c070 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/foo/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +_ = os diff --git a/gazelle/python/testdata/dependency_resolution_order/gazelle_python.yaml b/gazelle/python/testdata/dependency_resolution_order/gazelle_python.yaml new file mode 100644 index 0000000000..8615181c91 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + foo: some_foo + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.in b/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.out b/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.out new file mode 100644 index 0000000000..a0d421b8dc --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/__init__.py b/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/__init__.py new file mode 100644 index 0000000000..1c0275c070 --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/somewhere/bar/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +_ = os diff --git a/gazelle/python/testdata/dependency_resolution_order/test.yaml b/gazelle/python/testdata/dependency_resolution_order/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/dependency_resolution_order/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/disable_import_statements_validation/BUILD.in b/gazelle/python/testdata/disable_import_statements_validation/BUILD.in new file mode 100644 index 0000000000..741aff66ed --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_validate_import_statements false diff --git a/gazelle/python/testdata/disable_import_statements_validation/BUILD.out b/gazelle/python/testdata/disable_import_statements_validation/BUILD.out new file mode 100644 index 0000000000..964db6d484 --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_validate_import_statements false + +py_library( + name = "disable_import_statements_validation", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/disable_import_statements_validation/README.md b/gazelle/python/testdata/disable_import_statements_validation/README.md new file mode 100644 index 0000000000..a80fffec5e --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/README.md @@ -0,0 +1,3 @@ +# Disable import statements validation + +This test case asserts that the module's validation step is not performed. diff --git a/gazelle/python/testdata/disable_import_statements_validation/WORKSPACE b/gazelle/python/testdata/disable_import_statements_validation/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/disable_import_statements_validation/__init__.py b/gazelle/python/testdata/disable_import_statements_validation/__init__.py new file mode 100644 index 0000000000..fde6e50c27 --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import abcdefg + +_ = abcdefg diff --git a/gazelle/python/testdata/disable_import_statements_validation/test.yaml b/gazelle/python/testdata/disable_import_statements_validation/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/disable_import_statements_validation/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/dont_rename_target/BUILD.in b/gazelle/python/testdata/dont_rename_target/BUILD.in new file mode 100644 index 0000000000..33e8ec25cb --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/BUILD.in @@ -0,0 +1,5 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "my_custom_target", +) diff --git a/gazelle/python/testdata/dont_rename_target/BUILD.out b/gazelle/python/testdata/dont_rename_target/BUILD.out new file mode 100644 index 0000000000..62772e30b5 --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/BUILD.out @@ -0,0 +1,7 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "my_custom_target", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/dont_rename_target/README.md b/gazelle/python/testdata/dont_rename_target/README.md new file mode 100644 index 0000000000..19f9d6637a --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/README.md @@ -0,0 +1,4 @@ +# Don't rename target + +This test case asserts that an existing target with a custom name doesn't get +renamed by the Gazelle extension. diff --git a/gazelle/python/testdata/dont_rename_target/WORKSPACE b/gazelle/python/testdata/dont_rename_target/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/dont_rename_target/__init__.py b/gazelle/python/testdata/dont_rename_target/__init__.py new file mode 100644 index 0000000000..bbdfb4c588 --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/gazelle/python/testdata/dont_rename_target/test.yaml b/gazelle/python/testdata/dont_rename_target/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/dont_rename_target/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/file_name_matches_import_statement/BUILD.in b/gazelle/python/testdata/file_name_matches_import_statement/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/file_name_matches_import_statement/BUILD.out b/gazelle/python/testdata/file_name_matches_import_statement/BUILD.out new file mode 100644 index 0000000000..0216e4b2e3 --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "file_name_matches_import_statement", + srcs = [ + "__init__.py", + "rest_framework.py", + ], + visibility = ["//:__subpackages__"], + deps = ["@gazelle_python_test_djangorestframework//:pkg"], +) diff --git a/gazelle/python/testdata/file_name_matches_import_statement/README.md b/gazelle/python/testdata/file_name_matches_import_statement/README.md new file mode 100644 index 0000000000..591adc1c27 --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/README.md @@ -0,0 +1,4 @@ +# File name matches import statement + +This test case asserts that a file with an import statement that matches its own +name does the right thing of resolving the third-party package. diff --git a/gazelle/python/testdata/file_name_matches_import_statement/WORKSPACE b/gazelle/python/testdata/file_name_matches_import_statement/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/file_name_matches_import_statement/__init__.py b/gazelle/python/testdata/file_name_matches_import_statement/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/file_name_matches_import_statement/gazelle_python.yaml b/gazelle/python/testdata/file_name_matches_import_statement/gazelle_python.yaml new file mode 100644 index 0000000000..f50d3ae397 --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + rest_framework: djangorestframework + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/file_name_matches_import_statement/rest_framework.py b/gazelle/python/testdata/file_name_matches_import_statement/rest_framework.py new file mode 100644 index 0000000000..43098d29e2 --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/rest_framework.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import rest_framework + +_ = rest_framework diff --git a/gazelle/python/testdata/file_name_matches_import_statement/test.yaml b/gazelle/python/testdata/file_name_matches_import_statement/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/file_name_matches_import_statement/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/first_party_dependencies/BUILD.in b/gazelle/python/testdata/first_party_dependencies/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/first_party_dependencies/BUILD.out b/gazelle/python/testdata/first_party_dependencies/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/first_party_dependencies/README.md b/gazelle/python/testdata/first_party_dependencies/README.md new file mode 100644 index 0000000000..f57e255fa7 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/README.md @@ -0,0 +1,11 @@ +# First-party dependencies + +There are 2 different scenarios that the extension needs to handle: + +1. Import statements that match sub-directory names. +2. Import statements that don't match sub-directory names and need a hint from + the user via directives. + +This test case asserts that the generated targets cover both scenarios. + +With the hint we need to check if it's a .py file or a directory with `__init__.py` file. diff --git a/gazelle/python/testdata/first_party_dependencies/WORKSPACE b/gazelle/python/testdata/first_party_dependencies/WORKSPACE new file mode 100644 index 0000000000..4959898cdd --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/WORKSPACE @@ -0,0 +1 @@ +# This is a test data Bazel workspace. diff --git a/gazelle/python/testdata/first_party_dependencies/one/BUILD.in b/gazelle/python/testdata/first_party_dependencies/one/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/first_party_dependencies/one/BUILD.out b/gazelle/python/testdata/first_party_dependencies/one/BUILD.out new file mode 100644 index 0000000000..c96a56106d --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/BUILD.out @@ -0,0 +1,15 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +# gazelle:python_root + +py_binary( + name = "one_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//one:__subpackages__"], + deps = [ + "//one/bar", + "//one/bar/baz", + "//one/foo", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/__main__.py b/gazelle/python/testdata/first_party_dependencies/one/__main__.py new file mode 100644 index 0000000000..efc7900d53 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/__main__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from bar import bar +from bar.baz import baz +from foo import foo + +if __name__ == "__main__": + INIT_FILENAME = "__init__.py" + dirname = os.path.dirname(os.path.abspath(__file__)) + assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) + assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) + assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.in b/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.in new file mode 100644 index 0000000000..7fe1f496d1 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.in @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.out b/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.out new file mode 100644 index 0000000000..470bf82ce9 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + imports = [".."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/__init__.py b/gazelle/python/testdata/first_party_dependencies/one/bar/__init__.py new file mode 100644 index 0000000000..d4b5fb84f1 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def bar(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.in b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.in new file mode 100644 index 0000000000..886a89cc3d --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.in @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "baz", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.out b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.out new file mode 100644 index 0000000000..a0172452e1 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "baz", + srcs = ["__init__.py"], + imports = ["../.."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/bar/baz/__init__.py b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/__init__.py new file mode 100644 index 0000000000..5be74a7d3e --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/bar/baz/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def baz(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.in b/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.in new file mode 100644 index 0000000000..0ee9a303bf --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.in @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + "//two:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.out b/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.out new file mode 100644 index 0000000000..464fabb684 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/foo/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + imports = [".."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + "//two:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/one/foo/__init__.py b/gazelle/python/testdata/first_party_dependencies/one/foo/__init__.py new file mode 100644 index 0000000000..978fb74567 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/one/foo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def foo(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/first_party_dependencies/test.yaml b/gazelle/python/testdata/first_party_dependencies/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/first_party_dependencies/three/BUILD.in b/gazelle/python/testdata/first_party_dependencies/three/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/three/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/first_party_dependencies/three/BUILD.out b/gazelle/python/testdata/first_party_dependencies/three/BUILD.out new file mode 100644 index 0000000000..ccfb3e0c08 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/three/BUILD.out @@ -0,0 +1,14 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_root + +py_library( + name = "three", + srcs = ["__init__.py"], + visibility = ["//three:__subpackages__"], + deps = [ + "//one/bar", + "//one/bar/baz", + "//one/foo", + ], +) diff --git a/gazelle/python/testdata/first_party_dependencies/three/__init__.py b/gazelle/python/testdata/first_party_dependencies/three/__init__.py new file mode 100644 index 0000000000..9f7d123649 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/three/__init__.py @@ -0,0 +1,24 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from bar import bar +from bar.baz import baz +from foo import foo + +_ = os +_ = bar +_ = baz +_ = foo diff --git a/gazelle/python/testdata/first_party_dependencies/two/BUILD.in b/gazelle/python/testdata/first_party_dependencies/two/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/two/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/first_party_dependencies/two/BUILD.out b/gazelle/python/testdata/first_party_dependencies/two/BUILD.out new file mode 100644 index 0000000000..182db08f0e --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/two/BUILD.out @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_root + +py_library( + name = "two", + srcs = ["__init__.py"], + visibility = ["//two:__subpackages__"], + deps = ["//one/foo"], +) diff --git a/gazelle/python/testdata/first_party_dependencies/two/__init__.py b/gazelle/python/testdata/first_party_dependencies/two/__init__.py new file mode 100644 index 0000000000..88ff57bf1b --- /dev/null +++ b/gazelle/python/testdata/first_party_dependencies/two/__init__.py @@ -0,0 +1,20 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from foo import foo + +_ = os +_ = foo diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.in b/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.in new file mode 100644 index 0000000000..fb90e4cbde --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.in @@ -0,0 +1 @@ +# gazelle:resolve py foo //foo diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.out b/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.out new file mode 100644 index 0000000000..264205b964 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/BUILD.out @@ -0,0 +1,25 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +# gazelle:resolve py foo //foo + +py_library( + name = "first_party_file_and_directory_modules", + srcs = [ + "baz.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "first_party_file_and_directory_modules_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [ + ":first_party_file_and_directory_modules", + "//foo", + "//one", + "//undiscoverable/package1/subpackage1", + ], +) diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/README.md b/gazelle/python/testdata/first_party_file_and_directory_modules/README.md new file mode 100644 index 0000000000..2a173b4305 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/README.md @@ -0,0 +1,9 @@ +# First-party file and directory module dependencies + +This test case asserts that a `py_library` is generated with the dependencies +pointing to the correct first-party target that contains a Python module file +that was imported directly instead of a directory containing `__init__.py`. + +Also, it asserts that the directory with the `__init__.py` file is selected +instead of a module file with same. E.g. `foo/__init__.py` takes precedence over +`foo.py` when `import foo` exists. diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/WORKSPACE b/gazelle/python/testdata/first_party_file_and_directory_modules/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/__main__.py b/gazelle/python/testdata/first_party_file_and_directory_modules/__main__.py new file mode 100644 index 0000000000..242448d348 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/__main__.py @@ -0,0 +1,25 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import foo +from baz import baz as another_baz +from foo.bar import baz +from one.two import two +from package1.subpackage1.module1 import find_me + +assert not hasattr(foo, "foo") +assert baz() == "baz from foo/bar.py" +assert another_baz() == "baz from baz.py" +assert two() == "two" +assert find_me() == "found" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py b/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py new file mode 100644 index 0000000000..e03a9ecb9d --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/baz.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def baz(): + return "baz from baz.py" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py b/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py new file mode 100644 index 0000000000..04474d83a8 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/foo.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def foo(): + print("foo") diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.in b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.out b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.out new file mode 100644 index 0000000000..3decd902e0 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = [ + "__init__.py", + "bar.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//one"], +) diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo/__init__.py b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/foo/bar.py b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/bar.py new file mode 100644 index 0000000000..dacf2d42b2 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/foo/bar.py @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import one.two as two + +_ = two + + +def baz(): + return "baz from foo/bar.py" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.in b/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.out b/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.out new file mode 100644 index 0000000000..7063141808 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/one/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "one", + srcs = [ + "__init__.py", + "two.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/one/__init__.py b/gazelle/python/testdata/first_party_file_and_directory_modules/one/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/one/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py b/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py new file mode 100644 index 0000000000..94cca3d002 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/one/two.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def two(): + return "two" diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/test.yaml b/gazelle/python/testdata/first_party_file_and_directory_modules/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out new file mode 100644 index 0000000000..6948b47b10 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_root diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in new file mode 100644 index 0000000000..c7d0e48a57 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "subpackage1", + srcs = [ + "__init__.py", + "module1.py", + ], + imports = ["../.."], + # Manual fix to visibility after initial generation. + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out new file mode 100644 index 0000000000..c7d0e48a57 --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "subpackage1", + srcs = [ + "__init__.py", + "module1.py", + ], + imports = ["../.."], + # Manual fix to visibility after initial generation. + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py new file mode 100644 index 0000000000..76c72273fa --- /dev/null +++ b/gazelle/python/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def find_me(): + return "found" diff --git a/gazelle/python/testdata/from_imports/BUILD.in b/gazelle/python/testdata/from_imports/BUILD.in new file mode 100644 index 0000000000..93f2259140 --- /dev/null +++ b/gazelle/python/testdata/from_imports/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_extension enabled diff --git a/gazelle/python/testdata/from_imports/BUILD.out b/gazelle/python/testdata/from_imports/BUILD.out new file mode 100644 index 0000000000..93f2259140 --- /dev/null +++ b/gazelle/python/testdata/from_imports/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_extension enabled diff --git a/gazelle/python/testdata/from_imports/README.md b/gazelle/python/testdata/from_imports/README.md new file mode 100644 index 0000000000..161dd18e33 --- /dev/null +++ b/gazelle/python/testdata/from_imports/README.md @@ -0,0 +1,7 @@ +# From Imports + +This test case simulates imports of the form: + +```python +from foo import bar +``` diff --git a/gazelle/python/testdata/from_imports/WORKSPACE b/gazelle/python/testdata/from_imports/WORKSPACE new file mode 100644 index 0000000000..4959898cdd --- /dev/null +++ b/gazelle/python/testdata/from_imports/WORKSPACE @@ -0,0 +1 @@ +# This is a test data Bazel workspace. diff --git a/gazelle/python/testdata/from_imports/foo/BUILD.in b/gazelle/python/testdata/from_imports/foo/BUILD.in new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/BUILD.in @@ -0,0 +1 @@ + diff --git a/gazelle/python/testdata/from_imports/foo/BUILD.out b/gazelle/python/testdata/from_imports/foo/BUILD.out new file mode 100644 index 0000000000..4404d30461 --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/from_imports/foo/__init__.py b/gazelle/python/testdata/from_imports/foo/__init__.py new file mode 100644 index 0000000000..d0f74a859a --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +foo = "foo" diff --git a/gazelle/python/testdata/from_imports/foo/bar/BUILD.in b/gazelle/python/testdata/from_imports/foo/bar/BUILD.in new file mode 100644 index 0000000000..fbbec0284b --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/bar/BUILD.in @@ -0,0 +1,21 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_ignore_files baz.py + +py_library( + name = "baz", + srcs = [ + "baz.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) + +py_library( + name = "bar", + srcs = [ + "__init__.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/foo/bar/BUILD.out b/gazelle/python/testdata/from_imports/foo/bar/BUILD.out new file mode 100644 index 0000000000..fbbec0284b --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/bar/BUILD.out @@ -0,0 +1,21 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_ignore_files baz.py + +py_library( + name = "baz", + srcs = [ + "baz.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) + +py_library( + name = "bar", + srcs = [ + "__init__.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/foo/bar/__init__.py b/gazelle/python/testdata/from_imports/foo/bar/__init__.py new file mode 100644 index 0000000000..240f382ac6 --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/bar/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +bar = "bar" diff --git a/gazelle/python/testdata/from_imports/foo/bar/baz.py b/gazelle/python/testdata/from_imports/foo/bar/baz.py new file mode 100644 index 0000000000..9aeae611db --- /dev/null +++ b/gazelle/python/testdata/from_imports/foo/bar/baz.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +baz = "baz" diff --git a/gazelle/python/testdata/from_imports/gazelle_python.yaml b/gazelle/python/testdata/from_imports/gazelle_python.yaml new file mode 100644 index 0000000000..132854e842 --- /dev/null +++ b/gazelle/python/testdata/from_imports/gazelle_python.yaml @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: rootboto3 + boto4: rootboto4 + pip_deps_repository_name: root_pip_deps diff --git a/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.in b/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.out b/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.out new file mode 100644 index 0000000000..99b48610c2 --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_from_init_py/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_from_init_py", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//foo/bar"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_from_init_py/__init__.py b/gazelle/python/testdata/from_imports/import_from_init_py/__init__.py new file mode 100644 index 0000000000..bd6d8a550f --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_from_init_py/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# bar is a variable inside foo/bar/__init__.py +from foo.bar import bar diff --git a/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.in b/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.out b/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.out new file mode 100644 index 0000000000..d8219bb4d1 --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_from_multiple/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_from_multiple", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = [ + "//foo/bar", + "//foo/bar:baz", + ], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_from_multiple/__init__.py b/gazelle/python/testdata/from_imports/import_from_multiple/__init__.py new file mode 100644 index 0000000000..05cd10460a --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_from_multiple/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Import multiple values from the same import. +from foo.bar import bar, baz diff --git a/gazelle/python/testdata/from_imports/import_nested_file/BUILD.in b/gazelle/python/testdata/from_imports/import_nested_file/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_nested_file/BUILD.out b/gazelle/python/testdata/from_imports/import_nested_file/BUILD.out new file mode 100644 index 0000000000..662da9c9a0 --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_file/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_nested_file", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//foo/bar:baz"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_nested_file/__init__.py b/gazelle/python/testdata/from_imports/import_nested_file/__init__.py new file mode 100644 index 0000000000..55a1621628 --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_file/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# baz.py is a file at foo/bar/baz.py +from foo.bar import baz diff --git a/gazelle/python/testdata/from_imports/import_nested_module/BUILD.in b/gazelle/python/testdata/from_imports/import_nested_module/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_nested_module/BUILD.out b/gazelle/python/testdata/from_imports/import_nested_module/BUILD.out new file mode 100644 index 0000000000..ec6da507dd --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_module/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_nested_module", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//foo/bar"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_nested_module/__init__.py b/gazelle/python/testdata/from_imports/import_nested_module/__init__.py new file mode 100644 index 0000000000..96fa0e5ecb --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_module/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# bar is a module at foo/bar/__init__.py +from foo import bar diff --git a/gazelle/python/testdata/from_imports/import_nested_var/BUILD.in b/gazelle/python/testdata/from_imports/import_nested_var/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_nested_var/BUILD.out b/gazelle/python/testdata/from_imports/import_nested_var/BUILD.out new file mode 100644 index 0000000000..8ee527e17a --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_var/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_nested_var", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//foo/bar:baz"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_nested_var/__init__.py b/gazelle/python/testdata/from_imports/import_nested_var/__init__.py new file mode 100644 index 0000000000..d0f51c443c --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_nested_var/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# baz is a variable in foo/bar/baz.py +from foo.bar.baz import baz diff --git a/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.in b/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.out b/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.out new file mode 100644 index 0000000000..6b584d713b --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_top_level_var/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "import_top_level_var", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], + deps = ["//foo"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/import_top_level_var/__init__.py b/gazelle/python/testdata/from_imports/import_top_level_var/__init__.py new file mode 100644 index 0000000000..71dd7c482f --- /dev/null +++ b/gazelle/python/testdata/from_imports/import_top_level_var/__init__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# foo is a variable in foo/__init__.py +from foo import foo diff --git a/gazelle/python/testdata/from_imports/std_module/BUILD.in b/gazelle/python/testdata/from_imports/std_module/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/from_imports/std_module/BUILD.out b/gazelle/python/testdata/from_imports/std_module/BUILD.out new file mode 100644 index 0000000000..4903999afc --- /dev/null +++ b/gazelle/python/testdata/from_imports/std_module/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "std_module", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) \ No newline at end of file diff --git a/gazelle/python/testdata/from_imports/std_module/__init__.py b/gazelle/python/testdata/from_imports/std_module/__init__.py new file mode 100644 index 0000000000..5518cc0239 --- /dev/null +++ b/gazelle/python/testdata/from_imports/std_module/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Gazelle should recognize this from import +# as the standard module __future__. +from __future__ import print_function diff --git a/gazelle/python/testdata/from_imports/test.yaml b/gazelle/python/testdata/from_imports/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/from_imports/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/generated_test_entrypoint/BUILD.in b/gazelle/python/testdata/generated_test_entrypoint/BUILD.in new file mode 100644 index 0000000000..06616fb1ae --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/BUILD.in @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +something( + name = "__test__", +) + +py_library( + name = "generated_test_entrypoint", + srcs = ["__init__.py"], +) diff --git a/gazelle/python/testdata/generated_test_entrypoint/BUILD.out b/gazelle/python/testdata/generated_test_entrypoint/BUILD.out new file mode 100644 index 0000000000..e8e304c72b --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/BUILD.out @@ -0,0 +1,21 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +something( + name = "__test__", +) + +py_library( + name = "generated_test_entrypoint", + srcs = [ + "__init__.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "generated_test_entrypoint_test", + srcs = [":__test__"], + main = ":__test__.py", + deps = [":__test__"], +) diff --git a/gazelle/python/testdata/generated_test_entrypoint/README.md b/gazelle/python/testdata/generated_test_entrypoint/README.md new file mode 100644 index 0000000000..69f8415999 --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/README.md @@ -0,0 +1,4 @@ +# Generated test entrypoint + +This test case asserts that a `py_test` is generated using a target named +`__test__` as its `main` entrypoint. diff --git a/gazelle/python/testdata/generated_test_entrypoint/WORKSPACE b/gazelle/python/testdata/generated_test_entrypoint/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/generated_test_entrypoint/__init__.py b/gazelle/python/testdata/generated_test_entrypoint/__init__.py new file mode 100644 index 0000000000..b274b0d921 --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from foo import foo + +_ = foo diff --git a/gazelle/python/testdata/generated_test_entrypoint/foo.py b/gazelle/python/testdata/generated_test_entrypoint/foo.py new file mode 100644 index 0000000000..932de45b74 --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/foo.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def foo(): + return "foo" diff --git a/gazelle/python/testdata/generated_test_entrypoint/test.yaml b/gazelle/python/testdata/generated_test_entrypoint/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/generated_test_entrypoint/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.in b/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.out b/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.out new file mode 100644 index 0000000000..b8c936a7dd --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "ignored_invalid_imported_module", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], + deps = ["@gazelle_python_test_foo//:pkg"], +) diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/README.md b/gazelle/python/testdata/ignored_invalid_imported_module/README.md new file mode 100644 index 0000000000..55dcc9bf7b --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/README.md @@ -0,0 +1,3 @@ +# Ignored invalid imported module + +This test case asserts that the module's validation step succeeds as expected. diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/WORKSPACE b/gazelle/python/testdata/ignored_invalid_imported_module/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/__init__.py b/gazelle/python/testdata/ignored_invalid_imported_module/__init__.py new file mode 100644 index 0000000000..a094ed0332 --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/__init__.py @@ -0,0 +1,36 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# gazelle:ignore abcdefg1,abcdefg2 +# gazelle:ignore abcdefg3 + +import abcdefg1 +import abcdefg2 +import abcdefg3 +import foo + +_ = abcdefg1 +_ = abcdefg2 +_ = abcdefg3 +_ = foo + +try: + # gazelle:ignore grpc + import grpc + + grpc_available = True +except ImportError: + grpc_available = False + +_ = grpc diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/gazelle_python.yaml b/gazelle/python/testdata/ignored_invalid_imported_module/gazelle_python.yaml new file mode 100644 index 0000000000..4b12372b4e --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + foo: foo + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/ignored_invalid_imported_module/test.yaml b/gazelle/python/testdata/ignored_invalid_imported_module/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/ignored_invalid_imported_module/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/invalid_annotation/BUILD.in b/gazelle/python/testdata/invalid_annotation/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/invalid_annotation/BUILD.out b/gazelle/python/testdata/invalid_annotation/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/invalid_annotation/README.md b/gazelle/python/testdata/invalid_annotation/README.md new file mode 100644 index 0000000000..b2544b5bda --- /dev/null +++ b/gazelle/python/testdata/invalid_annotation/README.md @@ -0,0 +1,2 @@ +# Invalid annotation +This test case asserts that the parse step fails as expected due to invalid annotation format. diff --git a/gazelle/python/testdata/invalid_annotation/WORKSPACE b/gazelle/python/testdata/invalid_annotation/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/invalid_annotation/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/invalid_annotation/__init__.py b/gazelle/python/testdata/invalid_annotation/__init__.py new file mode 100644 index 0000000000..7aee8768ad --- /dev/null +++ b/gazelle/python/testdata/invalid_annotation/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# gazelle:ignore diff --git a/gazelle/python/testdata/invalid_annotation/test.yaml b/gazelle/python/testdata/invalid_annotation/test.yaml new file mode 100644 index 0000000000..19924b1288 --- /dev/null +++ b/gazelle/python/testdata/invalid_annotation/test.yaml @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 1 + stderr: | + gazelle: ERROR: failed to parse annotations: `# gazelle:ignore` requires a value diff --git a/gazelle/python/testdata/invalid_imported_module/BUILD.in b/gazelle/python/testdata/invalid_imported_module/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/invalid_imported_module/BUILD.out b/gazelle/python/testdata/invalid_imported_module/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/invalid_imported_module/README.md b/gazelle/python/testdata/invalid_imported_module/README.md new file mode 100644 index 0000000000..85e6f45954 --- /dev/null +++ b/gazelle/python/testdata/invalid_imported_module/README.md @@ -0,0 +1,3 @@ +# Invalid imported module + +This test case asserts that the module's validation step fails as expected. diff --git a/gazelle/python/testdata/invalid_imported_module/WORKSPACE b/gazelle/python/testdata/invalid_imported_module/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/invalid_imported_module/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/invalid_imported_module/__init__.py b/gazelle/python/testdata/invalid_imported_module/__init__.py new file mode 100644 index 0000000000..dc6fb8519e --- /dev/null +++ b/gazelle/python/testdata/invalid_imported_module/__init__.py @@ -0,0 +1,22 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +try: + import grpc + + grpc_available = True +except ImportError: + grpc_available = False + +_ = grpc diff --git a/gazelle/python/testdata/invalid_imported_module/test.yaml b/gazelle/python/testdata/invalid_imported_module/test.yaml new file mode 100644 index 0000000000..6bcea39d2e --- /dev/null +++ b/gazelle/python/testdata/invalid_imported_module/test.yaml @@ -0,0 +1,22 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 1 + stderr: | + gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module": "grpc" at line 16 from "__init__.py" is an invalid dependency: possible solutions: + 1. Add it as a dependency in the requirements.txt file. + 2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive. + 3. Ignore it with a comment '# gazelle:ignore grpc' in the Python file. diff --git a/gazelle/python/testdata/monorepo/BUILD.in b/gazelle/python/testdata/monorepo/BUILD.in new file mode 100644 index 0000000000..adc9e83069 --- /dev/null +++ b/gazelle/python/testdata/monorepo/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_extension disabled diff --git a/gazelle/python/testdata/monorepo/BUILD.out b/gazelle/python/testdata/monorepo/BUILD.out new file mode 100644 index 0000000000..adc9e83069 --- /dev/null +++ b/gazelle/python/testdata/monorepo/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_extension disabled diff --git a/gazelle/python/testdata/monorepo/README.md b/gazelle/python/testdata/monorepo/README.md new file mode 100644 index 0000000000..b3ac3d27bd --- /dev/null +++ b/gazelle/python/testdata/monorepo/README.md @@ -0,0 +1,4 @@ +# Monorepo + +This test case focuses on having multiple configurations tweaked in combination +to simulate a monorepo. diff --git a/gazelle/python/testdata/monorepo/WORKSPACE b/gazelle/python/testdata/monorepo/WORKSPACE new file mode 100644 index 0000000000..4959898cdd --- /dev/null +++ b/gazelle/python/testdata/monorepo/WORKSPACE @@ -0,0 +1 @@ +# This is a test data Bazel workspace. diff --git a/gazelle/python/testdata/monorepo/a/BUILD.in b/gazelle/python/testdata/monorepo/a/BUILD.in new file mode 100644 index 0000000000..265129ea56 --- /dev/null +++ b/gazelle/python/testdata/monorepo/a/BUILD.in @@ -0,0 +1 @@ +# gazelle:exclude bar/baz/hue.py \ No newline at end of file diff --git a/gazelle/python/testdata/monorepo/a/BUILD.out b/gazelle/python/testdata/monorepo/a/BUILD.out new file mode 100644 index 0000000000..265129ea56 --- /dev/null +++ b/gazelle/python/testdata/monorepo/a/BUILD.out @@ -0,0 +1 @@ +# gazelle:exclude bar/baz/hue.py \ No newline at end of file diff --git a/gazelle/python/testdata/monorepo/a/README.md b/gazelle/python/testdata/monorepo/a/README.md new file mode 100644 index 0000000000..84d3bff052 --- /dev/null +++ b/gazelle/python/testdata/monorepo/a/README.md @@ -0,0 +1,3 @@ +# Exclusions +* Intentionally make the directory "a" so Gazelle visit this before "coarse_grained" +* Making sure that the exclusion here doesn't affect coarse_grained/bar/baz/hue.py \ No newline at end of file diff --git a/gazelle/python/testdata/monorepo/coarse_grained/BUILD.in b/gazelle/python/testdata/monorepo/coarse_grained/BUILD.in new file mode 100644 index 0000000000..b85b32105e --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/BUILD.in @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:python_generation_mode project + +# gazelle:exclude bar/baz/*_excluded.py + +py_library( + name = "coarse_grained", + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/monorepo/coarse_grained/BUILD.out b/gazelle/python/testdata/monorepo/coarse_grained/BUILD.out new file mode 100644 index 0000000000..b11cbbdaad --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/BUILD.out @@ -0,0 +1,20 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:python_generation_mode project + +# gazelle:exclude bar/baz/*_excluded.py + +py_library( + name = "coarse_grained", + srcs = [ + "__init__.py", + "bar/__init__.py", + "bar/baz/__init__.py", + "bar/baz/hue.py", + "foo/__init__.py", + ], + visibility = ["//:__subpackages__"], + deps = ["@root_pip_deps_rootboto3//:pkg"], +) diff --git a/gazelle/python/testdata/monorepo/coarse_grained/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/__init__.py new file mode 100644 index 0000000000..6e77327a42 --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/__init__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import boto3 +from bar import bar +from bar.baz import baz +from foo import foo + +_ = os +_ = boto3 +_ = bar +_ = baz +_ = foo diff --git a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.in b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.in new file mode 100644 index 0000000000..421b48688a --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_generation_mode package diff --git a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.out b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.out new file mode 100644 index 0000000000..837e59f99e --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/BUILD.out @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_generation_mode package + +py_library( + name = "_boundary", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//coarse_grained:__subpackages__"], +) diff --git a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/README.md b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/README.md new file mode 100644 index 0000000000..0e67695af3 --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/README.md @@ -0,0 +1,5 @@ +# \_boundary + +This Bazel package must be before other packages in the `coarse_grained` +directory so that we assert that walking the tree still happens after ignoring +this package from the parent coarse-grained generation. diff --git a/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py new file mode 100644 index 0000000000..bbdfb4c588 --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/_boundary/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/gazelle/python/testdata/monorepo/coarse_grained/bar/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/bar/__init__.py new file mode 100644 index 0000000000..499a0903cc --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/bar/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import boto3 + +_ = boto3 + + +def bar(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/__init__.py new file mode 100644 index 0000000000..5be74a7d3e --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def baz(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/hue.py b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/hue.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/hue.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/monorepo/coarse_grained/foo/__init__.py b/gazelle/python/testdata/monorepo/coarse_grained/foo/__init__.py new file mode 100644 index 0000000000..978fb74567 --- /dev/null +++ b/gazelle/python/testdata/monorepo/coarse_grained/foo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def foo(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/gazelle_python.yaml b/gazelle/python/testdata/monorepo/gazelle_python.yaml new file mode 100644 index 0000000000..132854e842 --- /dev/null +++ b/gazelle/python/testdata/monorepo/gazelle_python.yaml @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: rootboto3 + boto4: rootboto4 + pip_deps_repository_name: root_pip_deps diff --git a/gazelle/python/testdata/monorepo/one/BUILD.in b/gazelle/python/testdata/monorepo/one/BUILD.in new file mode 100644 index 0000000000..b11b373468 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/BUILD.in @@ -0,0 +1,2 @@ +# gazelle:python_extension enabled +# gazelle:python_root diff --git a/gazelle/python/testdata/monorepo/one/BUILD.out b/gazelle/python/testdata/monorepo/one/BUILD.out new file mode 100644 index 0000000000..5098cc9a08 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/BUILD.out @@ -0,0 +1,17 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +# gazelle:python_extension enabled +# gazelle:python_root + +py_binary( + name = "one_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//one:__subpackages__"], + deps = [ + "//one/bar", + "//one/bar/baz:modified_name_baz", + "//one/foo", + "@one_pip_deps_oneboto3//:pkg", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/__main__.py b/gazelle/python/testdata/monorepo/one/__main__.py new file mode 100644 index 0000000000..7ef50cc97b --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/__main__.py @@ -0,0 +1,29 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import boto3 +from bar import bar +from bar.baz import baz +from foo import foo + +_ = boto3 + +if __name__ == "__main__": + INIT_FILENAME = "__init__.py" + dirname = os.path.dirname(os.path.abspath(__file__)) + assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) + assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) + assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/python/testdata/monorepo/one/bar/BUILD.in b/gazelle/python/testdata/monorepo/one/bar/BUILD.in new file mode 100644 index 0000000000..7fe1f496d1 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/BUILD.in @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/bar/BUILD.out b/gazelle/python/testdata/monorepo/one/bar/BUILD.out new file mode 100644 index 0000000000..6ee6515eec --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["__init__.py"], + imports = [".."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], + deps = ["@one_pip_deps_oneboto3//:pkg"], +) diff --git a/gazelle/python/testdata/monorepo/one/bar/__init__.py b/gazelle/python/testdata/monorepo/one/bar/__init__.py new file mode 100644 index 0000000000..499a0903cc --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/__init__.py @@ -0,0 +1,23 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import boto3 + +_ = boto3 + + +def bar(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.in b/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.in new file mode 100644 index 0000000000..00ba8ed974 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.in @@ -0,0 +1,10 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "modified_name_baz", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.out b/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.out new file mode 100644 index 0000000000..1eb52fcf88 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/baz/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "modified_name_baz", + srcs = ["__init__.py"], + imports = ["../.."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/bar/baz/__init__.py b/gazelle/python/testdata/monorepo/one/bar/baz/__init__.py new file mode 100644 index 0000000000..5be74a7d3e --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/bar/baz/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def baz(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/one/foo/BUILD.in b/gazelle/python/testdata/monorepo/one/foo/BUILD.in new file mode 100644 index 0000000000..0ee9a303bf --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/foo/BUILD.in @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + "//two:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/foo/BUILD.out b/gazelle/python/testdata/monorepo/one/foo/BUILD.out new file mode 100644 index 0000000000..464fabb684 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/foo/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["__init__.py"], + imports = [".."], + visibility = [ + "//one:__subpackages__", + "//three:__subpackages__", + "//two:__subpackages__", + ], +) diff --git a/gazelle/python/testdata/monorepo/one/foo/__init__.py b/gazelle/python/testdata/monorepo/one/foo/__init__.py new file mode 100644 index 0000000000..978fb74567 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/foo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def foo(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/one/gazelle_python.yaml b/gazelle/python/testdata/monorepo/one/gazelle_python.yaml new file mode 100644 index 0000000000..6b323b73d2 --- /dev/null +++ b/gazelle/python/testdata/monorepo/one/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: oneboto3 + pip_deps_repository_name: one_pip_deps diff --git a/gazelle/python/testdata/monorepo/test.yaml b/gazelle/python/testdata/monorepo/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/monorepo/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/monorepo/three/BUILD.in b/gazelle/python/testdata/monorepo/three/BUILD.in new file mode 100644 index 0000000000..79bb63fa49 --- /dev/null +++ b/gazelle/python/testdata/monorepo/three/BUILD.in @@ -0,0 +1,5 @@ +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:resolve py bar //one/bar +# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz +# gazelle:resolve py foo //one/foo diff --git a/gazelle/python/testdata/monorepo/three/BUILD.out b/gazelle/python/testdata/monorepo/three/BUILD.out new file mode 100644 index 0000000000..78a3927db9 --- /dev/null +++ b/gazelle/python/testdata/monorepo/three/BUILD.out @@ -0,0 +1,21 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:resolve py bar //one/bar +# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz +# gazelle:resolve py foo //one/foo + +py_library( + name = "three", + srcs = ["__init__.py"], + visibility = ["//three:__subpackages__"], + deps = [ + "//coarse_grained", + "//one/bar", + "//one/bar/baz:modified_name_baz", + "//one/foo", + "@root_pip_deps_rootboto4//:pkg", + "@three_pip_deps_threeboto3//:pkg", + ], +) diff --git a/gazelle/python/testdata/monorepo/three/__init__.py b/gazelle/python/testdata/monorepo/three/__init__.py new file mode 100644 index 0000000000..b324b0c416 --- /dev/null +++ b/gazelle/python/testdata/monorepo/three/__init__.py @@ -0,0 +1,30 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import bar.baz.hue as hue +import boto3 +import boto4 +from bar import bar +from bar.baz import baz +from foo import foo + +_ = os +_ = boto3 +_ = boto4 +_ = bar +_ = baz +_ = foo +_ = hue diff --git a/gazelle/python/testdata/monorepo/three/gazelle_python.yaml b/gazelle/python/testdata/monorepo/three/gazelle_python.yaml new file mode 100644 index 0000000000..8280b38d16 --- /dev/null +++ b/gazelle/python/testdata/monorepo/three/gazelle_python.yaml @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: threeboto3 + pip_repository: + name: three_pip_deps diff --git a/gazelle/python/testdata/monorepo/two/BUILD.in b/gazelle/python/testdata/monorepo/two/BUILD.in new file mode 100644 index 0000000000..31812e0535 --- /dev/null +++ b/gazelle/python/testdata/monorepo/two/BUILD.in @@ -0,0 +1,3 @@ +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:resolve py foo //one/foo diff --git a/gazelle/python/testdata/monorepo/two/BUILD.out b/gazelle/python/testdata/monorepo/two/BUILD.out new file mode 100644 index 0000000000..9cda007e59 --- /dev/null +++ b/gazelle/python/testdata/monorepo/two/BUILD.out @@ -0,0 +1,15 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_extension enabled +# gazelle:python_root +# gazelle:resolve py foo //one/foo + +py_library( + name = "two", + srcs = ["__init__.py"], + visibility = ["//two:__subpackages__"], + deps = [ + "//one/foo", + "@two_pip_deps_twoboto3//:pkg", + ], +) diff --git a/gazelle/python/testdata/monorepo/two/__init__.py b/gazelle/python/testdata/monorepo/two/__init__.py new file mode 100644 index 0000000000..d080c27de3 --- /dev/null +++ b/gazelle/python/testdata/monorepo/two/__init__.py @@ -0,0 +1,22 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import boto3 +from foo import foo + +_ = os +_ = boto3 +_ = foo diff --git a/gazelle/python/testdata/monorepo/two/gazelle_python.yaml b/gazelle/python/testdata/monorepo/two/gazelle_python.yaml new file mode 100644 index 0000000000..88c24d0147 --- /dev/null +++ b/gazelle/python/testdata/monorepo/two/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: twoboto3 + pip_deps_repository_name: two_pip_deps diff --git a/gazelle/python/testdata/monorepo/wont_generate/BUILD.in b/gazelle/python/testdata/monorepo/wont_generate/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/BUILD.out b/gazelle/python/testdata/monorepo/wont_generate/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/__main__.py b/gazelle/python/testdata/monorepo/wont_generate/__main__.py new file mode 100644 index 0000000000..efc7900d53 --- /dev/null +++ b/gazelle/python/testdata/monorepo/wont_generate/__main__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from bar import bar +from bar.baz import baz +from foo import foo + +if __name__ == "__main__": + INIT_FILENAME = "__init__.py" + dirname = os.path.dirname(os.path.abspath(__file__)) + assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) + assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) + assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.in b/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.out b/gazelle/python/testdata/monorepo/wont_generate/bar/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/__init__.py b/gazelle/python/testdata/monorepo/wont_generate/bar/__init__.py new file mode 100644 index 0000000000..d4b5fb84f1 --- /dev/null +++ b/gazelle/python/testdata/monorepo/wont_generate/bar/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def bar(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.in b/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.out b/gazelle/python/testdata/monorepo/wont_generate/bar/baz/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/bar/baz/__init__.py b/gazelle/python/testdata/monorepo/wont_generate/bar/baz/__init__.py new file mode 100644 index 0000000000..5be74a7d3e --- /dev/null +++ b/gazelle/python/testdata/monorepo/wont_generate/bar/baz/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def baz(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.in b/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.out b/gazelle/python/testdata/monorepo/wont_generate/foo/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/monorepo/wont_generate/foo/__init__.py b/gazelle/python/testdata/monorepo/wont_generate/foo/__init__.py new file mode 100644 index 0000000000..978fb74567 --- /dev/null +++ b/gazelle/python/testdata/monorepo/wont_generate/foo/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + + +def foo(): + return os.path.abspath(__file__) diff --git a/gazelle/python/testdata/multiple_tests/BUILD.in b/gazelle/python/testdata/multiple_tests/BUILD.in new file mode 100644 index 0000000000..9e84e5dc32 --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/BUILD.in @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "multiple_tests", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "bar_test", + srcs = ["bar_test.py"], +) diff --git a/gazelle/python/testdata/multiple_tests/BUILD.out b/gazelle/python/testdata/multiple_tests/BUILD.out new file mode 100644 index 0000000000..fd67724e3b --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/BUILD.out @@ -0,0 +1,17 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "multiple_tests", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "bar_test", + srcs = ["bar_test.py"], +) + +py_test( + name = "foo_test", + srcs = ["foo_test.py"], +) diff --git a/gazelle/python/testdata/multiple_tests/README.md b/gazelle/python/testdata/multiple_tests/README.md new file mode 100644 index 0000000000..8220f6112d --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/README.md @@ -0,0 +1,3 @@ +# Multiple tests + +This test case asserts that a second `py_test` rule is correctly created when a second `*_test.py` file is added to a package with an existing `py_test` rule. diff --git a/gazelle/python/testdata/multiple_tests/WORKSPACE b/gazelle/python/testdata/multiple_tests/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/multiple_tests/__init__.py b/gazelle/python/testdata/multiple_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/multiple_tests/bar_test.py b/gazelle/python/testdata/multiple_tests/bar_test.py new file mode 100644 index 0000000000..9948f1ccd4 --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/bar_test.py @@ -0,0 +1,24 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + + +class BarTest(unittest.TestCase): + def test_foo(self): + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/multiple_tests/foo_test.py b/gazelle/python/testdata/multiple_tests/foo_test.py new file mode 100644 index 0000000000..a128adf67f --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/foo_test.py @@ -0,0 +1,24 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + + +class FooTest(unittest.TestCase): + def test_foo(self): + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/multiple_tests/test.yaml b/gazelle/python/testdata/multiple_tests/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/multiple_tests/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/naming_convention/BUILD.in b/gazelle/python/testdata/naming_convention/BUILD.in new file mode 100644 index 0000000000..7517848a92 --- /dev/null +++ b/gazelle/python/testdata/naming_convention/BUILD.in @@ -0,0 +1,3 @@ +# gazelle:python_library_naming_convention my_$package_name$_library +# gazelle:python_binary_naming_convention my_$package_name$_binary +# gazelle:python_test_naming_convention my_$package_name$_test diff --git a/gazelle/python/testdata/naming_convention/BUILD.out b/gazelle/python/testdata/naming_convention/BUILD.out new file mode 100644 index 0000000000..e2f067489c --- /dev/null +++ b/gazelle/python/testdata/naming_convention/BUILD.out @@ -0,0 +1,26 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") + +# gazelle:python_library_naming_convention my_$package_name$_library +# gazelle:python_binary_naming_convention my_$package_name$_binary +# gazelle:python_test_naming_convention my_$package_name$_test + +py_library( + name = "my_naming_convention_library", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "my_naming_convention_binary", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [":my_naming_convention_library"], +) + +py_test( + name = "my_naming_convention_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [":my_naming_convention_library"], +) diff --git a/gazelle/python/testdata/naming_convention/README.md b/gazelle/python/testdata/naming_convention/README.md new file mode 100644 index 0000000000..9dd88ecd24 --- /dev/null +++ b/gazelle/python/testdata/naming_convention/README.md @@ -0,0 +1,4 @@ +# Naming convention + +This test case asserts that py\_{library,binary,test} targets are generated +correctly based on the directives that control their naming conventions. diff --git a/gazelle/python/testdata/naming_convention/WORKSPACE b/gazelle/python/testdata/naming_convention/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/naming_convention/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/naming_convention/__init__.py b/gazelle/python/testdata/naming_convention/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention/__main__.py b/gazelle/python/testdata/naming_convention/__main__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/__main__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/__test__.py b/gazelle/python/testdata/naming_convention/__test__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/__test__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/dont_rename/BUILD.in b/gazelle/python/testdata/naming_convention/dont_rename/BUILD.in new file mode 100644 index 0000000000..8d2ae35fd4 --- /dev/null +++ b/gazelle/python/testdata/naming_convention/dont_rename/BUILD.in @@ -0,0 +1,7 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") + +py_library( + name = "dont_rename", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/naming_convention/dont_rename/BUILD.out b/gazelle/python/testdata/naming_convention/dont_rename/BUILD.out new file mode 100644 index 0000000000..4d4ead86b4 --- /dev/null +++ b/gazelle/python/testdata/naming_convention/dont_rename/BUILD.out @@ -0,0 +1,25 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") + +py_library( + name = "dont_rename", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "my_dont_rename_binary", + srcs = ["__main__.py"], + imports = [".."], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [":dont_rename"], +) + +py_test( + name = "my_dont_rename_test", + srcs = ["__test__.py"], + imports = [".."], + main = "__test__.py", + deps = [":dont_rename"], +) diff --git a/gazelle/python/testdata/naming_convention/dont_rename/__init__.py b/gazelle/python/testdata/naming_convention/dont_rename/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention/dont_rename/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention/dont_rename/__main__.py b/gazelle/python/testdata/naming_convention/dont_rename/__main__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/dont_rename/__main__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/dont_rename/__test__.py b/gazelle/python/testdata/naming_convention/dont_rename/__test__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/dont_rename/__test__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.in b/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.in new file mode 100644 index 0000000000..c81e735d7e --- /dev/null +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.in @@ -0,0 +1,5 @@ +go_library(name = "resolve_conflict") + +go_binary(name = "resolve_conflict_bin") + +go_test(name = "resolve_conflict_test") diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.out b/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.out new file mode 100644 index 0000000000..3fa5de2b79 --- /dev/null +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/BUILD.out @@ -0,0 +1,31 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") + +go_library(name = "resolve_conflict") + +go_binary(name = "resolve_conflict_bin") + +go_test(name = "resolve_conflict_test") + +py_library( + name = "my_resolve_conflict_library", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "my_resolve_conflict_binary", + srcs = ["__main__.py"], + imports = [".."], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [":my_resolve_conflict_library"], +) + +py_test( + name = "my_resolve_conflict_test", + srcs = ["__test__.py"], + imports = [".."], + main = "__test__.py", + deps = [":my_resolve_conflict_library"], +) diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/__init__.py b/gazelle/python/testdata/naming_convention/resolve_conflict/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py b/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/__main__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py b/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/naming_convention/resolve_conflict/__test__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/naming_convention/test.yaml b/gazelle/python/testdata/naming_convention/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/naming_convention/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/naming_convention_binary_fail/BUILD.in b/gazelle/python/testdata/naming_convention_binary_fail/BUILD.in new file mode 100644 index 0000000000..fd4dc1c5b7 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/BUILD.in @@ -0,0 +1 @@ +go_binary(name = "naming_convention_binary_fail_bin") diff --git a/gazelle/python/testdata/naming_convention_binary_fail/BUILD.out b/gazelle/python/testdata/naming_convention_binary_fail/BUILD.out new file mode 100644 index 0000000000..fd4dc1c5b7 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/BUILD.out @@ -0,0 +1 @@ +go_binary(name = "naming_convention_binary_fail_bin") diff --git a/gazelle/python/testdata/naming_convention_binary_fail/README.md b/gazelle/python/testdata/naming_convention_binary_fail/README.md new file mode 100644 index 0000000000..a58bbe45dd --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/README.md @@ -0,0 +1,4 @@ +# Naming convention py_binary fail + +This test case asserts that a py_binary is not generated due to a naming conflict +with existing target. diff --git a/gazelle/python/testdata/naming_convention_binary_fail/WORKSPACE b/gazelle/python/testdata/naming_convention_binary_fail/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/naming_convention_binary_fail/__main__.py b/gazelle/python/testdata/naming_convention_binary_fail/__main__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/__main__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention_binary_fail/test.yaml b/gazelle/python/testdata/naming_convention_binary_fail/test.yaml new file mode 100644 index 0000000000..41eabbfb11 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_binary_fail/test.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 1 + stderr: > + gazelle: ERROR: failed to generate target "//:naming_convention_binary_fail_bin" of kind "py_binary": + a target of kind "go_binary" with the same name already exists. + Use the '# gazelle:python_binary_naming_convention' directive to change the naming convention. diff --git a/gazelle/python/testdata/naming_convention_library_fail/BUILD.in b/gazelle/python/testdata/naming_convention_library_fail/BUILD.in new file mode 100644 index 0000000000..a6840843c1 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/BUILD.in @@ -0,0 +1 @@ +go_library(name = "naming_convention_library_fail") diff --git a/gazelle/python/testdata/naming_convention_library_fail/BUILD.out b/gazelle/python/testdata/naming_convention_library_fail/BUILD.out new file mode 100644 index 0000000000..a6840843c1 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/BUILD.out @@ -0,0 +1 @@ +go_library(name = "naming_convention_library_fail") diff --git a/gazelle/python/testdata/naming_convention_library_fail/README.md b/gazelle/python/testdata/naming_convention_library_fail/README.md new file mode 100644 index 0000000000..cd36917251 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/README.md @@ -0,0 +1,4 @@ +# Naming convention py_library fail + +This test case asserts that a py_library is not generated due to a naming conflict +with existing target. diff --git a/gazelle/python/testdata/naming_convention_library_fail/WORKSPACE b/gazelle/python/testdata/naming_convention_library_fail/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/naming_convention_library_fail/__init__.py b/gazelle/python/testdata/naming_convention_library_fail/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention_library_fail/test.yaml b/gazelle/python/testdata/naming_convention_library_fail/test.yaml new file mode 100644 index 0000000000..f48aa397f1 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_library_fail/test.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 1 + stderr: > + gazelle: ERROR: failed to generate target "//:naming_convention_library_fail" of kind "py_library": + a target of kind "go_library" with the same name already exists. + Use the '# gazelle:python_library_naming_convention' directive to change the naming convention. diff --git a/gazelle/python/testdata/naming_convention_test_fail/BUILD.in b/gazelle/python/testdata/naming_convention_test_fail/BUILD.in new file mode 100644 index 0000000000..2091253114 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/BUILD.in @@ -0,0 +1 @@ +go_test(name = "naming_convention_test_fail_test") diff --git a/gazelle/python/testdata/naming_convention_test_fail/BUILD.out b/gazelle/python/testdata/naming_convention_test_fail/BUILD.out new file mode 100644 index 0000000000..2091253114 --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/BUILD.out @@ -0,0 +1 @@ +go_test(name = "naming_convention_test_fail_test") diff --git a/gazelle/python/testdata/naming_convention_test_fail/README.md b/gazelle/python/testdata/naming_convention_test_fail/README.md new file mode 100644 index 0000000000..886c1e368c --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/README.md @@ -0,0 +1,4 @@ +# Naming convention py_test fail + +This test case asserts that a py_test is not generated due to a naming conflict +with existing target. diff --git a/gazelle/python/testdata/naming_convention_test_fail/WORKSPACE b/gazelle/python/testdata/naming_convention_test_fail/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/naming_convention_test_fail/__test__.py b/gazelle/python/testdata/naming_convention_test_fail/__test__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/__test__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/naming_convention_test_fail/test.yaml b/gazelle/python/testdata/naming_convention_test_fail/test.yaml new file mode 100644 index 0000000000..a8867e567e --- /dev/null +++ b/gazelle/python/testdata/naming_convention_test_fail/test.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 1 + stderr: > + gazelle: ERROR: failed to generate target "//:naming_convention_test_fail_test" of kind "py_test": + a target of kind "go_test" with the same name already exists. + Use the '# gazelle:python_test_naming_convention' directive to change the naming convention. diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.in b/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.in new file mode 100644 index 0000000000..1ba277afbb --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.in @@ -0,0 +1,2 @@ +# gazelle:python_ignore_dependencies foo,bar, baz +# gazelle:python_ignore_dependencies foo.bar.baz diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.out b/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.out new file mode 100644 index 0000000000..3fb91f5964 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_ignore_dependencies foo,bar, baz +# gazelle:python_ignore_dependencies foo.bar.baz + +py_library( + name = "python_ignore_dependencies_directive", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], + deps = ["@gazelle_python_test_boto3//:pkg"], +) diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/README.md b/gazelle/python/testdata/python_ignore_dependencies_directive/README.md new file mode 100644 index 0000000000..75f61e1baf --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/README.md @@ -0,0 +1,4 @@ +# python_ignore_dependencies directive + +This test case asserts that the target is generated ignoring some of the +dependencies. diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/WORKSPACE b/gazelle/python/testdata/python_ignore_dependencies_directive/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/__init__.py b/gazelle/python/testdata/python_ignore_dependencies_directive/__init__.py new file mode 100644 index 0000000000..9e6e25a891 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/__init__.py @@ -0,0 +1,25 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import bar +import boto3 +import foo +import foo.bar.baz +from baz import baz as bazfn + +_ = foo +_ = bar +_ = bazfn +_ = baz +_ = boto3 diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/gazelle_python.yaml b/gazelle/python/testdata/python_ignore_dependencies_directive/gazelle_python.yaml new file mode 100644 index 0000000000..1bf594f9b4 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: boto3 + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/python_ignore_dependencies_directive/test.yaml b/gazelle/python/testdata/python_ignore_dependencies_directive/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/python_ignore_dependencies_directive/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/python_ignore_files_directive/BUILD.in b/gazelle/python/testdata/python_ignore_files_directive/BUILD.in new file mode 100644 index 0000000000..6277446576 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_ignore_files some_other.py diff --git a/gazelle/python/testdata/python_ignore_files_directive/BUILD.out b/gazelle/python/testdata/python_ignore_files_directive/BUILD.out new file mode 100644 index 0000000000..1fe6030053 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/BUILD.out @@ -0,0 +1,9 @@ +load("@rules_python//python:defs.bzl", "py_library") + +# gazelle:python_ignore_files some_other.py + +py_library( + name = "python_ignore_files_directive", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/python_ignore_files_directive/README.md b/gazelle/python/testdata/python_ignore_files_directive/README.md new file mode 100644 index 0000000000..710118d6a4 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/README.md @@ -0,0 +1,3 @@ +# python_ignore_files directive + +This test case asserts that no targets are generated for ignored files. diff --git a/gazelle/python/testdata/python_ignore_files_directive/WORKSPACE b/gazelle/python/testdata/python_ignore_files_directive/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/python_ignore_files_directive/__init__.py b/gazelle/python/testdata/python_ignore_files_directive/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.in b/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.out b/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.out new file mode 100644 index 0000000000..af3c3983db --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/bar/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "bar", + srcs = ["baz.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/python_ignore_files_directive/bar/baz.py b/gazelle/python/testdata/python_ignore_files_directive/bar/baz.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/bar/baz.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/bar/some_other.py b/gazelle/python/testdata/python_ignore_files_directive/bar/some_other.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/bar/some_other.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.in b/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.in new file mode 100644 index 0000000000..c3049cabf5 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.in @@ -0,0 +1 @@ +# gazelle:python_ignore_files baz.py diff --git a/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.out b/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.out new file mode 100644 index 0000000000..c3049cabf5 --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/foo/BUILD.out @@ -0,0 +1 @@ +# gazelle:python_ignore_files baz.py diff --git a/gazelle/python/testdata/python_ignore_files_directive/foo/baz.py b/gazelle/python/testdata/python_ignore_files_directive/foo/baz.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/foo/baz.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/setup.py b/gazelle/python/testdata/python_ignore_files_directive/setup.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/setup.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/some_other.py b/gazelle/python/testdata/python_ignore_files_directive/some_other.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/some_other.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_ignore_files_directive/test.yaml b/gazelle/python/testdata/python_ignore_files_directive/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/python_ignore_files_directive/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/python_target_with_test_in_name/BUILD.in b/gazelle/python/testdata/python_target_with_test_in_name/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/python_target_with_test_in_name/BUILD.out b/gazelle/python/testdata/python_target_with_test_in_name/BUILD.out new file mode 100644 index 0000000000..a46f5c40b8 --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/BUILD.out @@ -0,0 +1,22 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "python_target_with_test_in_name", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "real_test", + srcs = ["real_test.py"], + deps = [ + ":python_target_with_test_in_name", + "@gazelle_python_test_boto3//:pkg", + ], +) + +py_test( + name = "test_reality", + srcs = ["test_reality.py"], + deps = [":python_target_with_test_in_name"], +) diff --git a/gazelle/python/testdata/python_target_with_test_in_name/README.md b/gazelle/python/testdata/python_target_with_test_in_name/README.md new file mode 100644 index 0000000000..8b592e10a7 --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/README.md @@ -0,0 +1,3 @@ +# Python target with test in name + +Cover the case where a python file either starts with `test_` or ends with `_test`, but is not an actual test. diff --git a/gazelle/python/testdata/python_target_with_test_in_name/WORKSPACE b/gazelle/python/testdata/python_target_with_test_in_name/WORKSPACE new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/python_target_with_test_in_name/__init__.py b/gazelle/python/testdata/python_target_with_test_in_name/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/python_target_with_test_in_name/gazelle_python.yaml b/gazelle/python/testdata/python_target_with_test_in_name/gazelle_python.yaml new file mode 100644 index 0000000000..1bf594f9b4 --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: boto3 + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/python_target_with_test_in_name/real_test.py b/gazelle/python/testdata/python_target_with_test_in_name/real_test.py new file mode 100644 index 0000000000..e390866be3 --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/real_test.py @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import boto3 +import __init__ + +_ = boto3 diff --git a/gazelle/python/testdata/python_target_with_test_in_name/test.yaml b/gazelle/python/testdata/python_target_with_test_in_name/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py b/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py new file mode 100644 index 0000000000..a3afc79dcd --- /dev/null +++ b/gazelle/python/testdata/python_target_with_test_in_name/test_reality.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import __init__ \ No newline at end of file diff --git a/gazelle/python/testdata/relative_imports/BUILD.in b/gazelle/python/testdata/relative_imports/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/relative_imports/BUILD.out b/gazelle/python/testdata/relative_imports/BUILD.out new file mode 100644 index 0000000000..2c0862748b --- /dev/null +++ b/gazelle/python/testdata/relative_imports/BUILD.out @@ -0,0 +1,21 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +py_library( + name = "relative_imports", + srcs = [ + "package1/module1.py", + "package1/module2.py", + ], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "relative_imports_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [ + ":relative_imports", + "//package2", + ], +) diff --git a/gazelle/python/testdata/relative_imports/README.md b/gazelle/python/testdata/relative_imports/README.md new file mode 100644 index 0000000000..1937cbcf4a --- /dev/null +++ b/gazelle/python/testdata/relative_imports/README.md @@ -0,0 +1,4 @@ +# Relative imports + +This test case asserts that the generated targets handle relative imports in +Python correctly. diff --git a/gazelle/python/testdata/relative_imports/WORKSPACE b/gazelle/python/testdata/relative_imports/WORKSPACE new file mode 100644 index 0000000000..4959898cdd --- /dev/null +++ b/gazelle/python/testdata/relative_imports/WORKSPACE @@ -0,0 +1 @@ +# This is a test data Bazel workspace. diff --git a/gazelle/python/testdata/relative_imports/__main__.py b/gazelle/python/testdata/relative_imports/__main__.py new file mode 100644 index 0000000000..8d468bd643 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/__main__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from package1.module1 import function1 +from package2.module3 import function3 + +print(function1()) +print(function3()) diff --git a/gazelle/python/testdata/relative_imports/package1/module1.py b/gazelle/python/testdata/relative_imports/package1/module1.py new file mode 100644 index 0000000000..28502f1f84 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package1/module1.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from .module2 import function2 + + +def function1(): + return "function1 " + function2() diff --git a/gazelle/python/testdata/relative_imports/package1/module2.py b/gazelle/python/testdata/relative_imports/package1/module2.py new file mode 100644 index 0000000000..f8893b24e6 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package1/module2.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def function2(): + return "function2" diff --git a/gazelle/python/testdata/relative_imports/package2/BUILD.in b/gazelle/python/testdata/relative_imports/package2/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/relative_imports/package2/BUILD.out b/gazelle/python/testdata/relative_imports/package2/BUILD.out new file mode 100644 index 0000000000..bbbc9f8e95 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package2/BUILD.out @@ -0,0 +1,13 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "package2", + srcs = [ + "__init__.py", + "module3.py", + "module4.py", + "subpackage1/module5.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/relative_imports/package2/__init__.py b/gazelle/python/testdata/relative_imports/package2/__init__.py new file mode 100644 index 0000000000..0f5956835b --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package2/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +class Class1: + def method1(self): + return "method1" diff --git a/gazelle/python/testdata/relative_imports/package2/module3.py b/gazelle/python/testdata/relative_imports/package2/module3.py new file mode 100644 index 0000000000..74978a08d9 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package2/module3.py @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from . import Class1 +from .subpackage1.module5 import function5 + + +def function3(): + c1 = Class1() + return "function3 " + c1.method1() + " " + function5() diff --git a/gazelle/python/testdata/relative_imports/package2/module4.py b/gazelle/python/testdata/relative_imports/package2/module4.py new file mode 100644 index 0000000000..b7509dc7cf --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package2/module4.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def function4(): + return "function4" diff --git a/gazelle/python/testdata/relative_imports/package2/subpackage1/module5.py b/gazelle/python/testdata/relative_imports/package2/subpackage1/module5.py new file mode 100644 index 0000000000..ea0b981fd0 --- /dev/null +++ b/gazelle/python/testdata/relative_imports/package2/subpackage1/module5.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ..module4 import function4 + + +def function5(): + return "function5 " + function4() diff --git a/gazelle/python/testdata/relative_imports/test.yaml b/gazelle/python/testdata/relative_imports/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/relative_imports/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/sibling_imports/README.md b/gazelle/python/testdata/sibling_imports/README.md new file mode 100644 index 0000000000..e59be07634 --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/README.md @@ -0,0 +1,3 @@ +# Sibling imports + +This test case asserts that imports from sibling modules are resolved correctly. It covers 3 different types of imports in `pkg/unit_test.py` \ No newline at end of file diff --git a/gazelle/python/testdata/sibling_imports/WORKSPACE b/gazelle/python/testdata/sibling_imports/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/sibling_imports/pkg/BUILD.in b/gazelle/python/testdata/sibling_imports/pkg/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/sibling_imports/pkg/BUILD.out b/gazelle/python/testdata/sibling_imports/pkg/BUILD.out new file mode 100644 index 0000000000..edb40a8bcb --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/pkg/BUILD.out @@ -0,0 +1,29 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "pkg", + srcs = [ + "__init__.py", + "a.py", + "b.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "test_util", + srcs = ["test_util.py"], + imports = [".."], +) + +py_test( + name = "unit_test", + srcs = ["unit_test.py"], + imports = [".."], + deps = [ + ":pkg", + ":test_util", + ], +) + diff --git a/gazelle/python/testdata/sibling_imports/pkg/__init__.py b/gazelle/python/testdata/sibling_imports/pkg/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/sibling_imports/pkg/a.py b/gazelle/python/testdata/sibling_imports/pkg/a.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/sibling_imports/pkg/b.py b/gazelle/python/testdata/sibling_imports/pkg/b.py new file mode 100644 index 0000000000..7095bdcfb2 --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/pkg/b.py @@ -0,0 +1,2 @@ +def run(): + pass \ No newline at end of file diff --git a/gazelle/python/testdata/sibling_imports/pkg/test_util.py b/gazelle/python/testdata/sibling_imports/pkg/test_util.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/sibling_imports/pkg/unit_test.py b/gazelle/python/testdata/sibling_imports/pkg/unit_test.py new file mode 100644 index 0000000000..a3218e2ec2 --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/pkg/unit_test.py @@ -0,0 +1,3 @@ +import a +from b import run +import test_util \ No newline at end of file diff --git a/gazelle/python/testdata/sibling_imports/test.yaml b/gazelle/python/testdata/sibling_imports/test.yaml new file mode 100644 index 0000000000..ed97d539c0 --- /dev/null +++ b/gazelle/python/testdata/sibling_imports/test.yaml @@ -0,0 +1 @@ +--- diff --git a/gazelle/python/testdata/simple_binary/BUILD.in b/gazelle/python/testdata/simple_binary/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/simple_binary/BUILD.out b/gazelle/python/testdata/simple_binary/BUILD.out new file mode 100644 index 0000000000..35aa7089ec --- /dev/null +++ b/gazelle/python/testdata/simple_binary/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +py_binary( + name = "simple_binary_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/simple_binary/README.md b/gazelle/python/testdata/simple_binary/README.md new file mode 100644 index 0000000000..00c90dcf65 --- /dev/null +++ b/gazelle/python/testdata/simple_binary/README.md @@ -0,0 +1,3 @@ +# Simple binary + +This test case asserts that a simple `py_binary` is generated as expected. diff --git a/gazelle/python/testdata/simple_binary/WORKSPACE b/gazelle/python/testdata/simple_binary/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_binary/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_binary/__main__.py b/gazelle/python/testdata/simple_binary/__main__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_binary/__main__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_binary/test.yaml b/gazelle/python/testdata/simple_binary/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/simple_binary/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/simple_binary_with_library/BUILD.in b/gazelle/python/testdata/simple_binary_with_library/BUILD.in new file mode 100644 index 0000000000..b60e84f17e --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/BUILD.in @@ -0,0 +1,18 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "simple_binary_with_library", + srcs = [ + "__init__.py", + "bar.py", + "foo.py", + ], +) + +# This target should be kept unmodified by Gazelle. +py_library( + name = "custom", + srcs = [ + "bar.py", + ], +) diff --git a/gazelle/python/testdata/simple_binary_with_library/BUILD.out b/gazelle/python/testdata/simple_binary_with_library/BUILD.out new file mode 100644 index 0000000000..eddc15cacd --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/BUILD.out @@ -0,0 +1,27 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +py_library( + name = "simple_binary_with_library", + srcs = [ + "__init__.py", + "bar.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +# This target should be kept unmodified by Gazelle. +py_library( + name = "custom", + srcs = [ + "bar.py", + ], +) + +py_binary( + name = "simple_binary_with_library_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [":simple_binary_with_library"], +) diff --git a/gazelle/python/testdata/simple_binary_with_library/README.md b/gazelle/python/testdata/simple_binary_with_library/README.md new file mode 100644 index 0000000000..cfc81a3581 --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/README.md @@ -0,0 +1,4 @@ +# Simple binary with library + +This test case asserts that a simple `py_binary` is generated as expected +referencing a `py_library`. diff --git a/gazelle/python/testdata/simple_binary_with_library/WORKSPACE b/gazelle/python/testdata/simple_binary_with_library/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_binary_with_library/__init__.py b/gazelle/python/testdata/simple_binary_with_library/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_binary_with_library/__main__.py b/gazelle/python/testdata/simple_binary_with_library/__main__.py new file mode 100644 index 0000000000..bc7ddf0a71 --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/__main__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import foo diff --git a/gazelle/python/testdata/simple_binary_with_library/bar.py b/gazelle/python/testdata/simple_binary_with_library/bar.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/bar.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_binary_with_library/foo.py b/gazelle/python/testdata/simple_binary_with_library/foo.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/foo.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_binary_with_library/test.yaml b/gazelle/python/testdata/simple_binary_with_library/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/simple_binary_with_library/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/simple_library/BUILD.in b/gazelle/python/testdata/simple_library/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/simple_library/BUILD.out b/gazelle/python/testdata/simple_library/BUILD.out new file mode 100644 index 0000000000..5793ac2066 --- /dev/null +++ b/gazelle/python/testdata/simple_library/BUILD.out @@ -0,0 +1,7 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "simple_library", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/simple_library/README.md b/gazelle/python/testdata/simple_library/README.md new file mode 100644 index 0000000000..f88bda1ba1 --- /dev/null +++ b/gazelle/python/testdata/simple_library/README.md @@ -0,0 +1,3 @@ +# Simple library + +This test case asserts that a simple `py_library` is generated as expected. diff --git a/gazelle/python/testdata/simple_library/WORKSPACE b/gazelle/python/testdata/simple_library/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_library/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_library/__init__.py b/gazelle/python/testdata/simple_library/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_library/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_library/test.yaml b/gazelle/python/testdata/simple_library/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/simple_library/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/simple_library_without_init/BUILD.in b/gazelle/python/testdata/simple_library_without_init/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/simple_library_without_init/BUILD.out b/gazelle/python/testdata/simple_library_without_init/BUILD.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/simple_library_without_init/README.md b/gazelle/python/testdata/simple_library_without_init/README.md new file mode 100644 index 0000000000..5c0a1cad9f --- /dev/null +++ b/gazelle/python/testdata/simple_library_without_init/README.md @@ -0,0 +1,4 @@ +# Simple library without `__init__.py` + +This test case asserts that a simple `py_library` is generated as expected +without an `__init__.py` but with a `BUILD` file marking it as a package. diff --git a/gazelle/python/testdata/simple_library_without_init/WORKSPACE b/gazelle/python/testdata/simple_library_without_init/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_library_without_init/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_library_without_init/foo/BUILD.in b/gazelle/python/testdata/simple_library_without_init/foo/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/simple_library_without_init/foo/BUILD.out b/gazelle/python/testdata/simple_library_without_init/foo/BUILD.out new file mode 100644 index 0000000000..2faa046fc1 --- /dev/null +++ b/gazelle/python/testdata/simple_library_without_init/foo/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = ["foo.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/simple_library_without_init/foo/foo.py b/gazelle/python/testdata/simple_library_without_init/foo/foo.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/simple_library_without_init/foo/foo.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/simple_library_without_init/test.yaml b/gazelle/python/testdata/simple_library_without_init/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/simple_library_without_init/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/simple_test/BUILD.in b/gazelle/python/testdata/simple_test/BUILD.in new file mode 100644 index 0000000000..ffd20ea85d --- /dev/null +++ b/gazelle/python/testdata/simple_test/BUILD.in @@ -0,0 +1,6 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "simple_test", + srcs = ["__init__.py"], +) diff --git a/gazelle/python/testdata/simple_test/BUILD.out b/gazelle/python/testdata/simple_test/BUILD.out new file mode 100644 index 0000000000..ae2f982032 --- /dev/null +++ b/gazelle/python/testdata/simple_test/BUILD.out @@ -0,0 +1,17 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "simple_test", + srcs = [ + "__init__.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "simple_test_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [":simple_test"], +) diff --git a/gazelle/python/testdata/simple_test/README.md b/gazelle/python/testdata/simple_test/README.md new file mode 100644 index 0000000000..0cfbbebc02 --- /dev/null +++ b/gazelle/python/testdata/simple_test/README.md @@ -0,0 +1,3 @@ +# Simple test + +This test case asserts that a simple `py_test` is generated as expected. diff --git a/gazelle/python/testdata/simple_test/WORKSPACE b/gazelle/python/testdata/simple_test/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_test/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_test/__init__.py b/gazelle/python/testdata/simple_test/__init__.py new file mode 100644 index 0000000000..b274b0d921 --- /dev/null +++ b/gazelle/python/testdata/simple_test/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from foo import foo + +_ = foo diff --git a/gazelle/python/testdata/simple_test/__test__.py b/gazelle/python/testdata/simple_test/__test__.py new file mode 100644 index 0000000000..2b180a5f53 --- /dev/null +++ b/gazelle/python/testdata/simple_test/__test__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from __init__ import foo + + +class FooTest(unittest.TestCase): + def test_foo(self): + self.assertEqual("foo", foo()) + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/simple_test/foo.py b/gazelle/python/testdata/simple_test/foo.py new file mode 100644 index 0000000000..932de45b74 --- /dev/null +++ b/gazelle/python/testdata/simple_test/foo.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def foo(): + return "foo" diff --git a/gazelle/python/testdata/simple_test/test.yaml b/gazelle/python/testdata/simple_test/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/simple_test/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/simple_test_with_conftest/BUILD.in b/gazelle/python/testdata/simple_test_with_conftest/BUILD.in new file mode 100644 index 0000000000..3f2beb3147 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/BUILD.in @@ -0,0 +1 @@ +load("@rules_python//python:defs.bzl", "py_library") diff --git a/gazelle/python/testdata/simple_test_with_conftest/BUILD.out b/gazelle/python/testdata/simple_test_with_conftest/BUILD.out new file mode 100644 index 0000000000..18079bf2f4 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/BUILD.out @@ -0,0 +1,27 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "simple_test_with_conftest", + srcs = [ + "__init__.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], +) + +py_library( + name = "conftest", + testonly = True, + srcs = ["conftest.py"], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "simple_test_with_conftest_test", + srcs = ["__test__.py"], + main = "__test__.py", + deps = [ + ":conftest", + ":simple_test_with_conftest", + ], +) diff --git a/gazelle/python/testdata/simple_test_with_conftest/README.md b/gazelle/python/testdata/simple_test_with_conftest/README.md new file mode 100644 index 0000000000..0ff245f808 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/README.md @@ -0,0 +1,4 @@ +# Simple test with conftest.py + +This test case asserts that a simple `py_test` is generated as expected when a +`conftest.py` is present. diff --git a/gazelle/python/testdata/simple_test_with_conftest/WORKSPACE b/gazelle/python/testdata/simple_test_with_conftest/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/simple_test_with_conftest/__init__.py b/gazelle/python/testdata/simple_test_with_conftest/__init__.py new file mode 100644 index 0000000000..b274b0d921 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from foo import foo + +_ = foo diff --git a/gazelle/python/testdata/simple_test_with_conftest/__test__.py b/gazelle/python/testdata/simple_test_with_conftest/__test__.py new file mode 100644 index 0000000000..2b180a5f53 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/__test__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from __init__ import foo + + +class FooTest(unittest.TestCase): + def test_foo(self): + self.assertEqual("foo", foo()) + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.in b/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.in new file mode 100644 index 0000000000..3f2beb3147 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.in @@ -0,0 +1 @@ +load("@rules_python//python:defs.bzl", "py_library") diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.out b/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.out new file mode 100644 index 0000000000..e42c4998b1 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/BUILD.out @@ -0,0 +1,30 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "bar", + srcs = [ + "__init__.py", + "bar.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], +) + +py_library( + name = "conftest", + testonly = True, + srcs = ["conftest.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "bar_test", + srcs = ["__test__.py"], + imports = [".."], + main = "__test__.py", + deps = [ + ":bar", + ":conftest", + ], +) diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/__init__.py b/gazelle/python/testdata/simple_test_with_conftest/bar/__init__.py new file mode 100644 index 0000000000..3f0275e179 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/__init__.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from bar import bar + +_ = bar diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/__test__.py b/gazelle/python/testdata/simple_test_with_conftest/bar/__test__.py new file mode 100644 index 0000000000..00c4c28247 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/__test__.py @@ -0,0 +1,26 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from __init__ import bar + + +class BarTest(unittest.TestCase): + def test_bar(self): + self.assertEqual("bar", bar()) + + +if __name__ == "__main__": + unittest.main() diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/bar.py b/gazelle/python/testdata/simple_test_with_conftest/bar/bar.py new file mode 100644 index 0000000000..ba6a62db30 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/bar.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +def bar(): + return "bar" diff --git a/gazelle/python/testdata/simple_test_with_conftest/bar/conftest.py b/gazelle/python/testdata/simple_test_with_conftest/bar/conftest.py new file mode 100644 index 0000000000..41010956cf --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/bar/conftest.py @@ -0,0 +1,13 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/gazelle/python/testdata/simple_test_with_conftest/conftest.py b/gazelle/python/testdata/simple_test_with_conftest/conftest.py new file mode 100644 index 0000000000..bbdfb4c588 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/conftest.py @@ -0,0 +1,14 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + diff --git a/gazelle/python/testdata/simple_test_with_conftest/foo.py b/gazelle/python/testdata/simple_test_with_conftest/foo.py new file mode 100644 index 0000000000..932de45b74 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/foo.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +def foo(): + return "foo" diff --git a/gazelle/python/testdata/simple_test_with_conftest/test.yaml b/gazelle/python/testdata/simple_test_with_conftest/test.yaml new file mode 100644 index 0000000000..2410223e59 --- /dev/null +++ b/gazelle/python/testdata/simple_test_with_conftest/test.yaml @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +expect: + exit_code: 0 diff --git a/gazelle/python/testdata/subdir_sources/BUILD.in b/gazelle/python/testdata/subdir_sources/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/BUILD.out b/gazelle/python/testdata/subdir_sources/BUILD.out new file mode 100644 index 0000000000..d03a8f05ac --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_binary") + +py_binary( + name = "subdir_sources_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [ + "//foo", + "//one/two", + ], +) diff --git a/gazelle/python/testdata/subdir_sources/README.md b/gazelle/python/testdata/subdir_sources/README.md new file mode 100644 index 0000000000..79ca3a2c20 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/README.md @@ -0,0 +1,5 @@ +# Subdir sources + +This test case asserts that `py_library` targets are generated with sources from +subdirectories and that dependencies are added according to the target that the +imported source file belongs to. diff --git a/gazelle/python/testdata/subdir_sources/WORKSPACE b/gazelle/python/testdata/subdir_sources/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/subdir_sources/__main__.py b/gazelle/python/testdata/subdir_sources/__main__.py new file mode 100644 index 0000000000..aacfc67bc5 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/__main__.py @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import foo.bar.bar as bar +import foo.baz.baz as baz +import one.two.three as three + +_ = bar +_ = baz +_ = three diff --git a/gazelle/python/testdata/subdir_sources/foo/BUILD.in b/gazelle/python/testdata/subdir_sources/foo/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/BUILD.out new file mode 100644 index 0000000000..f99857dc52 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/BUILD.out @@ -0,0 +1,13 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "foo", + srcs = [ + "__init__.py", + "bar/bar.py", + "baz/baz.py", + "foo.py", + ], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/subdir_sources/foo/__init__.py b/gazelle/python/testdata/subdir_sources/foo/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/bar/bar.py b/gazelle/python/testdata/subdir_sources/foo/bar/bar.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/bar/bar.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/baz/baz.py b/gazelle/python/testdata/subdir_sources/foo/baz/baz.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/baz/baz.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/foo.py b/gazelle/python/testdata/subdir_sources/foo/foo.py new file mode 100644 index 0000000000..a98c73d4eb --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/foo.py @@ -0,0 +1,17 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import foo.bar.bar as bar + +_ = bar diff --git a/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.in b/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.out new file mode 100644 index 0000000000..0ef0cc12e6 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_build/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "has_build", + srcs = ["python/my_module.py"], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_build/python/my_module.py b/gazelle/python/testdata/subdir_sources/foo/has_build/python/my_module.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_build/python/my_module.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in b/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py b/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.in b/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.out new file mode 100644 index 0000000000..ce59ee263e --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_init/BUILD.out @@ -0,0 +1,11 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "has_init", + srcs = [ + "__init__.py", + "python/my_module.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_init/__init__.py b/gazelle/python/testdata/subdir_sources/foo/has_init/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_init/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/has_init/python/my_module.py b/gazelle/python/testdata/subdir_sources/foo/has_init/python/my_module.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_init/python/my_module.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.in b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out new file mode 100644 index 0000000000..265c08bd57 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/BUILD.out @@ -0,0 +1,17 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +py_library( + name = "has_main", + srcs = ["python/my_module.py"], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) + +py_binary( + name = "has_main_bin", + srcs = ["__main__.py"], + imports = ["../.."], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [":has_main"], +) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py b/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py new file mode 100644 index 0000000000..bd0fe61faa --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/__main__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import foo.has_main.python.my_module \ No newline at end of file diff --git a/gazelle/python/testdata/subdir_sources/foo/has_main/python/my_module.py b/gazelle/python/testdata/subdir_sources/foo/has_main/python/my_module.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_main/python/my_module.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.in b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out new file mode 100644 index 0000000000..80739d9a3f --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/BUILD.out @@ -0,0 +1,16 @@ +load("@rules_python//python:defs.bzl", "py_library", "py_test") + +py_library( + name = "has_test", + srcs = ["python/my_module.py"], + imports = ["../.."], + visibility = ["//:__subpackages__"], +) + +py_test( + name = "has_test_test", + srcs = ["__test__.py"], + imports = ["../.."], + main = "__test__.py", + deps = [":has_test"], +) diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py b/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py new file mode 100644 index 0000000000..3c9ed1a1bd --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/__test__.py @@ -0,0 +1,16 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. +import foo.has_test.python.my_module \ No newline at end of file diff --git a/gazelle/python/testdata/subdir_sources/foo/has_test/python/my_module.py b/gazelle/python/testdata/subdir_sources/foo/has_test/python/my_module.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/foo/has_test/python/my_module.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/one/BUILD.in b/gazelle/python/testdata/subdir_sources/one/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/one/BUILD.out b/gazelle/python/testdata/subdir_sources/one/BUILD.out new file mode 100644 index 0000000000..f2e57456ca --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "one", + srcs = ["__init__.py"], + imports = [".."], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/subdir_sources/one/__init__.py b/gazelle/python/testdata/subdir_sources/one/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/one/two/BUILD.in b/gazelle/python/testdata/subdir_sources/one/two/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/subdir_sources/one/two/BUILD.out b/gazelle/python/testdata/subdir_sources/one/two/BUILD.out new file mode 100644 index 0000000000..f632eedcf3 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/two/BUILD.out @@ -0,0 +1,12 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "two", + srcs = [ + "__init__.py", + "three.py", + ], + imports = ["../.."], + visibility = ["//:__subpackages__"], + deps = ["//foo"], +) diff --git a/gazelle/python/testdata/subdir_sources/one/two/README.md b/gazelle/python/testdata/subdir_sources/one/two/README.md new file mode 100644 index 0000000000..ec4c15ddaa --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/two/README.md @@ -0,0 +1,2 @@ +# Same package imports +This test case asserts that no `deps` is needed when a module imports another module in the same package \ No newline at end of file diff --git a/gazelle/python/testdata/subdir_sources/one/two/__init__.py b/gazelle/python/testdata/subdir_sources/one/two/__init__.py new file mode 100644 index 0000000000..72357b3c46 --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/two/__init__.py @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import foo.baz.baz as baz +import three + +_ = baz diff --git a/gazelle/python/testdata/subdir_sources/one/two/three.py b/gazelle/python/testdata/subdir_sources/one/two/three.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/one/two/three.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/subdir_sources/test.yaml b/gazelle/python/testdata/subdir_sources/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/subdir_sources/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/with_nested_import_statements/BUILD.in b/gazelle/python/testdata/with_nested_import_statements/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/with_nested_import_statements/BUILD.out b/gazelle/python/testdata/with_nested_import_statements/BUILD.out new file mode 100644 index 0000000000..45bf265180 --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/BUILD.out @@ -0,0 +1,8 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "with_nested_import_statements", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], + deps = ["@gazelle_python_test_boto3//:pkg"], +) diff --git a/gazelle/python/testdata/with_nested_import_statements/README.md b/gazelle/python/testdata/with_nested_import_statements/README.md new file mode 100644 index 0000000000..7213b34565 --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/README.md @@ -0,0 +1,4 @@ +# With nested import statements + +This test case asserts that a `py_library` is generated with dependencies +extracted from nested import statements from the Python source file. diff --git a/gazelle/python/testdata/with_nested_import_statements/WORKSPACE b/gazelle/python/testdata/with_nested_import_statements/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/with_nested_import_statements/__init__.py b/gazelle/python/testdata/with_nested_import_statements/__init__.py new file mode 100644 index 0000000000..733b51f974 --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/__init__.py @@ -0,0 +1,25 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +_ = os +_ = sys + + +def main(): + import boto3 + + _ = boto3 diff --git a/gazelle/python/testdata/with_nested_import_statements/gazelle_python.yaml b/gazelle/python/testdata/with_nested_import_statements/gazelle_python.yaml new file mode 100644 index 0000000000..1bf594f9b4 --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/gazelle_python.yaml @@ -0,0 +1,18 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: boto3 + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/with_nested_import_statements/test.yaml b/gazelle/python/testdata/with_nested_import_statements/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/with_nested_import_statements/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/with_std_requirements/BUILD.in b/gazelle/python/testdata/with_std_requirements/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/with_std_requirements/BUILD.out b/gazelle/python/testdata/with_std_requirements/BUILD.out new file mode 100644 index 0000000000..a382ca88c2 --- /dev/null +++ b/gazelle/python/testdata/with_std_requirements/BUILD.out @@ -0,0 +1,7 @@ +load("@rules_python//python:defs.bzl", "py_library") + +py_library( + name = "with_std_requirements", + srcs = ["__init__.py"], + visibility = ["//:__subpackages__"], +) diff --git a/gazelle/python/testdata/with_std_requirements/README.md b/gazelle/python/testdata/with_std_requirements/README.md new file mode 100644 index 0000000000..4eaf1b04c2 --- /dev/null +++ b/gazelle/python/testdata/with_std_requirements/README.md @@ -0,0 +1,4 @@ +# With std requirements + +This test case asserts that a `py_library` is generated without any `deps` since +it only imports Python standard library packages. diff --git a/gazelle/python/testdata/with_std_requirements/WORKSPACE b/gazelle/python/testdata/with_std_requirements/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/with_std_requirements/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/with_std_requirements/__init__.py b/gazelle/python/testdata/with_std_requirements/__init__.py new file mode 100644 index 0000000000..e51d320213 --- /dev/null +++ b/gazelle/python/testdata/with_std_requirements/__init__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +_ = os +_ = sys diff --git a/gazelle/python/testdata/with_std_requirements/test.yaml b/gazelle/python/testdata/with_std_requirements/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/with_std_requirements/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/with_third_party_requirements/BUILD.in b/gazelle/python/testdata/with_third_party_requirements/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/with_third_party_requirements/BUILD.out b/gazelle/python/testdata/with_third_party_requirements/BUILD.out new file mode 100644 index 0000000000..2a97d8bc1e --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/BUILD.out @@ -0,0 +1,24 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +py_library( + name = "with_third_party_requirements", + srcs = [ + "__init__.py", + "bar.py", + "foo.py", + ], + visibility = ["//:__subpackages__"], + deps = [ + "@gazelle_python_test_baz//:pkg", + "@gazelle_python_test_boto3//:pkg", + "@gazelle_python_test_djangorestframework//:pkg", + ], +) + +py_binary( + name = "with_third_party_requirements_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = ["@gazelle_python_test_baz//:pkg"], +) diff --git a/gazelle/python/testdata/with_third_party_requirements/README.md b/gazelle/python/testdata/with_third_party_requirements/README.md new file mode 100644 index 0000000000..a7ef7a3ca7 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/README.md @@ -0,0 +1,7 @@ +# With third-party requirements + +This test case asserts that +* a `py_library` is generated with dependencies +extracted from its sources and a `py_binary` is generated embeding the +`py_library` and inherits its dependencies, without specifying the `deps` again. +* when a third-party library and a module in the same package having the same name, the one in the same package takes precedence. diff --git a/gazelle/python/testdata/with_third_party_requirements/WORKSPACE b/gazelle/python/testdata/with_third_party_requirements/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/with_third_party_requirements/__init__.py b/gazelle/python/testdata/with_third_party_requirements/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/with_third_party_requirements/__main__.py b/gazelle/python/testdata/with_third_party_requirements/__main__.py new file mode 100644 index 0000000000..38e9a55fb5 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/__main__.py @@ -0,0 +1,19 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import bar +import foo + +_ = bar +_ = foo diff --git a/gazelle/python/testdata/with_third_party_requirements/bar.py b/gazelle/python/testdata/with_third_party_requirements/bar.py new file mode 100644 index 0000000000..08f2e7c289 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/bar.py @@ -0,0 +1,25 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import bar +import boto3 +import rest_framework + +_ = os + +_ = bar +_ = boto3 +_ = rest_framework diff --git a/gazelle/python/testdata/with_third_party_requirements/foo.py b/gazelle/python/testdata/with_third_party_requirements/foo.py new file mode 100644 index 0000000000..9bebbfcfc6 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/foo.py @@ -0,0 +1,25 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys + +import boto3 +import foo +import rest_framework + +_ = sys + +_ = boto3 +_ = foo +_ = rest_framework diff --git a/gazelle/python/testdata/with_third_party_requirements/gazelle_python.yaml b/gazelle/python/testdata/with_third_party_requirements/gazelle_python.yaml new file mode 100644 index 0000000000..7753cfff2c --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/gazelle_python.yaml @@ -0,0 +1,21 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + boto3: boto3 + rest_framework: djangorestframework + foo: baz + bar: baz + pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/python/testdata/with_third_party_requirements/test.yaml b/gazelle/python/testdata/with_third_party_requirements/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.in b/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.in new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.out b/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.out new file mode 100644 index 0000000000..577f167143 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/BUILD.out @@ -0,0 +1,25 @@ +load("@rules_python//python:defs.bzl", "py_binary", "py_library") + +py_library( + name = "with_third_party_requirements_from_imports", + srcs = [ + "__init__.py", + "bar.py", + ], + visibility = ["//:__subpackages__"], + deps = [ + "@gazelle_python_test_google_cloud_aiplatform//:pkg", + "@gazelle_python_test_google_cloud_storage//:pkg", + ], +) + +py_binary( + name = "with_third_party_requirements_from_imports_bin", + srcs = ["__main__.py"], + main = "__main__.py", + visibility = ["//:__subpackages__"], + deps = [ + ":with_third_party_requirements_from_imports", + "@gazelle_python_test_google_cloud_aiplatform//:pkg", + ], +) diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/README.md b/gazelle/python/testdata/with_third_party_requirements_from_imports/README.md new file mode 100644 index 0000000000..c50a1ca100 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/README.md @@ -0,0 +1,15 @@ +# With third-party requirements (from imports) + +This test case covers imports of the form: + +```python +from my_pip_dep import foo +``` + +for example + +```python +from google.cloud import aiplatform, storage +``` + +See https://github.com/bazelbuild/rules_python/issues/709 and https://github.com/sramirezmartin/gazelle-toy-example. diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/WORKSPACE b/gazelle/python/testdata/with_third_party_requirements_from_imports/WORKSPACE new file mode 100644 index 0000000000..faff6af87a --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/WORKSPACE @@ -0,0 +1 @@ +# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/__init__.py b/gazelle/python/testdata/with_third_party_requirements_from_imports/__init__.py new file mode 100644 index 0000000000..730755995d --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# For test purposes only. diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/__main__.py b/gazelle/python/testdata/with_third_party_requirements_from_imports/__main__.py new file mode 100644 index 0000000000..2062a9b04a --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/__main__.py @@ -0,0 +1,20 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from bar import main +from google.cloud import aiplatform + +if __name__ == "__main__": + print(aiplatform) + main() diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/bar.py b/gazelle/python/testdata/with_third_party_requirements_from_imports/bar.py new file mode 100644 index 0000000000..6886b2b4e9 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/bar.py @@ -0,0 +1,20 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from google.cloud import aiplatform, storage + + +def main(): + a = dir(aiplatform) + b = dir(storage) diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml b/gazelle/python/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml new file mode 100644 index 0000000000..8b5694b2d7 --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml @@ -0,0 +1,1678 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +manifest: + modules_mapping: + cachetools: cachetools + cachetools.__init__: cachetools + cachetools.func: cachetools + cachetools.keys: cachetools + certifi: certifi + certifi.__init__: certifi + certifi.__main__: certifi + certifi.core: certifi + charset_normalizer: charset_normalizer + charset_normalizer.__init__: charset_normalizer + charset_normalizer.api: charset_normalizer + charset_normalizer.assets: charset_normalizer + charset_normalizer.assets.__init__: charset_normalizer + charset_normalizer.cd: charset_normalizer + charset_normalizer.cli: charset_normalizer + charset_normalizer.cli.__init__: charset_normalizer + charset_normalizer.cli.normalizer: charset_normalizer + charset_normalizer.constant: charset_normalizer + charset_normalizer.legacy: charset_normalizer + charset_normalizer.md: charset_normalizer + charset_normalizer.models: charset_normalizer + charset_normalizer.utils: charset_normalizer + charset_normalizer.version: charset_normalizer + dateutil: python_dateutil + dateutil.__init__: python_dateutil + dateutil._common: python_dateutil + dateutil._version: python_dateutil + dateutil.easter: python_dateutil + dateutil.parser: python_dateutil + dateutil.parser.__init__: python_dateutil + dateutil.parser._parser: python_dateutil + dateutil.parser.isoparser: python_dateutil + dateutil.relativedelta: python_dateutil + dateutil.rrule: python_dateutil + dateutil.tz: python_dateutil + dateutil.tz.__init__: python_dateutil + dateutil.tz._common: python_dateutil + dateutil.tz._factories: python_dateutil + dateutil.tz.tz: python_dateutil + dateutil.tz.win: python_dateutil + dateutil.tzwin: python_dateutil + dateutil.utils: python_dateutil + dateutil.zoneinfo: python_dateutil + dateutil.zoneinfo.__init__: python_dateutil + dateutil.zoneinfo.rebuild: python_dateutil + docs.conf: google_cloud_resource_manager + google._async_resumable_media: google_resumable_media + google._async_resumable_media.__init__: google_resumable_media + google._async_resumable_media._download: google_resumable_media + google._async_resumable_media._helpers: google_resumable_media + google._async_resumable_media._upload: google_resumable_media + google._async_resumable_media.requests: google_resumable_media + google._async_resumable_media.requests.__init__: google_resumable_media + google._async_resumable_media.requests._request_helpers: google_resumable_media + google._async_resumable_media.requests.download: google_resumable_media + google._async_resumable_media.requests.upload: google_resumable_media + google.api: googleapis_common_protos + google.api.__init__: googleapis_common_protos + google.api.annotations_pb2: googleapis_common_protos + google.api.auth_pb2: googleapis_common_protos + google.api.backend_pb2: googleapis_common_protos + google.api.billing_pb2: googleapis_common_protos + google.api.client_pb2: googleapis_common_protos + google.api.config_change_pb2: googleapis_common_protos + google.api.consumer_pb2: googleapis_common_protos + google.api.context_pb2: googleapis_common_protos + google.api.control_pb2: googleapis_common_protos + google.api.distribution_pb2: googleapis_common_protos + google.api.documentation_pb2: googleapis_common_protos + google.api.endpoint_pb2: googleapis_common_protos + google.api.error_reason_pb2: googleapis_common_protos + google.api.field_behavior_pb2: googleapis_common_protos + google.api.http_pb2: googleapis_common_protos + google.api.httpbody_pb2: googleapis_common_protos + google.api.label_pb2: googleapis_common_protos + google.api.launch_stage_pb2: googleapis_common_protos + google.api.log_pb2: googleapis_common_protos + google.api.logging_pb2: googleapis_common_protos + google.api.metric_pb2: googleapis_common_protos + google.api.monitored_resource_pb2: googleapis_common_protos + google.api.monitoring_pb2: googleapis_common_protos + google.api.quota_pb2: googleapis_common_protos + google.api.resource_pb2: googleapis_common_protos + google.api.routing_pb2: googleapis_common_protos + google.api.service_pb2: googleapis_common_protos + google.api.source_info_pb2: googleapis_common_protos + google.api.system_parameter_pb2: googleapis_common_protos + google.api.usage_pb2: googleapis_common_protos + google.api.visibility_pb2: googleapis_common_protos + google.api_core: google_api_core + google.api_core.__init__: google_api_core + google.api_core.bidi: google_api_core + google.api_core.client_info: google_api_core + google.api_core.client_options: google_api_core + google.api_core.datetime_helpers: google_api_core + google.api_core.exceptions: google_api_core + google.api_core.extended_operation: google_api_core + google.api_core.future: google_api_core + google.api_core.future.__init__: google_api_core + google.api_core.future._helpers: google_api_core + google.api_core.future.async_future: google_api_core + google.api_core.future.base: google_api_core + google.api_core.future.polling: google_api_core + google.api_core.gapic_v1: google_api_core + google.api_core.gapic_v1.__init__: google_api_core + google.api_core.gapic_v1.client_info: google_api_core + google.api_core.gapic_v1.config: google_api_core + google.api_core.gapic_v1.config_async: google_api_core + google.api_core.gapic_v1.method: google_api_core + google.api_core.gapic_v1.method_async: google_api_core + google.api_core.gapic_v1.routing_header: google_api_core + google.api_core.general_helpers: google_api_core + google.api_core.grpc_helpers: google_api_core + google.api_core.grpc_helpers_async: google_api_core + google.api_core.iam: google_api_core + google.api_core.operation: google_api_core + google.api_core.operation_async: google_api_core + google.api_core.operations_v1: google_api_core + google.api_core.operations_v1.__init__: google_api_core + google.api_core.operations_v1.abstract_operations_client: google_api_core + google.api_core.operations_v1.operations_async_client: google_api_core + google.api_core.operations_v1.operations_client: google_api_core + google.api_core.operations_v1.operations_client_config: google_api_core + google.api_core.operations_v1.pagers: google_api_core + google.api_core.operations_v1.transports: google_api_core + google.api_core.operations_v1.transports.__init__: google_api_core + google.api_core.operations_v1.transports.base: google_api_core + google.api_core.operations_v1.transports.rest: google_api_core + google.api_core.page_iterator: google_api_core + google.api_core.page_iterator_async: google_api_core + google.api_core.path_template: google_api_core + google.api_core.protobuf_helpers: google_api_core + google.api_core.rest_helpers: google_api_core + google.api_core.rest_streaming: google_api_core + google.api_core.retry: google_api_core + google.api_core.retry_async: google_api_core + google.api_core.timeout: google_api_core + google.api_core.version: google_api_core + google.auth: google_auth + google.auth.__init__: google_auth + google.auth._cloud_sdk: google_auth + google.auth._credentials_async: google_auth + google.auth._default: google_auth + google.auth._default_async: google_auth + google.auth._helpers: google_auth + google.auth._jwt_async: google_auth + google.auth._oauth2client: google_auth + google.auth._service_account_info: google_auth + google.auth.app_engine: google_auth + google.auth.aws: google_auth + google.auth.compute_engine: google_auth + google.auth.compute_engine.__init__: google_auth + google.auth.compute_engine._metadata: google_auth + google.auth.compute_engine.credentials: google_auth + google.auth.credentials: google_auth + google.auth.crypt: google_auth + google.auth.crypt.__init__: google_auth + google.auth.crypt._cryptography_rsa: google_auth + google.auth.crypt._helpers: google_auth + google.auth.crypt._python_rsa: google_auth + google.auth.crypt.base: google_auth + google.auth.crypt.es256: google_auth + google.auth.crypt.rsa: google_auth + google.auth.downscoped: google_auth + google.auth.environment_vars: google_auth + google.auth.exceptions: google_auth + google.auth.external_account: google_auth + google.auth.iam: google_auth + google.auth.identity_pool: google_auth + google.auth.impersonated_credentials: google_auth + google.auth.jwt: google_auth + google.auth.transport: google_auth + google.auth.transport.__init__: google_auth + google.auth.transport._aiohttp_requests: google_auth + google.auth.transport._http_client: google_auth + google.auth.transport._mtls_helper: google_auth + google.auth.transport.grpc: google_auth + google.auth.transport.mtls: google_auth + google.auth.transport.requests: google_auth + google.auth.transport.urllib3: google_auth + google.auth.version: google_auth + google.cloud._helpers: google_cloud_core + google.cloud._helpers.__init__: google_cloud_core + google.cloud._http: google_cloud_core + google.cloud._http.__init__: google_cloud_core + google.cloud._testing: google_cloud_core + google.cloud._testing.__init__: google_cloud_core + google.cloud.aiplatform: google_cloud_aiplatform + google.cloud.aiplatform.__init__: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.__init__: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.match_service_pb2: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.match_service_pb2_grpc: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.matching_engine_index: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.matching_engine_index_config: google_cloud_aiplatform + google.cloud.aiplatform._matching_engine.matching_engine_index_endpoint: google_cloud_aiplatform + google.cloud.aiplatform.base: google_cloud_aiplatform + google.cloud.aiplatform.compat: google_cloud_aiplatform + google.cloud.aiplatform.compat.__init__: google_cloud_aiplatform + google.cloud.aiplatform.compat.services: google_cloud_aiplatform + google.cloud.aiplatform.compat.services.__init__: google_cloud_aiplatform + google.cloud.aiplatform.compat.types: google_cloud_aiplatform + google.cloud.aiplatform.compat.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.constants: google_cloud_aiplatform + google.cloud.aiplatform.constants.__init__: google_cloud_aiplatform + google.cloud.aiplatform.constants.base: google_cloud_aiplatform + google.cloud.aiplatform.constants.prediction: google_cloud_aiplatform + google.cloud.aiplatform.datasets: google_cloud_aiplatform + google.cloud.aiplatform.datasets.__init__: google_cloud_aiplatform + google.cloud.aiplatform.datasets._datasources: google_cloud_aiplatform + google.cloud.aiplatform.datasets.column_names_dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.image_dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.tabular_dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.text_dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.time_series_dataset: google_cloud_aiplatform + google.cloud.aiplatform.datasets.video_dataset: google_cloud_aiplatform + google.cloud.aiplatform.explain: google_cloud_aiplatform + google.cloud.aiplatform.explain.__init__: google_cloud_aiplatform + google.cloud.aiplatform.explain.lit: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.__init__: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.metadata_builder: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.__init__: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v1: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v1.saved_model_metadata_builder: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v2: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v2.__init__: google_cloud_aiplatform + google.cloud.aiplatform.explain.metadata.tf.v2.saved_model_metadata_builder: google_cloud_aiplatform + google.cloud.aiplatform.featurestore: google_cloud_aiplatform + google.cloud.aiplatform.featurestore.__init__: google_cloud_aiplatform + google.cloud.aiplatform.featurestore.entity_type: google_cloud_aiplatform + google.cloud.aiplatform.featurestore.feature: google_cloud_aiplatform + google.cloud.aiplatform.featurestore.featurestore: google_cloud_aiplatform + google.cloud.aiplatform.gapic: google_cloud_aiplatform + google.cloud.aiplatform.gapic.__init__: google_cloud_aiplatform + google.cloud.aiplatform.gapic.schema: google_cloud_aiplatform + google.cloud.aiplatform.gapic.schema.__init__: google_cloud_aiplatform + google.cloud.aiplatform.helpers: google_cloud_aiplatform + google.cloud.aiplatform.helpers.__init__: google_cloud_aiplatform + google.cloud.aiplatform.helpers.container_uri_builders: google_cloud_aiplatform + google.cloud.aiplatform.hyperparameter_tuning: google_cloud_aiplatform + google.cloud.aiplatform.initializer: google_cloud_aiplatform + google.cloud.aiplatform.jobs: google_cloud_aiplatform + google.cloud.aiplatform.metadata: google_cloud_aiplatform + google.cloud.aiplatform.metadata.__init__: google_cloud_aiplatform + google.cloud.aiplatform.metadata.artifact: google_cloud_aiplatform + google.cloud.aiplatform.metadata.constants: google_cloud_aiplatform + google.cloud.aiplatform.metadata.context: google_cloud_aiplatform + google.cloud.aiplatform.metadata.execution: google_cloud_aiplatform + google.cloud.aiplatform.metadata.metadata: google_cloud_aiplatform + google.cloud.aiplatform.metadata.metadata_store: google_cloud_aiplatform + google.cloud.aiplatform.metadata.resource: google_cloud_aiplatform + google.cloud.aiplatform.model_evaluation: google_cloud_aiplatform + google.cloud.aiplatform.model_evaluation.__init__: google_cloud_aiplatform + google.cloud.aiplatform.model_evaluation.model_evaluation: google_cloud_aiplatform + google.cloud.aiplatform.models: google_cloud_aiplatform + google.cloud.aiplatform.pipeline_jobs: google_cloud_aiplatform + google.cloud.aiplatform.schema: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.__init__: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.plugins.tf_profiler.profile_uploader: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.tensorboard_resource: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.uploader: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.uploader_main: google_cloud_aiplatform + google.cloud.aiplatform.tensorboard.uploader_utils: google_cloud_aiplatform + google.cloud.aiplatform.training_jobs: google_cloud_aiplatform + google.cloud.aiplatform.training_utils: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.__init__: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.__init__: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.cloud_profiler_utils: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.initializer: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.plugins.base_plugin: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tensorboard_api: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tf_profiler: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.webserver: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.cloud_profiler.wsgi_types: google_cloud_aiplatform + google.cloud.aiplatform.training_utils.environment_variables: google_cloud_aiplatform + google.cloud.aiplatform.utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.__init__: google_cloud_aiplatform + google.cloud.aiplatform.utils.column_transformations_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.console_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.enhanced_library: google_cloud_aiplatform + google.cloud.aiplatform.utils.enhanced_library.__init__: google_cloud_aiplatform + google.cloud.aiplatform.utils.enhanced_library._decorators: google_cloud_aiplatform + google.cloud.aiplatform.utils.enhanced_library.value_converter: google_cloud_aiplatform + google.cloud.aiplatform.utils.featurestore_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.gcs_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.pipeline_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.resource_manager_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.source_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.tensorboard_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.worker_spec_utils: google_cloud_aiplatform + google.cloud.aiplatform.utils.yaml_utils: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_regression: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_tables: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.export_evaluated_data_items_config: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_regression: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.time_series_forecasting: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_forecasting: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_object_detection: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_segmentation: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_tables: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_extraction: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_sentiment: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_time_series_forecasting: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_action_recognition: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_classification: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_object_tracking: google_cloud_aiplatform + google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.export_evaluated_data_items_config: google_cloud_aiplatform + google.cloud.aiplatform.version: google_cloud_aiplatform + google.cloud.aiplatform_v1: google_cloud_aiplatform + google.cloud.aiplatform_v1.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1.types: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.accelerator_type: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.annotation: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.annotation_spec: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.artifact: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.batch_prediction_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.completion_stats: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.context: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.custom_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.data_item: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.data_labeling_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.dataset: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.dataset_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.deployed_index_ref: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.deployed_model_ref: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.encryption_spec: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.endpoint: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.entity_type: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.env_var: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.event: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.execution: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.explanation: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.explanation_metadata: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.feature: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.feature_monitoring_stats: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.feature_selector: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.featurestore: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.featurestore_monitoring: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.featurestore_online_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.featurestore_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.hyperparameter_tuning_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.index: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.index_endpoint: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.index_endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.index_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.io: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.job_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.job_state: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.lineage_subgraph: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.machine_resources: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.manual_batch_tuning_parameters: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.metadata_schema: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.metadata_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.metadata_store: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.migratable_resource: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.migration_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model_deployment_monitoring_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model_evaluation: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model_evaluation_slice: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model_monitoring: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.model_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.operation: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.pipeline_job: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.pipeline_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.pipeline_state: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.prediction_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.specialist_pool: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.specialist_pool_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.study: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard_data: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard_experiment: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard_run: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard_service: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.tensorboard_time_series: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.training_pipeline: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.types: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.unmanaged_container_model: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.user_action_reference: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.value: google_cloud_aiplatform + google.cloud.aiplatform_v1.types.vizier_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.async_client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.client: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.pagers: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.transports: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.transports.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.transports.base: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.__init__: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.accelerator_type: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.annotation: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.annotation_spec: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.artifact: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.batch_prediction_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.completion_stats: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.context: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.custom_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.data_item: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.data_labeling_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.dataset: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.dataset_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.deployed_index_ref: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.deployed_model_ref: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.encryption_spec: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.endpoint: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.entity_type: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.env_var: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.event: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.execution: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.explanation: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.explanation_metadata: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.feature: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.feature_monitoring_stats: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.feature_selector: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.featurestore: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.featurestore_monitoring: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.featurestore_online_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.featurestore_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.hyperparameter_tuning_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.index: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.index_endpoint: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.index_endpoint_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.index_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.io: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.job_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.job_state: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.lineage_subgraph: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.machine_resources: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.manual_batch_tuning_parameters: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.metadata_schema: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.metadata_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.metadata_store: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.migratable_resource: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.migration_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model_deployment_monitoring_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model_evaluation: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model_evaluation_slice: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model_monitoring: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.model_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.operation: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.pipeline_job: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.pipeline_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.pipeline_state: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.prediction_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.specialist_pool: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.specialist_pool_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.study: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard_data: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard_experiment: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard_run: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard_service: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.tensorboard_time_series: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.training_pipeline: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.types: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.unmanaged_container_model: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.user_action_reference: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.value: google_cloud_aiplatform + google.cloud.aiplatform_v1beta1.types.vizier_service: google_cloud_aiplatform + google.cloud.bigquery: google_cloud_bigquery + google.cloud.bigquery.__init__: google_cloud_bigquery + google.cloud.bigquery._helpers: google_cloud_bigquery + google.cloud.bigquery._http: google_cloud_bigquery + google.cloud.bigquery._pandas_helpers: google_cloud_bigquery + google.cloud.bigquery._tqdm_helpers: google_cloud_bigquery + google.cloud.bigquery.client: google_cloud_bigquery + google.cloud.bigquery.dataset: google_cloud_bigquery + google.cloud.bigquery.dbapi: google_cloud_bigquery + google.cloud.bigquery.dbapi.__init__: google_cloud_bigquery + google.cloud.bigquery.dbapi._helpers: google_cloud_bigquery + google.cloud.bigquery.dbapi.connection: google_cloud_bigquery + google.cloud.bigquery.dbapi.cursor: google_cloud_bigquery + google.cloud.bigquery.dbapi.exceptions: google_cloud_bigquery + google.cloud.bigquery.dbapi.types: google_cloud_bigquery + google.cloud.bigquery.encryption_configuration: google_cloud_bigquery + google.cloud.bigquery.enums: google_cloud_bigquery + google.cloud.bigquery.exceptions: google_cloud_bigquery + google.cloud.bigquery.external_config: google_cloud_bigquery + google.cloud.bigquery.format_options: google_cloud_bigquery + google.cloud.bigquery.iam: google_cloud_bigquery + google.cloud.bigquery.job: google_cloud_bigquery + google.cloud.bigquery.job.__init__: google_cloud_bigquery + google.cloud.bigquery.job.base: google_cloud_bigquery + google.cloud.bigquery.job.copy_: google_cloud_bigquery + google.cloud.bigquery.job.extract: google_cloud_bigquery + google.cloud.bigquery.job.load: google_cloud_bigquery + google.cloud.bigquery.job.query: google_cloud_bigquery + google.cloud.bigquery.magics: google_cloud_bigquery + google.cloud.bigquery.magics.__init__: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser.__init__: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser.exceptions: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser.lexer: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser.parser: google_cloud_bigquery + google.cloud.bigquery.magics.line_arg_parser.visitors: google_cloud_bigquery + google.cloud.bigquery.magics.magics: google_cloud_bigquery + google.cloud.bigquery.model: google_cloud_bigquery + google.cloud.bigquery.opentelemetry_tracing: google_cloud_bigquery + google.cloud.bigquery.query: google_cloud_bigquery + google.cloud.bigquery.retry: google_cloud_bigquery + google.cloud.bigquery.routine: google_cloud_bigquery + google.cloud.bigquery.routine.__init__: google_cloud_bigquery + google.cloud.bigquery.routine.routine: google_cloud_bigquery + google.cloud.bigquery.schema: google_cloud_bigquery + google.cloud.bigquery.table: google_cloud_bigquery + google.cloud.bigquery.version: google_cloud_bigquery + google.cloud.bigquery_v2: google_cloud_bigquery + google.cloud.bigquery_v2.__init__: google_cloud_bigquery + google.cloud.bigquery_v2.types: google_cloud_bigquery + google.cloud.bigquery_v2.types.__init__: google_cloud_bigquery + google.cloud.bigquery_v2.types.encryption_config: google_cloud_bigquery + google.cloud.bigquery_v2.types.model: google_cloud_bigquery + google.cloud.bigquery_v2.types.model_reference: google_cloud_bigquery + google.cloud.bigquery_v2.types.standard_sql: google_cloud_bigquery + google.cloud.bigquery_v2.types.table_reference: google_cloud_bigquery + google.cloud.client: google_cloud_core + google.cloud.client.__init__: google_cloud_core + google.cloud.environment_vars: google_cloud_core + google.cloud.environment_vars.__init__: google_cloud_core + google.cloud.exceptions: google_cloud_core + google.cloud.exceptions.__init__: google_cloud_core + google.cloud.extended_operations_pb2: googleapis_common_protos + google.cloud.location.locations_pb2: googleapis_common_protos + google.cloud.obsolete: google_cloud_core + google.cloud.obsolete.__init__: google_cloud_core + google.cloud.operation: google_cloud_core + google.cloud.operation.__init__: google_cloud_core + google.cloud.resourcemanager: google_cloud_resource_manager + google.cloud.resourcemanager.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3: google_cloud_resource_manager + google.cloud.resourcemanager_v3.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.folders.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.organizations.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.projects.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.async_client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.client: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.pagers: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.transports: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.transports.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.transports.base: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.transports.grpc: google_cloud_resource_manager + google.cloud.resourcemanager_v3.services.tag_values.transports.grpc_asyncio: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.__init__: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.folders: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.organizations: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.projects: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.tag_bindings: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.tag_keys: google_cloud_resource_manager + google.cloud.resourcemanager_v3.types.tag_values: google_cloud_resource_manager + google.cloud.storage: google_cloud_storage + google.cloud.storage.__init__: google_cloud_storage + google.cloud.storage._helpers: google_cloud_storage + google.cloud.storage._http: google_cloud_storage + google.cloud.storage._signing: google_cloud_storage + google.cloud.storage.acl: google_cloud_storage + google.cloud.storage.batch: google_cloud_storage + google.cloud.storage.blob: google_cloud_storage + google.cloud.storage.bucket: google_cloud_storage + google.cloud.storage.client: google_cloud_storage + google.cloud.storage.constants: google_cloud_storage + google.cloud.storage.fileio: google_cloud_storage + google.cloud.storage.hmac_key: google_cloud_storage + google.cloud.storage.iam: google_cloud_storage + google.cloud.storage.notification: google_cloud_storage + google.cloud.storage.retry: google_cloud_storage + google.cloud.storage.version: google_cloud_storage + google.cloud.version: google_cloud_core + google.gapic.metadata: googleapis_common_protos + google.gapic.metadata.__init__: googleapis_common_protos + google.gapic.metadata.gapic_metadata_pb2: googleapis_common_protos + google.iam.v1: grpc_google_iam_v1 + google.iam.v1.__init__: grpc_google_iam_v1 + google.iam.v1.iam_policy_pb2: grpc_google_iam_v1 + google.iam.v1.iam_policy_pb2_grpc: grpc_google_iam_v1 + google.iam.v1.logging: grpc_google_iam_v1 + google.iam.v1.logging.__init__: grpc_google_iam_v1 + google.iam.v1.logging.audit_data_pb2: grpc_google_iam_v1 + google.iam.v1.options_pb2: grpc_google_iam_v1 + google.iam.v1.options_pb2_grpc: grpc_google_iam_v1 + google.iam.v1.policy_pb2: grpc_google_iam_v1 + google.iam.v1.policy_pb2_grpc: grpc_google_iam_v1 + google.logging.type: googleapis_common_protos + google.logging.type.__init__: googleapis_common_protos + google.logging.type.http_request_pb2: googleapis_common_protos + google.logging.type.log_severity_pb2: googleapis_common_protos + google.longrunning: googleapis_common_protos + google.longrunning.__init__: googleapis_common_protos + google.longrunning.operations_grpc: googleapis_common_protos + google.longrunning.operations_grpc_pb2: googleapis_common_protos + google.longrunning.operations_pb2: googleapis_common_protos + google.longrunning.operations_pb2_grpc: googleapis_common_protos + google.longrunning.operations_proto: googleapis_common_protos + google.longrunning.operations_proto_pb2: googleapis_common_protos + google.oauth2: google_auth + google.oauth2.__init__: google_auth + google.oauth2._client: google_auth + google.oauth2._client_async: google_auth + google.oauth2._credentials_async: google_auth + google.oauth2._id_token_async: google_auth + google.oauth2._reauth_async: google_auth + google.oauth2._service_account_async: google_auth + google.oauth2.challenges: google_auth + google.oauth2.credentials: google_auth + google.oauth2.id_token: google_auth + google.oauth2.reauth: google_auth + google.oauth2.service_account: google_auth + google.oauth2.sts: google_auth + google.oauth2.utils: google_auth + google.protobuf: protobuf + google.protobuf.__init__: protobuf + google.protobuf.any_pb2: protobuf + google.protobuf.api_pb2: protobuf + google.protobuf.compiler: protobuf + google.protobuf.compiler.__init__: protobuf + google.protobuf.compiler.plugin_pb2: protobuf + google.protobuf.descriptor: protobuf + google.protobuf.descriptor_database: protobuf + google.protobuf.descriptor_pb2: protobuf + google.protobuf.descriptor_pool: protobuf + google.protobuf.duration_pb2: protobuf + google.protobuf.empty_pb2: protobuf + google.protobuf.field_mask_pb2: protobuf + google.protobuf.internal: protobuf + google.protobuf.internal.__init__: protobuf + google.protobuf.internal._api_implementation: protobuf + google.protobuf.internal.api_implementation: protobuf + google.protobuf.internal.builder: protobuf + google.protobuf.internal.containers: protobuf + google.protobuf.internal.decoder: protobuf + google.protobuf.internal.encoder: protobuf + google.protobuf.internal.enum_type_wrapper: protobuf + google.protobuf.internal.extension_dict: protobuf + google.protobuf.internal.message_listener: protobuf + google.protobuf.internal.python_message: protobuf + google.protobuf.internal.type_checkers: protobuf + google.protobuf.internal.well_known_types: protobuf + google.protobuf.internal.wire_format: protobuf + google.protobuf.json_format: protobuf + google.protobuf.message: protobuf + google.protobuf.message_factory: protobuf + google.protobuf.proto_builder: protobuf + google.protobuf.pyext: protobuf + google.protobuf.pyext.__init__: protobuf + google.protobuf.pyext._message: protobuf + google.protobuf.pyext.cpp_message: protobuf + google.protobuf.reflection: protobuf + google.protobuf.service: protobuf + google.protobuf.service_reflection: protobuf + google.protobuf.source_context_pb2: protobuf + google.protobuf.struct_pb2: protobuf + google.protobuf.symbol_database: protobuf + google.protobuf.text_encoding: protobuf + google.protobuf.text_format: protobuf + google.protobuf.timestamp_pb2: protobuf + google.protobuf.type_pb2: protobuf + google.protobuf.util: protobuf + google.protobuf.util.__init__: protobuf + google.protobuf.util.json_format_pb2: protobuf + google.protobuf.util.json_format_proto3_pb2: protobuf + google.protobuf.wrappers_pb2: protobuf + google.resumable_media: google_resumable_media + google.resumable_media.__init__: google_resumable_media + google.resumable_media._download: google_resumable_media + google.resumable_media._helpers: google_resumable_media + google.resumable_media._upload: google_resumable_media + google.resumable_media.common: google_resumable_media + google.resumable_media.requests: google_resumable_media + google.resumable_media.requests.__init__: google_resumable_media + google.resumable_media.requests._request_helpers: google_resumable_media + google.resumable_media.requests.download: google_resumable_media + google.resumable_media.requests.upload: google_resumable_media + google.rpc: googleapis_common_protos + google.rpc.__init__: googleapis_common_protos + google.rpc.code_pb2: googleapis_common_protos + google.rpc.context: googleapis_common_protos + google.rpc.context.__init__: googleapis_common_protos + google.rpc.context.attribute_context_pb2: googleapis_common_protos + google.rpc.error_details_pb2: googleapis_common_protos + google.rpc.status_pb2: googleapis_common_protos + google.type: googleapis_common_protos + google.type.__init__: googleapis_common_protos + google.type.calendar_period_pb2: googleapis_common_protos + google.type.color_pb2: googleapis_common_protos + google.type.date_pb2: googleapis_common_protos + google.type.datetime_pb2: googleapis_common_protos + google.type.dayofweek_pb2: googleapis_common_protos + google.type.decimal_pb2: googleapis_common_protos + google.type.expr_pb2: googleapis_common_protos + google.type.fraction_pb2: googleapis_common_protos + google.type.interval_pb2: googleapis_common_protos + google.type.latlng_pb2: googleapis_common_protos + google.type.localized_text_pb2: googleapis_common_protos + google.type.money_pb2: googleapis_common_protos + google.type.month_pb2: googleapis_common_protos + google.type.phone_number_pb2: googleapis_common_protos + google.type.postal_address_pb2: googleapis_common_protos + google.type.quaternion_pb2: googleapis_common_protos + google.type.timeofday_pb2: googleapis_common_protos + google_crc32c: google_crc32c + google_crc32c.__config__: google_crc32c + google_crc32c.__init__: google_crc32c + google_crc32c._checksum: google_crc32c + google_crc32c._crc32c: google_crc32c + google_crc32c.cext: google_crc32c + google_crc32c.libs.libcrc32c-672e1704: google_crc32c + google_crc32c.python: google_crc32c + grpc: grpcio + grpc.__init__: grpcio + grpc._auth: grpcio + grpc._channel: grpcio + grpc._common: grpcio + grpc._compression: grpcio + grpc._cython: grpcio + grpc._cython.__init__: grpcio + grpc._cython._cygrpc: grpcio + grpc._cython._cygrpc.__init__: grpcio + grpc._cython.cygrpc: grpcio + grpc._grpcio_metadata: grpcio + grpc._interceptor: grpcio + grpc._plugin_wrapping: grpcio + grpc._runtime_protos: grpcio + grpc._server: grpcio + grpc._simple_stubs: grpcio + grpc._utilities: grpcio + grpc.aio: grpcio + grpc.aio.__init__: grpcio + grpc.aio._base_call: grpcio + grpc.aio._base_channel: grpcio + grpc.aio._base_server: grpcio + grpc.aio._call: grpcio + grpc.aio._channel: grpcio + grpc.aio._interceptor: grpcio + grpc.aio._metadata: grpcio + grpc.aio._server: grpcio + grpc.aio._typing: grpcio + grpc.aio._utils: grpcio + grpc.beta: grpcio + grpc.beta.__init__: grpcio + grpc.beta._client_adaptations: grpcio + grpc.beta._metadata: grpcio + grpc.beta._server_adaptations: grpcio + grpc.beta.implementations: grpcio + grpc.beta.interfaces: grpcio + grpc.beta.utilities: grpcio + grpc.experimental: grpcio + grpc.experimental.__init__: grpcio + grpc.experimental.aio: grpcio + grpc.experimental.aio.__init__: grpcio + grpc.experimental.gevent: grpcio + grpc.experimental.session_cache: grpcio + grpc.framework: grpcio + grpc.framework.__init__: grpcio + grpc.framework.common: grpcio + grpc.framework.common.__init__: grpcio + grpc.framework.common.cardinality: grpcio + grpc.framework.common.style: grpcio + grpc.framework.foundation: grpcio + grpc.framework.foundation.__init__: grpcio + grpc.framework.foundation.abandonment: grpcio + grpc.framework.foundation.callable_util: grpcio + grpc.framework.foundation.future: grpcio + grpc.framework.foundation.logging_pool: grpcio + grpc.framework.foundation.stream: grpcio + grpc.framework.foundation.stream_util: grpcio + grpc.framework.interfaces: grpcio + grpc.framework.interfaces.__init__: grpcio + grpc.framework.interfaces.base: grpcio + grpc.framework.interfaces.base.__init__: grpcio + grpc.framework.interfaces.base.base: grpcio + grpc.framework.interfaces.base.utilities: grpcio + grpc.framework.interfaces.face: grpcio + grpc.framework.interfaces.face.__init__: grpcio + grpc.framework.interfaces.face.face: grpcio + grpc.framework.interfaces.face.utilities: grpcio + grpc_status: grpcio_status + grpc_status.__init__: grpcio_status + grpc_status._async: grpcio_status + grpc_status._common: grpcio_status + grpc_status.rpc_status: grpcio_status + idna: idna + idna.__init__: idna + idna.codec: idna + idna.compat: idna + idna.core: idna + idna.idnadata: idna + idna.intranges: idna + idna.package_data: idna + idna.uts46data: idna + packaging: packaging + packaging.__about__: packaging + packaging.__init__: packaging + packaging._manylinux: packaging + packaging._musllinux: packaging + packaging._structures: packaging + packaging.markers: packaging + packaging.requirements: packaging + packaging.specifiers: packaging + packaging.tags: packaging + packaging.utils: packaging + packaging.version: packaging + proto: proto_plus + proto.__init__: proto_plus + proto._file_info: proto_plus + proto._package_info: proto_plus + proto.datetime_helpers: proto_plus + proto.enums: proto_plus + proto.fields: proto_plus + proto.marshal: proto_plus + proto.marshal.__init__: proto_plus + proto.marshal.collections: proto_plus + proto.marshal.collections.__init__: proto_plus + proto.marshal.collections.maps: proto_plus + proto.marshal.collections.repeated: proto_plus + proto.marshal.compat: proto_plus + proto.marshal.marshal: proto_plus + proto.marshal.rules: proto_plus + proto.marshal.rules.__init__: proto_plus + proto.marshal.rules.bytes: proto_plus + proto.marshal.rules.dates: proto_plus + proto.marshal.rules.enums: proto_plus + proto.marshal.rules.message: proto_plus + proto.marshal.rules.stringy_numbers: proto_plus + proto.marshal.rules.struct: proto_plus + proto.marshal.rules.wrappers: proto_plus + proto.message: proto_plus + proto.modules: proto_plus + proto.primitives: proto_plus + proto.utils: proto_plus + pyasn1: pyasn1 + pyasn1.__init__: pyasn1 + pyasn1.codec: pyasn1 + pyasn1.codec.__init__: pyasn1 + pyasn1.codec.ber: pyasn1 + pyasn1.codec.ber.__init__: pyasn1 + pyasn1.codec.ber.decoder: pyasn1 + pyasn1.codec.ber.encoder: pyasn1 + pyasn1.codec.ber.eoo: pyasn1 + pyasn1.codec.cer: pyasn1 + pyasn1.codec.cer.__init__: pyasn1 + pyasn1.codec.cer.decoder: pyasn1 + pyasn1.codec.cer.encoder: pyasn1 + pyasn1.codec.der: pyasn1 + pyasn1.codec.der.__init__: pyasn1 + pyasn1.codec.der.decoder: pyasn1 + pyasn1.codec.der.encoder: pyasn1 + pyasn1.codec.native: pyasn1 + pyasn1.codec.native.__init__: pyasn1 + pyasn1.codec.native.decoder: pyasn1 + pyasn1.codec.native.encoder: pyasn1 + pyasn1.compat: pyasn1 + pyasn1.compat.__init__: pyasn1 + pyasn1.compat.binary: pyasn1 + pyasn1.compat.calling: pyasn1 + pyasn1.compat.dateandtime: pyasn1 + pyasn1.compat.integer: pyasn1 + pyasn1.compat.octets: pyasn1 + pyasn1.compat.string: pyasn1 + pyasn1.debug: pyasn1 + pyasn1.error: pyasn1 + pyasn1.type: pyasn1 + pyasn1.type.__init__: pyasn1 + pyasn1.type.base: pyasn1 + pyasn1.type.char: pyasn1 + pyasn1.type.constraint: pyasn1 + pyasn1.type.error: pyasn1 + pyasn1.type.namedtype: pyasn1 + pyasn1.type.namedval: pyasn1 + pyasn1.type.opentype: pyasn1 + pyasn1.type.tag: pyasn1 + pyasn1.type.tagmap: pyasn1 + pyasn1.type.univ: pyasn1 + pyasn1.type.useful: pyasn1 + pyasn1_modules: pyasn1_modules + pyasn1_modules.__init__: pyasn1_modules + pyasn1_modules.pem: pyasn1_modules + pyasn1_modules.rfc1155: pyasn1_modules + pyasn1_modules.rfc1157: pyasn1_modules + pyasn1_modules.rfc1901: pyasn1_modules + pyasn1_modules.rfc1902: pyasn1_modules + pyasn1_modules.rfc1905: pyasn1_modules + pyasn1_modules.rfc2251: pyasn1_modules + pyasn1_modules.rfc2314: pyasn1_modules + pyasn1_modules.rfc2315: pyasn1_modules + pyasn1_modules.rfc2437: pyasn1_modules + pyasn1_modules.rfc2459: pyasn1_modules + pyasn1_modules.rfc2511: pyasn1_modules + pyasn1_modules.rfc2560: pyasn1_modules + pyasn1_modules.rfc2631: pyasn1_modules + pyasn1_modules.rfc2634: pyasn1_modules + pyasn1_modules.rfc2985: pyasn1_modules + pyasn1_modules.rfc2986: pyasn1_modules + pyasn1_modules.rfc3114: pyasn1_modules + pyasn1_modules.rfc3161: pyasn1_modules + pyasn1_modules.rfc3274: pyasn1_modules + pyasn1_modules.rfc3279: pyasn1_modules + pyasn1_modules.rfc3280: pyasn1_modules + pyasn1_modules.rfc3281: pyasn1_modules + pyasn1_modules.rfc3412: pyasn1_modules + pyasn1_modules.rfc3414: pyasn1_modules + pyasn1_modules.rfc3447: pyasn1_modules + pyasn1_modules.rfc3560: pyasn1_modules + pyasn1_modules.rfc3565: pyasn1_modules + pyasn1_modules.rfc3709: pyasn1_modules + pyasn1_modules.rfc3770: pyasn1_modules + pyasn1_modules.rfc3779: pyasn1_modules + pyasn1_modules.rfc3852: pyasn1_modules + pyasn1_modules.rfc4043: pyasn1_modules + pyasn1_modules.rfc4055: pyasn1_modules + pyasn1_modules.rfc4073: pyasn1_modules + pyasn1_modules.rfc4108: pyasn1_modules + pyasn1_modules.rfc4210: pyasn1_modules + pyasn1_modules.rfc4211: pyasn1_modules + pyasn1_modules.rfc4334: pyasn1_modules + pyasn1_modules.rfc4985: pyasn1_modules + pyasn1_modules.rfc5035: pyasn1_modules + pyasn1_modules.rfc5083: pyasn1_modules + pyasn1_modules.rfc5084: pyasn1_modules + pyasn1_modules.rfc5208: pyasn1_modules + pyasn1_modules.rfc5280: pyasn1_modules + pyasn1_modules.rfc5480: pyasn1_modules + pyasn1_modules.rfc5649: pyasn1_modules + pyasn1_modules.rfc5652: pyasn1_modules + pyasn1_modules.rfc5751: pyasn1_modules + pyasn1_modules.rfc5755: pyasn1_modules + pyasn1_modules.rfc5913: pyasn1_modules + pyasn1_modules.rfc5914: pyasn1_modules + pyasn1_modules.rfc5915: pyasn1_modules + pyasn1_modules.rfc5916: pyasn1_modules + pyasn1_modules.rfc5917: pyasn1_modules + pyasn1_modules.rfc5924: pyasn1_modules + pyasn1_modules.rfc5934: pyasn1_modules + pyasn1_modules.rfc5940: pyasn1_modules + pyasn1_modules.rfc5958: pyasn1_modules + pyasn1_modules.rfc5990: pyasn1_modules + pyasn1_modules.rfc6010: pyasn1_modules + pyasn1_modules.rfc6019: pyasn1_modules + pyasn1_modules.rfc6031: pyasn1_modules + pyasn1_modules.rfc6032: pyasn1_modules + pyasn1_modules.rfc6120: pyasn1_modules + pyasn1_modules.rfc6170: pyasn1_modules + pyasn1_modules.rfc6187: pyasn1_modules + pyasn1_modules.rfc6210: pyasn1_modules + pyasn1_modules.rfc6211: pyasn1_modules + pyasn1_modules.rfc6402: pyasn1_modules + pyasn1_modules.rfc6402-1: pyasn1_modules + pyasn1_modules.rfc6482: pyasn1_modules + pyasn1_modules.rfc6486: pyasn1_modules + pyasn1_modules.rfc6487: pyasn1_modules + pyasn1_modules.rfc6664: pyasn1_modules + pyasn1_modules.rfc6955: pyasn1_modules + pyasn1_modules.rfc6960: pyasn1_modules + pyasn1_modules.rfc7030: pyasn1_modules + pyasn1_modules.rfc7191: pyasn1_modules + pyasn1_modules.rfc7229: pyasn1_modules + pyasn1_modules.rfc7292: pyasn1_modules + pyasn1_modules.rfc7296: pyasn1_modules + pyasn1_modules.rfc7508: pyasn1_modules + pyasn1_modules.rfc7585: pyasn1_modules + pyasn1_modules.rfc7633: pyasn1_modules + pyasn1_modules.rfc7773: pyasn1_modules + pyasn1_modules.rfc7894: pyasn1_modules + pyasn1_modules.rfc7894-1: pyasn1_modules + pyasn1_modules.rfc7906: pyasn1_modules + pyasn1_modules.rfc7914: pyasn1_modules + pyasn1_modules.rfc8017: pyasn1_modules + pyasn1_modules.rfc8018: pyasn1_modules + pyasn1_modules.rfc8103: pyasn1_modules + pyasn1_modules.rfc8209: pyasn1_modules + pyasn1_modules.rfc8226: pyasn1_modules + pyasn1_modules.rfc8358: pyasn1_modules + pyasn1_modules.rfc8360: pyasn1_modules + pyasn1_modules.rfc8398: pyasn1_modules + pyasn1_modules.rfc8410: pyasn1_modules + pyasn1_modules.rfc8418: pyasn1_modules + pyasn1_modules.rfc8419: pyasn1_modules + pyasn1_modules.rfc8479: pyasn1_modules + pyasn1_modules.rfc8494: pyasn1_modules + pyasn1_modules.rfc8520: pyasn1_modules + pyasn1_modules.rfc8619: pyasn1_modules + pyasn1_modules.rfc8649: pyasn1_modules + pyparsing: pyparsing + pyparsing.__init__: pyparsing + pyparsing.actions: pyparsing + pyparsing.common: pyparsing + pyparsing.core: pyparsing + pyparsing.diagram: pyparsing + pyparsing.diagram.__init__: pyparsing + pyparsing.exceptions: pyparsing + pyparsing.helpers: pyparsing + pyparsing.results: pyparsing + pyparsing.testing: pyparsing + pyparsing.unicode: pyparsing + pyparsing.util: pyparsing + requests: requests + requests.__init__: requests + requests.__version__: requests + requests._internal_utils: requests + requests.adapters: requests + requests.api: requests + requests.auth: requests + requests.certs: requests + requests.compat: requests + requests.cookies: requests + requests.exceptions: requests + requests.help: requests + requests.hooks: requests + requests.models: requests + requests.packages: requests + requests.sessions: requests + requests.status_codes: requests + requests.structures: requests + requests.utils: requests + rsa: rsa + rsa.__init__: rsa + rsa._compat: rsa + rsa.asn1: rsa + rsa.cli: rsa + rsa.common: rsa + rsa.core: rsa + rsa.key: rsa + rsa.parallel: rsa + rsa.pem: rsa + rsa.pkcs1: rsa + rsa.pkcs1_v2: rsa + rsa.prime: rsa + rsa.randnum: rsa + rsa.transform: rsa + rsa.util: rsa + samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_sync: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_async: google_cloud_resource_manager + samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_sync: google_cloud_resource_manager + scripts.fixup_resourcemanager_v3_keywords: google_cloud_resource_manager + scripts.readme-gen.readme_gen: google_cloud_resource_manager + six: six + tests: google_cloud_resource_manager + tests.__init__: google_cloud_resource_manager + tests.unit: google_cloud_resource_manager + tests.unit.__init__: google_cloud_resource_manager + tests.unit.gapic: google_cloud_resource_manager + tests.unit.gapic.__init__: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.__init__: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_folders: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_organizations: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_projects: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_tag_bindings: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_tag_keys: google_cloud_resource_manager + tests.unit.gapic.resourcemanager_v3.test_tag_values: google_cloud_resource_manager + urllib3: urllib3 + urllib3.__init__: urllib3 + urllib3._collections: urllib3 + urllib3._version: urllib3 + urllib3.connection: urllib3 + urllib3.connectionpool: urllib3 + urllib3.contrib: urllib3 + urllib3.contrib.__init__: urllib3 + urllib3.contrib._appengine_environ: urllib3 + urllib3.contrib._securetransport: urllib3 + urllib3.contrib._securetransport.__init__: urllib3 + urllib3.contrib._securetransport.bindings: urllib3 + urllib3.contrib._securetransport.low_level: urllib3 + urllib3.contrib.appengine: urllib3 + urllib3.contrib.ntlmpool: urllib3 + urllib3.contrib.pyopenssl: urllib3 + urllib3.contrib.securetransport: urllib3 + urllib3.contrib.socks: urllib3 + urllib3.exceptions: urllib3 + urllib3.fields: urllib3 + urllib3.filepost: urllib3 + urllib3.packages: urllib3 + urllib3.packages.__init__: urllib3 + urllib3.packages.backports: urllib3 + urllib3.packages.backports.__init__: urllib3 + urllib3.packages.backports.makefile: urllib3 + urllib3.packages.six: urllib3 + urllib3.poolmanager: urllib3 + urllib3.request: urllib3 + urllib3.response: urllib3 + urllib3.util: urllib3 + urllib3.util.__init__: urllib3 + urllib3.util.connection: urllib3 + urllib3.util.proxy: urllib3 + urllib3.util.queue: urllib3 + urllib3.util.request: urllib3 + urllib3.util.response: urllib3 + urllib3.util.retry: urllib3 + urllib3.util.ssl_: urllib3 + urllib3.util.ssl_match_hostname: urllib3 + urllib3.util.ssltransport: urllib3 + urllib3.util.timeout: urllib3 + urllib3.util.url: urllib3 + urllib3.util.wait: urllib3 + pip_repository: + name: gazelle_python_test +integrity: 32e38932043eca090a64ca741758d8e4a5817c2cd7dc821fc927914c32fb3114 diff --git a/gazelle/python/testdata/with_third_party_requirements_from_imports/test.yaml b/gazelle/python/testdata/with_third_party_requirements_from_imports/test.yaml new file mode 100644 index 0000000000..fcea77710f --- /dev/null +++ b/gazelle/python/testdata/with_third_party_requirements_from_imports/test.yaml @@ -0,0 +1,15 @@ +# Copyright 2023 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- diff --git a/gazelle/pythonconfig/BUILD.bazel b/gazelle/pythonconfig/BUILD.bazel index cff75d9ee3..d0f1690d94 100644 --- a/gazelle/pythonconfig/BUILD.bazel +++ b/gazelle/pythonconfig/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "pythonconfig", @@ -9,8 +9,20 @@ go_library( importpath = "github.com/bazelbuild/rules_python/gazelle/pythonconfig", visibility = ["//visibility:public"], deps = [ - "//gazelle/manifest", + "//manifest", "@bazel_gazelle//label:go_default_library", "@com_github_emirpasic_gods//lists/singlylinkedlist", ], ) + +go_test( + name = "pythonconfig_test", + srcs = ["pythonconfig_test.go"], + deps = [":pythonconfig"], +) + +filegroup( + name = "distribution", + srcs = glob(["**"]), + visibility = ["//:__pkg__"], +) diff --git a/gazelle/pythonconfig/pythonconfig.go b/gazelle/pythonconfig/pythonconfig.go index 7e65fd98d7..c7cd7c1a28 100644 --- a/gazelle/pythonconfig/pythonconfig.go +++ b/gazelle/pythonconfig/pythonconfig.go @@ -1,3 +1,17 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package pythonconfig import ( @@ -76,6 +90,14 @@ var defaultIgnoreFiles = map[string]struct{}{ "setup.py": {}, } +func SanitizeDistribution(distributionName string) string { + sanitizedDistribution := strings.ToLower(distributionName) + sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, "-", "_") + sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, ".", "_") + + return sanitizedDistribution +} + // Configs is an extension of map[string]*Config. It provides finding methods // on top of the mapping. type Configs map[string]*Config @@ -204,18 +226,17 @@ func (c *Config) FindThirdPartyDependency(modName string) (string, bool) { } else if gazelleManifest.PipRepository != nil { distributionRepositoryName = gazelleManifest.PipRepository.Name } - sanitizedDistribution := strings.ToLower(distributionName) - sanitizedDistribution = strings.ReplaceAll(sanitizedDistribution, "-", "_") - var lbl label.Label - if gazelleManifest.PipRepository != nil && gazelleManifest.PipRepository.Incremental { - // @_//:pkg - distributionRepositoryName = distributionRepositoryName + "_" + sanitizedDistribution - lbl = label.New(distributionRepositoryName, "", "pkg") - } else { - // @//pypi__ - distributionPackage := "pypi__" + sanitizedDistribution - lbl = label.New(distributionRepositoryName, distributionPackage, distributionPackage) + sanitizedDistribution := SanitizeDistribution(distributionName) + + if gazelleManifest.PipRepository != nil && gazelleManifest.PipRepository.UsePipRepositoryAliases { + // @// + lbl := label.New(distributionRepositoryName, sanitizedDistribution, sanitizedDistribution) + return lbl.String(), true } + + // @_//:pkg + distributionRepositoryName = distributionRepositoryName + "_" + sanitizedDistribution + lbl := label.New(distributionRepositoryName, "", "pkg") return lbl.String(), true } } diff --git a/gazelle/pythonconfig/pythonconfig_test.go b/gazelle/pythonconfig/pythonconfig_test.go new file mode 100644 index 0000000000..1512eb97ae --- /dev/null +++ b/gazelle/pythonconfig/pythonconfig_test.go @@ -0,0 +1,28 @@ +package pythonconfig + +import ( + "testing" + + "github.com/bazelbuild/rules_python/gazelle/pythonconfig" +) + +func TestDistributionSanitizing(t *testing.T) { + tests := map[string]struct { + input string + want string + }{ + "upper case": {input: "DistWithUpperCase", want: "distwithuppercase"}, + "dashes": {input: "dist-with-dashes", want: "dist_with_dashes"}, + "dots": {input: "dist.with.dots", want: "dist_with_dots"}, + "mixed": {input: "To-be.sanitized", want: "to_be_sanitized"}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + got := pythonconfig.SanitizeDistribution(tc.input) + if tc.want != got { + t.Fatalf("expected %q, got %q", tc.want, got) + } + }) + } +} diff --git a/gazelle/pythonconfig/types.go b/gazelle/pythonconfig/types.go index bdb535bf6e..d83d35f015 100644 --- a/gazelle/pythonconfig/types.go +++ b/gazelle/pythonconfig/types.go @@ -1,3 +1,17 @@ +// Copyright 2023 The Bazel Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package pythonconfig import ( From 71eb8dd4cb34b5c53c2334a102c1af64d8d517c5 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 05:33:31 +0000 Subject: [PATCH 5/8] Re-expose gazelle go module --- gazelle/BUILD.bazel | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gazelle/BUILD.bazel b/gazelle/BUILD.bazel index 6016145516..df2bdcb259 100644 --- a/gazelle/BUILD.bazel +++ b/gazelle/BUILD.bazel @@ -1,5 +1,40 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@bazel_gazelle//:def.bzl", "gazelle") +go_library( + name = "gazelle_mod", + srcs = [ + "configure.go", + "fix.go", + "generate.go", + "kinds.go", + "language.go", + "parser.go", + "resolve.go", + "std_modules.go", + "target.go", + ], + importpath = "github.com/bazelbuild/rules_python/gazelle", + visibility = ["//visibility:public"], + deps = [ + "//manifest", + "//pythonconfig", + "@bazel_gazelle//config:go_default_library", + "@bazel_gazelle//label:go_default_library", + "@bazel_gazelle//language:go_default_library", + "@bazel_gazelle//repo:go_default_library", + "@bazel_gazelle//resolve:go_default_library", + "@bazel_gazelle//rule:go_default_library", + "@com_github_bazelbuild_buildtools//build:go_default_library", + "@com_github_bmatcuk_doublestar//:doublestar", + "@com_github_emirpasic_gods//lists/singlylinkedlist", + "@com_github_emirpasic_gods//sets/treeset", + "@com_github_emirpasic_gods//utils", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", + ], + ) + + # Gazelle configuration options. # See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel # gazelle:prefix github.com/bazelbuild/rules_python/gazelle From 05efdfcc303ceaafdde73f2c4f70e49aa74c3660 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 05:42:25 +0000 Subject: [PATCH 6/8] Remove gazelle go binary, it was all a mistake --- gazelle/BUILD.bazel | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/gazelle/BUILD.bazel b/gazelle/BUILD.bazel index df2bdcb259..f2b9c8a9fd 100644 --- a/gazelle/BUILD.bazel +++ b/gazelle/BUILD.bazel @@ -1,39 +1,5 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") load("@bazel_gazelle//:def.bzl", "gazelle") -go_library( - name = "gazelle_mod", - srcs = [ - "configure.go", - "fix.go", - "generate.go", - "kinds.go", - "language.go", - "parser.go", - "resolve.go", - "std_modules.go", - "target.go", - ], - importpath = "github.com/bazelbuild/rules_python/gazelle", - visibility = ["//visibility:public"], - deps = [ - "//manifest", - "//pythonconfig", - "@bazel_gazelle//config:go_default_library", - "@bazel_gazelle//label:go_default_library", - "@bazel_gazelle//language:go_default_library", - "@bazel_gazelle//repo:go_default_library", - "@bazel_gazelle//resolve:go_default_library", - "@bazel_gazelle//rule:go_default_library", - "@com_github_bazelbuild_buildtools//build:go_default_library", - "@com_github_bmatcuk_doublestar//:doublestar", - "@com_github_emirpasic_gods//lists/singlylinkedlist", - "@com_github_emirpasic_gods//sets/treeset", - "@com_github_emirpasic_gods//utils", - "@io_bazel_rules_go//go/tools/bazel:go_default_library", - ], - ) - # Gazelle configuration options. # See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel From b07ae7cb7fcaab9fcef5236bac3a2a72630478f2 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Thu, 25 May 2023 05:48:14 +0000 Subject: [PATCH 7/8] More aggressive cherry picking --- gazelle/BUILD.bazel | 1 - gazelle/configure.go | 164 -- gazelle/fix.go | 13 - gazelle/generate.go | 438 ----- gazelle/kinds.go | 88 - gazelle/language.go | 18 - gazelle/manifest/test/run.sh | 8 - gazelle/parse.py | 92 - gazelle/parser.go | 254 --- gazelle/python_test.go | 211 --- gazelle/resolve.go | 301 --- gazelle/std_modules.go | 98 - gazelle/std_modules.py | 39 - gazelle/target.go | 157 -- gazelle/testdata/README.md | 12 - .../dependency_resolution_order/BUILD.in | 1 - .../dependency_resolution_order/BUILD.out | 14 - .../dependency_resolution_order/README.md | 7 - .../dependency_resolution_order/WORKSPACE | 1 - .../dependency_resolution_order/__init__.py | 10 - .../dependency_resolution_order/bar/BUILD.in | 0 .../dependency_resolution_order/bar/BUILD.out | 8 - .../bar/__init__.py | 3 - .../dependency_resolution_order/baz/BUILD.in | 0 .../dependency_resolution_order/baz/BUILD.out | 8 - .../baz/__init__.py | 3 - .../dependency_resolution_order/foo/BUILD.in | 0 .../dependency_resolution_order/foo/BUILD.out | 8 - .../foo/__init__.py | 3 - .../gazelle_python.yaml | 4 - .../somewhere/bar/BUILD.in | 0 .../somewhere/bar/BUILD.out | 8 - .../somewhere/bar/__init__.py | 3 - .../dependency_resolution_order/test.yaml | 1 - .../BUILD.in | 1 - .../BUILD.out | 9 - .../README.md | 3 - .../WORKSPACE | 1 - .../__init__.py | 3 - .../test.yaml | 3 - gazelle/testdata/dont_rename_target/BUILD.in | 5 - gazelle/testdata/dont_rename_target/BUILD.out | 7 - gazelle/testdata/dont_rename_target/README.md | 4 - gazelle/testdata/dont_rename_target/WORKSPACE | 1 - .../testdata/dont_rename_target/__init__.py | 0 gazelle/testdata/dont_rename_target/test.yaml | 1 - .../BUILD.in | 0 .../BUILD.out | 11 - .../README.md | 4 - .../WORKSPACE | 1 - .../__init__.py | 1 - .../gazelle_python.yaml | 4 - .../rest_framework.py | 3 - .../test.yaml | 1 - .../first_party_dependencies/BUILD.in | 0 .../first_party_dependencies/BUILD.out | 0 .../first_party_dependencies/README.md | 11 - .../first_party_dependencies/WORKSPACE | 1 - .../first_party_dependencies/one/BUILD.in | 1 - .../first_party_dependencies/one/BUILD.out | 15 - .../first_party_dependencies/one/__main__.py | 12 - .../first_party_dependencies/one/bar/BUILD.in | 10 - .../one/bar/BUILD.out | 11 - .../one/bar/__init__.py | 5 - .../one/bar/baz/BUILD.in | 10 - .../one/bar/baz/BUILD.out | 11 - .../one/bar/baz/__init__.py | 5 - .../first_party_dependencies/one/foo/BUILD.in | 11 - .../one/foo/BUILD.out | 12 - .../one/foo/__init__.py | 5 - .../first_party_dependencies/test.yaml | 1 - .../first_party_dependencies/three/BUILD.in | 1 - .../first_party_dependencies/three/BUILD.out | 14 - .../three/__init__.py | 10 - .../first_party_dependencies/two/BUILD.in | 1 - .../first_party_dependencies/two/BUILD.out | 10 - .../first_party_dependencies/two/__init__.py | 6 - .../BUILD.in | 1 - .../BUILD.out | 25 - .../README.md | 9 - .../WORKSPACE | 1 - .../__main__.py | 11 - .../baz.py | 2 - .../foo.py | 2 - .../foo/BUILD.in | 0 .../foo/BUILD.out | 12 - .../foo/__init__.py | 1 - .../foo/bar.py | 7 - .../one/BUILD.in | 0 .../one/BUILD.out | 11 - .../one/__init__.py | 1 - .../one/two.py | 2 - .../test.yaml | 1 - .../undiscoverable/BUILD.in | 1 - .../undiscoverable/BUILD.out | 1 - .../package1/subpackage1/BUILD.in | 12 - .../package1/subpackage1/BUILD.out | 12 - .../package1/subpackage1/__init__.py | 1 - .../package1/subpackage1/module1.py | 2 - gazelle/testdata/from_imports/BUILD.in | 1 - gazelle/testdata/from_imports/BUILD.out | 1 - gazelle/testdata/from_imports/README.md | 7 - gazelle/testdata/from_imports/WORKSPACE | 1 - gazelle/testdata/from_imports/foo/BUILD.in | 1 - gazelle/testdata/from_imports/foo/BUILD.out | 8 - gazelle/testdata/from_imports/foo/__init__.py | 1 - .../testdata/from_imports/foo/bar/BUILD.in | 21 - .../testdata/from_imports/foo/bar/BUILD.out | 21 - .../testdata/from_imports/foo/bar/__init__.py | 1 - gazelle/testdata/from_imports/foo/bar/baz.py | 1 - .../testdata/from_imports/gazelle_python.yaml | 5 - .../from_imports/import_from_init_py/BUILD.in | 0 .../import_from_init_py/BUILD.out | 9 - .../import_from_init_py/__init__.py | 2 - .../import_from_multiple/BUILD.in | 0 .../import_from_multiple/BUILD.out | 12 - .../import_from_multiple/__init__.py | 2 - .../from_imports/import_nested_file/BUILD.in | 0 .../from_imports/import_nested_file/BUILD.out | 9 - .../import_nested_file/__init__.py | 2 - .../import_nested_module/BUILD.in | 0 .../import_nested_module/BUILD.out | 9 - .../import_nested_module/__init__.py | 2 - .../from_imports/import_nested_var/BUILD.in | 0 .../from_imports/import_nested_var/BUILD.out | 9 - .../import_nested_var/__init__.py | 2 - .../import_top_level_var/BUILD.in | 0 .../import_top_level_var/BUILD.out | 9 - .../import_top_level_var/__init__.py | 2 - .../testdata/from_imports/std_module/BUILD.in | 0 .../from_imports/std_module/BUILD.out | 8 - .../from_imports/std_module/__init__.py | 3 - gazelle/testdata/from_imports/test.yaml | 1 - .../generated_test_entrypoint/BUILD.in | 10 - .../generated_test_entrypoint/BUILD.out | 24 - .../generated_test_entrypoint/README.md | 4 - .../generated_test_entrypoint/WORKSPACE | 1 - .../generated_test_entrypoint/__init__.py | 3 - .../testdata/generated_test_entrypoint/foo.py | 2 - .../generated_test_entrypoint/test.yaml | 1 - .../ignored_invalid_imported_module/BUILD.in | 0 .../ignored_invalid_imported_module/BUILD.out | 8 - .../ignored_invalid_imported_module/README.md | 3 - .../ignored_invalid_imported_module/WORKSPACE | 1 - .../__init__.py | 22 - .../gazelle_python.yaml | 4 - .../ignored_invalid_imported_module/test.yaml | 3 - .../testdata/invalid_imported_module/BUILD.in | 0 .../invalid_imported_module/BUILD.out | 0 .../invalid_imported_module/README.md | 3 - .../invalid_imported_module/WORKSPACE | 1 - .../invalid_imported_module/__init__.py | 8 - .../invalid_imported_module/test.yaml | 8 - gazelle/testdata/monorepo/BUILD.in | 1 - gazelle/testdata/monorepo/BUILD.out | 1 - gazelle/testdata/monorepo/README.md | 4 - gazelle/testdata/monorepo/WORKSPACE | 1 - .../testdata/monorepo/coarse_grained/BUILD.in | 12 - .../monorepo/coarse_grained/BUILD.out | 20 - .../monorepo/coarse_grained/__init__.py | 12 - .../coarse_grained/_boundary/BUILD.in | 1 - .../coarse_grained/_boundary/BUILD.out | 10 - .../coarse_grained/_boundary/README.md | 5 - .../coarse_grained/_boundary/__init__.py | 0 .../monorepo/coarse_grained/bar/__init__.py | 9 - .../coarse_grained/bar/baz/__init__.py | 5 - .../coarse_grained/bar/baz/first_excluded.py | 1 - .../monorepo/coarse_grained/bar/baz/hue.py | 1 - .../coarse_grained/bar/baz/second_excluded.py | 1 - .../monorepo/coarse_grained/foo/__init__.py | 5 - gazelle/testdata/monorepo/gazelle_python.yaml | 5 - gazelle/testdata/monorepo/one/BUILD.in | 2 - gazelle/testdata/monorepo/one/BUILD.out | 17 - gazelle/testdata/monorepo/one/__main__.py | 15 - gazelle/testdata/monorepo/one/bar/BUILD.in | 10 - gazelle/testdata/monorepo/one/bar/BUILD.out | 12 - gazelle/testdata/monorepo/one/bar/__init__.py | 9 - .../testdata/monorepo/one/bar/baz/BUILD.in | 10 - .../testdata/monorepo/one/bar/baz/BUILD.out | 11 - .../testdata/monorepo/one/bar/baz/__init__.py | 5 - gazelle/testdata/monorepo/one/foo/BUILD.in | 11 - gazelle/testdata/monorepo/one/foo/BUILD.out | 12 - gazelle/testdata/monorepo/one/foo/__init__.py | 5 - .../testdata/monorepo/one/gazelle_python.yaml | 4 - gazelle/testdata/monorepo/test.yaml | 1 - gazelle/testdata/monorepo/three/BUILD.in | 5 - gazelle/testdata/monorepo/three/BUILD.out | 21 - gazelle/testdata/monorepo/three/__init__.py | 16 - .../monorepo/three/gazelle_python.yaml | 6 - gazelle/testdata/monorepo/two/BUILD.in | 3 - gazelle/testdata/monorepo/two/BUILD.out | 15 - gazelle/testdata/monorepo/two/__init__.py | 8 - .../testdata/monorepo/two/gazelle_python.yaml | 4 - .../testdata/monorepo/wont_generate/BUILD.in | 0 .../testdata/monorepo/wont_generate/BUILD.out | 0 .../monorepo/wont_generate/__main__.py | 12 - .../monorepo/wont_generate/bar/BUILD.in | 0 .../monorepo/wont_generate/bar/BUILD.out | 0 .../monorepo/wont_generate/bar/__init__.py | 5 - .../monorepo/wont_generate/bar/baz/BUILD.in | 0 .../monorepo/wont_generate/bar/baz/BUILD.out | 0 .../wont_generate/bar/baz/__init__.py | 5 - .../monorepo/wont_generate/foo/BUILD.in | 0 .../monorepo/wont_generate/foo/BUILD.out | 0 .../monorepo/wont_generate/foo/__init__.py | 5 - gazelle/testdata/naming_convention/BUILD.in | 3 - gazelle/testdata/naming_convention/BUILD.out | 26 - gazelle/testdata/naming_convention/README.md | 4 - gazelle/testdata/naming_convention/WORKSPACE | 1 - .../testdata/naming_convention/__init__.py | 1 - .../testdata/naming_convention/__main__.py | 1 - .../testdata/naming_convention/__test__.py | 1 - .../naming_convention/dont_rename/BUILD.in | 7 - .../naming_convention/dont_rename/BUILD.out | 25 - .../naming_convention/dont_rename/__init__.py | 1 - .../naming_convention/dont_rename/__main__.py | 1 - .../naming_convention/dont_rename/__test__.py | 1 - .../resolve_conflict/BUILD.in | 5 - .../resolve_conflict/BUILD.out | 31 - .../resolve_conflict/__init__.py | 1 - .../resolve_conflict/__main__.py | 1 - .../resolve_conflict/__test__.py | 1 - gazelle/testdata/naming_convention/test.yaml | 1 - .../naming_convention_binary_fail/BUILD.in | 1 - .../naming_convention_binary_fail/BUILD.out | 1 - .../naming_convention_binary_fail/README.md | 4 - .../naming_convention_binary_fail/WORKSPACE | 1 - .../naming_convention_binary_fail/__main__.py | 1 - .../naming_convention_binary_fail/test.yaml | 7 - .../naming_convention_library_fail/BUILD.in | 1 - .../naming_convention_library_fail/BUILD.out | 1 - .../naming_convention_library_fail/README.md | 4 - .../naming_convention_library_fail/WORKSPACE | 1 - .../__init__.py | 1 - .../naming_convention_library_fail/test.yaml | 7 - .../naming_convention_test_fail/BUILD.in | 1 - .../naming_convention_test_fail/BUILD.out | 1 - .../naming_convention_test_fail/README.md | 4 - .../naming_convention_test_fail/WORKSPACE | 1 - .../naming_convention_test_fail/__test__.py | 1 - .../naming_convention_test_fail/test.yaml | 7 - .../BUILD.in | 2 - .../BUILD.out | 11 - .../README.md | 4 - .../WORKSPACE | 1 - .../__init__.py | 11 - .../gazelle_python.yaml | 4 - .../test.yaml | 1 - .../python_ignore_files_directive/BUILD.in | 1 - .../python_ignore_files_directive/BUILD.out | 9 - .../python_ignore_files_directive/README.md | 3 - .../python_ignore_files_directive/WORKSPACE | 1 - .../python_ignore_files_directive/__init__.py | 1 - .../bar/BUILD.in | 0 .../bar/BUILD.out | 8 - .../python_ignore_files_directive/bar/baz.py | 1 - .../bar/some_other.py | 1 - .../foo/BUILD.in | 1 - .../foo/BUILD.out | 1 - .../python_ignore_files_directive/foo/baz.py | 1 - .../python_ignore_files_directive/setup.py | 1 - .../some_other.py | 1 - .../python_ignore_files_directive/test.yaml | 1 - .../python_target_with_test_in_name/BUILD.in | 0 .../python_target_with_test_in_name/BUILD.out | 12 - .../python_target_with_test_in_name/README.md | 3 - .../python_target_with_test_in_name/WORKSPACE | 0 .../__init__.py | 1 - .../gazelle_python.yaml | 4 - .../not_a_real_test.py | 3 - .../python_target_with_test_in_name/test.yaml | 1 - .../test_not_a_real.py | 1 - gazelle/testdata/relative_imports/BUILD.in | 0 gazelle/testdata/relative_imports/BUILD.out | 21 - gazelle/testdata/relative_imports/README.md | 4 - gazelle/testdata/relative_imports/WORKSPACE | 1 - gazelle/testdata/relative_imports/__main__.py | 5 - .../relative_imports/package1/module1.py | 5 - .../relative_imports/package1/module2.py | 2 - .../relative_imports/package2/BUILD.in | 0 .../relative_imports/package2/BUILD.out | 13 - .../relative_imports/package2/__init__.py | 3 - .../relative_imports/package2/module3.py | 7 - .../relative_imports/package2/module4.py | 2 - .../package2/subpackage1/module5.py | 5 - gazelle/testdata/relative_imports/test.yaml | 1 - gazelle/testdata/simple_binary/BUILD.in | 0 gazelle/testdata/simple_binary/BUILD.out | 8 - gazelle/testdata/simple_binary/README.md | 3 - gazelle/testdata/simple_binary/WORKSPACE | 1 - gazelle/testdata/simple_binary/__main__.py | 1 - gazelle/testdata/simple_binary/test.yaml | 1 - .../simple_binary_with_library/BUILD.in | 18 - .../simple_binary_with_library/BUILD.out | 27 - .../simple_binary_with_library/README.md | 4 - .../simple_binary_with_library/WORKSPACE | 1 - .../simple_binary_with_library/__init__.py | 1 - .../simple_binary_with_library/__main__.py | 1 - .../simple_binary_with_library/bar.py | 1 - .../simple_binary_with_library/foo.py | 1 - .../simple_binary_with_library/test.yaml | 1 - gazelle/testdata/simple_library/BUILD.in | 0 gazelle/testdata/simple_library/BUILD.out | 7 - gazelle/testdata/simple_library/README.md | 3 - gazelle/testdata/simple_library/WORKSPACE | 1 - gazelle/testdata/simple_library/__init__.py | 1 - gazelle/testdata/simple_library/test.yaml | 1 - .../simple_library_without_init/BUILD.in | 0 .../simple_library_without_init/BUILD.out | 0 .../simple_library_without_init/README.md | 4 - .../simple_library_without_init/WORKSPACE | 1 - .../simple_library_without_init/foo/BUILD.in | 0 .../simple_library_without_init/foo/BUILD.out | 8 - .../simple_library_without_init/foo/foo.py | 1 - .../simple_library_without_init/test.yaml | 1 - gazelle/testdata/simple_test/BUILD.in | 6 - gazelle/testdata/simple_test/BUILD.out | 17 - gazelle/testdata/simple_test/README.md | 3 - gazelle/testdata/simple_test/WORKSPACE | 1 - gazelle/testdata/simple_test/__init__.py | 3 - gazelle/testdata/simple_test/__test__.py | 12 - gazelle/testdata/simple_test/foo.py | 2 - gazelle/testdata/simple_test/test.yaml | 3 - gazelle/testdata/subdir_sources/BUILD.in | 0 gazelle/testdata/subdir_sources/BUILD.out | 12 - gazelle/testdata/subdir_sources/README.md | 5 - gazelle/testdata/subdir_sources/WORKSPACE | 1 - gazelle/testdata/subdir_sources/__main__.py | 7 - gazelle/testdata/subdir_sources/foo/BUILD.in | 0 gazelle/testdata/subdir_sources/foo/BUILD.out | 13 - .../testdata/subdir_sources/foo/__init__.py | 1 - .../testdata/subdir_sources/foo/bar/bar.py | 1 - .../testdata/subdir_sources/foo/baz/baz.py | 1 - gazelle/testdata/subdir_sources/foo/foo.py | 3 - .../subdir_sources/foo/has_build/BUILD.in | 0 .../subdir_sources/foo/has_build/BUILD.out | 8 - .../foo/has_build/python/my_module.py | 1 - .../foo/has_build_bazel/BUILD.bazel.in | 0 .../foo/has_build_bazel/BUILD.bazel.out | 8 - .../foo/has_build_bazel/python/my_module.py | 1 - .../subdir_sources/foo/has_init/BUILD.in | 0 .../subdir_sources/foo/has_init/BUILD.out | 11 - .../subdir_sources/foo/has_init/__init__.py | 1 - .../foo/has_init/python/my_module.py | 1 - .../subdir_sources/foo/has_main/BUILD.in | 0 .../subdir_sources/foo/has_main/BUILD.out | 17 - .../subdir_sources/foo/has_main/__main__.py | 1 - .../foo/has_main/python/my_module.py | 1 - .../subdir_sources/foo/has_test/BUILD.in | 0 .../subdir_sources/foo/has_test/BUILD.out | 16 - .../subdir_sources/foo/has_test/__test__.py | 1 - .../foo/has_test/python/my_module.py | 1 - gazelle/testdata/subdir_sources/one/BUILD.in | 0 gazelle/testdata/subdir_sources/one/BUILD.out | 8 - .../testdata/subdir_sources/one/__init__.py | 1 - .../testdata/subdir_sources/one/two/BUILD.in | 0 .../testdata/subdir_sources/one/two/BUILD.out | 12 - .../subdir_sources/one/two/__init__.py | 3 - .../testdata/subdir_sources/one/two/three.py | 1 - gazelle/testdata/subdir_sources/test.yaml | 1 - .../with_nested_import_statements/BUILD.in | 0 .../with_nested_import_statements/BUILD.out | 8 - .../with_nested_import_statements/README.md | 4 - .../with_nested_import_statements/WORKSPACE | 1 - .../with_nested_import_statements/__init__.py | 11 - .../gazelle_python.yaml | 4 - .../with_nested_import_statements/test.yaml | 1 - .../testdata/with_std_requirements/BUILD.in | 0 .../testdata/with_std_requirements/BUILD.out | 7 - .../testdata/with_std_requirements/README.md | 4 - .../testdata/with_std_requirements/WORKSPACE | 1 - .../with_std_requirements/__init__.py | 5 - .../testdata/with_std_requirements/test.yaml | 1 - .../with_third_party_requirements/BUILD.in | 0 .../with_third_party_requirements/BUILD.out | 27 - .../with_third_party_requirements/README.md | 5 - .../with_third_party_requirements/WORKSPACE | 1 - .../with_third_party_requirements/__init__.py | 1 - .../with_third_party_requirements/__main__.py | 5 - .../with_third_party_requirements/bar.py | 11 - .../with_third_party_requirements/foo.py | 11 - .../gazelle_python.yaml | 7 - .../with_third_party_requirements/test.yaml | 1 - .../BUILD.in | 0 .../BUILD.out | 25 - .../README.md | 15 - .../WORKSPACE | 1 - .../__init__.py | 1 - .../__main__.py | 6 - .../bar.py | 6 - .../gazelle_python.yaml | 1665 ----------------- .../test.yaml | 1 - 392 files changed, 5330 deletions(-) delete mode 100644 gazelle/configure.go delete mode 100644 gazelle/fix.go delete mode 100644 gazelle/generate.go delete mode 100644 gazelle/kinds.go delete mode 100644 gazelle/language.go delete mode 100755 gazelle/manifest/test/run.sh delete mode 100644 gazelle/parse.py delete mode 100644 gazelle/parser.go delete mode 100644 gazelle/python_test.go delete mode 100644 gazelle/resolve.go delete mode 100644 gazelle/std_modules.go delete mode 100644 gazelle/std_modules.py delete mode 100644 gazelle/target.go delete mode 100644 gazelle/testdata/README.md delete mode 100644 gazelle/testdata/dependency_resolution_order/BUILD.in delete mode 100644 gazelle/testdata/dependency_resolution_order/BUILD.out delete mode 100644 gazelle/testdata/dependency_resolution_order/README.md delete mode 100644 gazelle/testdata/dependency_resolution_order/WORKSPACE delete mode 100644 gazelle/testdata/dependency_resolution_order/__init__.py delete mode 100644 gazelle/testdata/dependency_resolution_order/bar/BUILD.in delete mode 100644 gazelle/testdata/dependency_resolution_order/bar/BUILD.out delete mode 100644 gazelle/testdata/dependency_resolution_order/bar/__init__.py delete mode 100644 gazelle/testdata/dependency_resolution_order/baz/BUILD.in delete mode 100644 gazelle/testdata/dependency_resolution_order/baz/BUILD.out delete mode 100644 gazelle/testdata/dependency_resolution_order/baz/__init__.py delete mode 100644 gazelle/testdata/dependency_resolution_order/foo/BUILD.in delete mode 100644 gazelle/testdata/dependency_resolution_order/foo/BUILD.out delete mode 100644 gazelle/testdata/dependency_resolution_order/foo/__init__.py delete mode 100644 gazelle/testdata/dependency_resolution_order/gazelle_python.yaml delete mode 100644 gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.in delete mode 100644 gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.out delete mode 100644 gazelle/testdata/dependency_resolution_order/somewhere/bar/__init__.py delete mode 100644 gazelle/testdata/dependency_resolution_order/test.yaml delete mode 100644 gazelle/testdata/disable_import_statements_validation/BUILD.in delete mode 100644 gazelle/testdata/disable_import_statements_validation/BUILD.out delete mode 100644 gazelle/testdata/disable_import_statements_validation/README.md delete mode 100644 gazelle/testdata/disable_import_statements_validation/WORKSPACE delete mode 100644 gazelle/testdata/disable_import_statements_validation/__init__.py delete mode 100644 gazelle/testdata/disable_import_statements_validation/test.yaml delete mode 100644 gazelle/testdata/dont_rename_target/BUILD.in delete mode 100644 gazelle/testdata/dont_rename_target/BUILD.out delete mode 100644 gazelle/testdata/dont_rename_target/README.md delete mode 100644 gazelle/testdata/dont_rename_target/WORKSPACE delete mode 100644 gazelle/testdata/dont_rename_target/__init__.py delete mode 100644 gazelle/testdata/dont_rename_target/test.yaml delete mode 100644 gazelle/testdata/file_name_matches_import_statement/BUILD.in delete mode 100644 gazelle/testdata/file_name_matches_import_statement/BUILD.out delete mode 100644 gazelle/testdata/file_name_matches_import_statement/README.md delete mode 100644 gazelle/testdata/file_name_matches_import_statement/WORKSPACE delete mode 100644 gazelle/testdata/file_name_matches_import_statement/__init__.py delete mode 100644 gazelle/testdata/file_name_matches_import_statement/gazelle_python.yaml delete mode 100644 gazelle/testdata/file_name_matches_import_statement/rest_framework.py delete mode 100644 gazelle/testdata/file_name_matches_import_statement/test.yaml delete mode 100644 gazelle/testdata/first_party_dependencies/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/README.md delete mode 100644 gazelle/testdata/first_party_dependencies/WORKSPACE delete mode 100644 gazelle/testdata/first_party_dependencies/one/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/one/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/one/__main__.py delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/__init__.py delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/one/bar/baz/__init__.py delete mode 100644 gazelle/testdata/first_party_dependencies/one/foo/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/one/foo/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/one/foo/__init__.py delete mode 100644 gazelle/testdata/first_party_dependencies/test.yaml delete mode 100644 gazelle/testdata/first_party_dependencies/three/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/three/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/three/__init__.py delete mode 100644 gazelle/testdata/first_party_dependencies/two/BUILD.in delete mode 100644 gazelle/testdata/first_party_dependencies/two/BUILD.out delete mode 100644 gazelle/testdata/first_party_dependencies/two/__init__.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/BUILD.in delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/BUILD.out delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/README.md delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/WORKSPACE delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/__main__.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/baz.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/foo.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.in delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.out delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/foo/__init__.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/foo/bar.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.in delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.out delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/one/__init__.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/one/two.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/test.yaml delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py delete mode 100644 gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py delete mode 100644 gazelle/testdata/from_imports/BUILD.in delete mode 100644 gazelle/testdata/from_imports/BUILD.out delete mode 100644 gazelle/testdata/from_imports/README.md delete mode 100644 gazelle/testdata/from_imports/WORKSPACE delete mode 100644 gazelle/testdata/from_imports/foo/BUILD.in delete mode 100644 gazelle/testdata/from_imports/foo/BUILD.out delete mode 100644 gazelle/testdata/from_imports/foo/__init__.py delete mode 100644 gazelle/testdata/from_imports/foo/bar/BUILD.in delete mode 100644 gazelle/testdata/from_imports/foo/bar/BUILD.out delete mode 100644 gazelle/testdata/from_imports/foo/bar/__init__.py delete mode 100644 gazelle/testdata/from_imports/foo/bar/baz.py delete mode 100644 gazelle/testdata/from_imports/gazelle_python.yaml delete mode 100644 gazelle/testdata/from_imports/import_from_init_py/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_from_init_py/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_from_init_py/__init__.py delete mode 100644 gazelle/testdata/from_imports/import_from_multiple/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_from_multiple/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_from_multiple/__init__.py delete mode 100644 gazelle/testdata/from_imports/import_nested_file/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_nested_file/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_nested_file/__init__.py delete mode 100644 gazelle/testdata/from_imports/import_nested_module/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_nested_module/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_nested_module/__init__.py delete mode 100644 gazelle/testdata/from_imports/import_nested_var/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_nested_var/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_nested_var/__init__.py delete mode 100644 gazelle/testdata/from_imports/import_top_level_var/BUILD.in delete mode 100644 gazelle/testdata/from_imports/import_top_level_var/BUILD.out delete mode 100644 gazelle/testdata/from_imports/import_top_level_var/__init__.py delete mode 100644 gazelle/testdata/from_imports/std_module/BUILD.in delete mode 100644 gazelle/testdata/from_imports/std_module/BUILD.out delete mode 100644 gazelle/testdata/from_imports/std_module/__init__.py delete mode 100644 gazelle/testdata/from_imports/test.yaml delete mode 100644 gazelle/testdata/generated_test_entrypoint/BUILD.in delete mode 100644 gazelle/testdata/generated_test_entrypoint/BUILD.out delete mode 100644 gazelle/testdata/generated_test_entrypoint/README.md delete mode 100644 gazelle/testdata/generated_test_entrypoint/WORKSPACE delete mode 100644 gazelle/testdata/generated_test_entrypoint/__init__.py delete mode 100644 gazelle/testdata/generated_test_entrypoint/foo.py delete mode 100644 gazelle/testdata/generated_test_entrypoint/test.yaml delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/BUILD.in delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/BUILD.out delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/README.md delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/WORKSPACE delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/__init__.py delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/gazelle_python.yaml delete mode 100644 gazelle/testdata/ignored_invalid_imported_module/test.yaml delete mode 100644 gazelle/testdata/invalid_imported_module/BUILD.in delete mode 100644 gazelle/testdata/invalid_imported_module/BUILD.out delete mode 100644 gazelle/testdata/invalid_imported_module/README.md delete mode 100644 gazelle/testdata/invalid_imported_module/WORKSPACE delete mode 100644 gazelle/testdata/invalid_imported_module/__init__.py delete mode 100644 gazelle/testdata/invalid_imported_module/test.yaml delete mode 100644 gazelle/testdata/monorepo/BUILD.in delete mode 100644 gazelle/testdata/monorepo/BUILD.out delete mode 100644 gazelle/testdata/monorepo/README.md delete mode 100644 gazelle/testdata/monorepo/WORKSPACE delete mode 100644 gazelle/testdata/monorepo/coarse_grained/BUILD.in delete mode 100644 gazelle/testdata/monorepo/coarse_grained/BUILD.out delete mode 100644 gazelle/testdata/monorepo/coarse_grained/__init__.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.in delete mode 100644 gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.out delete mode 100644 gazelle/testdata/monorepo/coarse_grained/_boundary/README.md delete mode 100644 gazelle/testdata/monorepo/coarse_grained/_boundary/__init__.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/bar/__init__.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/bar/baz/__init__.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/bar/baz/hue.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py delete mode 100644 gazelle/testdata/monorepo/coarse_grained/foo/__init__.py delete mode 100644 gazelle/testdata/monorepo/gazelle_python.yaml delete mode 100644 gazelle/testdata/monorepo/one/BUILD.in delete mode 100644 gazelle/testdata/monorepo/one/BUILD.out delete mode 100644 gazelle/testdata/monorepo/one/__main__.py delete mode 100644 gazelle/testdata/monorepo/one/bar/BUILD.in delete mode 100644 gazelle/testdata/monorepo/one/bar/BUILD.out delete mode 100644 gazelle/testdata/monorepo/one/bar/__init__.py delete mode 100644 gazelle/testdata/monorepo/one/bar/baz/BUILD.in delete mode 100644 gazelle/testdata/monorepo/one/bar/baz/BUILD.out delete mode 100644 gazelle/testdata/monorepo/one/bar/baz/__init__.py delete mode 100644 gazelle/testdata/monorepo/one/foo/BUILD.in delete mode 100644 gazelle/testdata/monorepo/one/foo/BUILD.out delete mode 100644 gazelle/testdata/monorepo/one/foo/__init__.py delete mode 100644 gazelle/testdata/monorepo/one/gazelle_python.yaml delete mode 100644 gazelle/testdata/monorepo/test.yaml delete mode 100644 gazelle/testdata/monorepo/three/BUILD.in delete mode 100644 gazelle/testdata/monorepo/three/BUILD.out delete mode 100644 gazelle/testdata/monorepo/three/__init__.py delete mode 100644 gazelle/testdata/monorepo/three/gazelle_python.yaml delete mode 100644 gazelle/testdata/monorepo/two/BUILD.in delete mode 100644 gazelle/testdata/monorepo/two/BUILD.out delete mode 100644 gazelle/testdata/monorepo/two/__init__.py delete mode 100644 gazelle/testdata/monorepo/two/gazelle_python.yaml delete mode 100644 gazelle/testdata/monorepo/wont_generate/BUILD.in delete mode 100644 gazelle/testdata/monorepo/wont_generate/BUILD.out delete mode 100644 gazelle/testdata/monorepo/wont_generate/__main__.py delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/BUILD.in delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/BUILD.out delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/__init__.py delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.in delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.out delete mode 100644 gazelle/testdata/monorepo/wont_generate/bar/baz/__init__.py delete mode 100644 gazelle/testdata/monorepo/wont_generate/foo/BUILD.in delete mode 100644 gazelle/testdata/monorepo/wont_generate/foo/BUILD.out delete mode 100644 gazelle/testdata/monorepo/wont_generate/foo/__init__.py delete mode 100644 gazelle/testdata/naming_convention/BUILD.in delete mode 100644 gazelle/testdata/naming_convention/BUILD.out delete mode 100644 gazelle/testdata/naming_convention/README.md delete mode 100644 gazelle/testdata/naming_convention/WORKSPACE delete mode 100644 gazelle/testdata/naming_convention/__init__.py delete mode 100644 gazelle/testdata/naming_convention/__main__.py delete mode 100644 gazelle/testdata/naming_convention/__test__.py delete mode 100644 gazelle/testdata/naming_convention/dont_rename/BUILD.in delete mode 100644 gazelle/testdata/naming_convention/dont_rename/BUILD.out delete mode 100644 gazelle/testdata/naming_convention/dont_rename/__init__.py delete mode 100644 gazelle/testdata/naming_convention/dont_rename/__main__.py delete mode 100644 gazelle/testdata/naming_convention/dont_rename/__test__.py delete mode 100644 gazelle/testdata/naming_convention/resolve_conflict/BUILD.in delete mode 100644 gazelle/testdata/naming_convention/resolve_conflict/BUILD.out delete mode 100644 gazelle/testdata/naming_convention/resolve_conflict/__init__.py delete mode 100644 gazelle/testdata/naming_convention/resolve_conflict/__main__.py delete mode 100644 gazelle/testdata/naming_convention/resolve_conflict/__test__.py delete mode 100644 gazelle/testdata/naming_convention/test.yaml delete mode 100644 gazelle/testdata/naming_convention_binary_fail/BUILD.in delete mode 100644 gazelle/testdata/naming_convention_binary_fail/BUILD.out delete mode 100644 gazelle/testdata/naming_convention_binary_fail/README.md delete mode 100644 gazelle/testdata/naming_convention_binary_fail/WORKSPACE delete mode 100644 gazelle/testdata/naming_convention_binary_fail/__main__.py delete mode 100644 gazelle/testdata/naming_convention_binary_fail/test.yaml delete mode 100644 gazelle/testdata/naming_convention_library_fail/BUILD.in delete mode 100644 gazelle/testdata/naming_convention_library_fail/BUILD.out delete mode 100644 gazelle/testdata/naming_convention_library_fail/README.md delete mode 100644 gazelle/testdata/naming_convention_library_fail/WORKSPACE delete mode 100644 gazelle/testdata/naming_convention_library_fail/__init__.py delete mode 100644 gazelle/testdata/naming_convention_library_fail/test.yaml delete mode 100644 gazelle/testdata/naming_convention_test_fail/BUILD.in delete mode 100644 gazelle/testdata/naming_convention_test_fail/BUILD.out delete mode 100644 gazelle/testdata/naming_convention_test_fail/README.md delete mode 100644 gazelle/testdata/naming_convention_test_fail/WORKSPACE delete mode 100644 gazelle/testdata/naming_convention_test_fail/__test__.py delete mode 100644 gazelle/testdata/naming_convention_test_fail/test.yaml delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/BUILD.in delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/BUILD.out delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/README.md delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/WORKSPACE delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/__init__.py delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/gazelle_python.yaml delete mode 100644 gazelle/testdata/python_ignore_dependencies_directive/test.yaml delete mode 100644 gazelle/testdata/python_ignore_files_directive/BUILD.in delete mode 100644 gazelle/testdata/python_ignore_files_directive/BUILD.out delete mode 100644 gazelle/testdata/python_ignore_files_directive/README.md delete mode 100644 gazelle/testdata/python_ignore_files_directive/WORKSPACE delete mode 100644 gazelle/testdata/python_ignore_files_directive/__init__.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/bar/BUILD.in delete mode 100644 gazelle/testdata/python_ignore_files_directive/bar/BUILD.out delete mode 100644 gazelle/testdata/python_ignore_files_directive/bar/baz.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/bar/some_other.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/foo/BUILD.in delete mode 100644 gazelle/testdata/python_ignore_files_directive/foo/BUILD.out delete mode 100644 gazelle/testdata/python_ignore_files_directive/foo/baz.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/setup.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/some_other.py delete mode 100644 gazelle/testdata/python_ignore_files_directive/test.yaml delete mode 100644 gazelle/testdata/python_target_with_test_in_name/BUILD.in delete mode 100644 gazelle/testdata/python_target_with_test_in_name/BUILD.out delete mode 100644 gazelle/testdata/python_target_with_test_in_name/README.md delete mode 100644 gazelle/testdata/python_target_with_test_in_name/WORKSPACE delete mode 100644 gazelle/testdata/python_target_with_test_in_name/__init__.py delete mode 100644 gazelle/testdata/python_target_with_test_in_name/gazelle_python.yaml delete mode 100644 gazelle/testdata/python_target_with_test_in_name/not_a_real_test.py delete mode 100644 gazelle/testdata/python_target_with_test_in_name/test.yaml delete mode 100644 gazelle/testdata/python_target_with_test_in_name/test_not_a_real.py delete mode 100644 gazelle/testdata/relative_imports/BUILD.in delete mode 100644 gazelle/testdata/relative_imports/BUILD.out delete mode 100644 gazelle/testdata/relative_imports/README.md delete mode 100644 gazelle/testdata/relative_imports/WORKSPACE delete mode 100644 gazelle/testdata/relative_imports/__main__.py delete mode 100644 gazelle/testdata/relative_imports/package1/module1.py delete mode 100644 gazelle/testdata/relative_imports/package1/module2.py delete mode 100644 gazelle/testdata/relative_imports/package2/BUILD.in delete mode 100644 gazelle/testdata/relative_imports/package2/BUILD.out delete mode 100644 gazelle/testdata/relative_imports/package2/__init__.py delete mode 100644 gazelle/testdata/relative_imports/package2/module3.py delete mode 100644 gazelle/testdata/relative_imports/package2/module4.py delete mode 100644 gazelle/testdata/relative_imports/package2/subpackage1/module5.py delete mode 100644 gazelle/testdata/relative_imports/test.yaml delete mode 100644 gazelle/testdata/simple_binary/BUILD.in delete mode 100644 gazelle/testdata/simple_binary/BUILD.out delete mode 100644 gazelle/testdata/simple_binary/README.md delete mode 100644 gazelle/testdata/simple_binary/WORKSPACE delete mode 100644 gazelle/testdata/simple_binary/__main__.py delete mode 100644 gazelle/testdata/simple_binary/test.yaml delete mode 100644 gazelle/testdata/simple_binary_with_library/BUILD.in delete mode 100644 gazelle/testdata/simple_binary_with_library/BUILD.out delete mode 100644 gazelle/testdata/simple_binary_with_library/README.md delete mode 100644 gazelle/testdata/simple_binary_with_library/WORKSPACE delete mode 100644 gazelle/testdata/simple_binary_with_library/__init__.py delete mode 100644 gazelle/testdata/simple_binary_with_library/__main__.py delete mode 100644 gazelle/testdata/simple_binary_with_library/bar.py delete mode 100644 gazelle/testdata/simple_binary_with_library/foo.py delete mode 100644 gazelle/testdata/simple_binary_with_library/test.yaml delete mode 100644 gazelle/testdata/simple_library/BUILD.in delete mode 100644 gazelle/testdata/simple_library/BUILD.out delete mode 100644 gazelle/testdata/simple_library/README.md delete mode 100644 gazelle/testdata/simple_library/WORKSPACE delete mode 100644 gazelle/testdata/simple_library/__init__.py delete mode 100644 gazelle/testdata/simple_library/test.yaml delete mode 100644 gazelle/testdata/simple_library_without_init/BUILD.in delete mode 100644 gazelle/testdata/simple_library_without_init/BUILD.out delete mode 100644 gazelle/testdata/simple_library_without_init/README.md delete mode 100644 gazelle/testdata/simple_library_without_init/WORKSPACE delete mode 100644 gazelle/testdata/simple_library_without_init/foo/BUILD.in delete mode 100644 gazelle/testdata/simple_library_without_init/foo/BUILD.out delete mode 100644 gazelle/testdata/simple_library_without_init/foo/foo.py delete mode 100644 gazelle/testdata/simple_library_without_init/test.yaml delete mode 100644 gazelle/testdata/simple_test/BUILD.in delete mode 100644 gazelle/testdata/simple_test/BUILD.out delete mode 100644 gazelle/testdata/simple_test/README.md delete mode 100644 gazelle/testdata/simple_test/WORKSPACE delete mode 100644 gazelle/testdata/simple_test/__init__.py delete mode 100644 gazelle/testdata/simple_test/__test__.py delete mode 100644 gazelle/testdata/simple_test/foo.py delete mode 100644 gazelle/testdata/simple_test/test.yaml delete mode 100644 gazelle/testdata/subdir_sources/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/README.md delete mode 100644 gazelle/testdata/subdir_sources/WORKSPACE delete mode 100644 gazelle/testdata/subdir_sources/__main__.py delete mode 100644 gazelle/testdata/subdir_sources/foo/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/foo/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/foo/__init__.py delete mode 100644 gazelle/testdata/subdir_sources/foo/bar/bar.py delete mode 100644 gazelle/testdata/subdir_sources/foo/baz/baz.py delete mode 100644 gazelle/testdata/subdir_sources/foo/foo.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build/python/my_module.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.out delete mode 100644 gazelle/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_init/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/foo/has_init/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/foo/has_init/__init__.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_init/python/my_module.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_main/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/foo/has_main/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/foo/has_main/__main__.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_main/python/my_module.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_test/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/foo/has_test/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/foo/has_test/__test__.py delete mode 100644 gazelle/testdata/subdir_sources/foo/has_test/python/my_module.py delete mode 100644 gazelle/testdata/subdir_sources/one/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/one/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/one/__init__.py delete mode 100644 gazelle/testdata/subdir_sources/one/two/BUILD.in delete mode 100644 gazelle/testdata/subdir_sources/one/two/BUILD.out delete mode 100644 gazelle/testdata/subdir_sources/one/two/__init__.py delete mode 100644 gazelle/testdata/subdir_sources/one/two/three.py delete mode 100644 gazelle/testdata/subdir_sources/test.yaml delete mode 100644 gazelle/testdata/with_nested_import_statements/BUILD.in delete mode 100644 gazelle/testdata/with_nested_import_statements/BUILD.out delete mode 100644 gazelle/testdata/with_nested_import_statements/README.md delete mode 100644 gazelle/testdata/with_nested_import_statements/WORKSPACE delete mode 100644 gazelle/testdata/with_nested_import_statements/__init__.py delete mode 100644 gazelle/testdata/with_nested_import_statements/gazelle_python.yaml delete mode 100644 gazelle/testdata/with_nested_import_statements/test.yaml delete mode 100644 gazelle/testdata/with_std_requirements/BUILD.in delete mode 100644 gazelle/testdata/with_std_requirements/BUILD.out delete mode 100644 gazelle/testdata/with_std_requirements/README.md delete mode 100644 gazelle/testdata/with_std_requirements/WORKSPACE delete mode 100644 gazelle/testdata/with_std_requirements/__init__.py delete mode 100644 gazelle/testdata/with_std_requirements/test.yaml delete mode 100644 gazelle/testdata/with_third_party_requirements/BUILD.in delete mode 100644 gazelle/testdata/with_third_party_requirements/BUILD.out delete mode 100644 gazelle/testdata/with_third_party_requirements/README.md delete mode 100644 gazelle/testdata/with_third_party_requirements/WORKSPACE delete mode 100644 gazelle/testdata/with_third_party_requirements/__init__.py delete mode 100644 gazelle/testdata/with_third_party_requirements/__main__.py delete mode 100644 gazelle/testdata/with_third_party_requirements/bar.py delete mode 100644 gazelle/testdata/with_third_party_requirements/foo.py delete mode 100644 gazelle/testdata/with_third_party_requirements/gazelle_python.yaml delete mode 100644 gazelle/testdata/with_third_party_requirements/test.yaml delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/BUILD.in delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/BUILD.out delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/README.md delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/WORKSPACE delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/__init__.py delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/__main__.py delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/bar.py delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml delete mode 100644 gazelle/testdata/with_third_party_requirements_from_imports/test.yaml diff --git a/gazelle/BUILD.bazel b/gazelle/BUILD.bazel index f2b9c8a9fd..6016145516 100644 --- a/gazelle/BUILD.bazel +++ b/gazelle/BUILD.bazel @@ -1,6 +1,5 @@ load("@bazel_gazelle//:def.bzl", "gazelle") - # Gazelle configuration options. # See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel # gazelle:prefix github.com/bazelbuild/rules_python/gazelle diff --git a/gazelle/configure.go b/gazelle/configure.go deleted file mode 100644 index 8e71110d0a..0000000000 --- a/gazelle/configure.go +++ /dev/null @@ -1,164 +0,0 @@ -package python - -import ( - "flag" - "fmt" - "log" - "os" - "path/filepath" - "strconv" - "strings" - - "github.com/bazelbuild/bazel-gazelle/config" - "github.com/bazelbuild/bazel-gazelle/rule" - - "github.com/bazelbuild/rules_python/gazelle/manifest" - "github.com/bazelbuild/rules_python/gazelle/pythonconfig" -) - -// Configurer satisfies the config.Configurer interface. It's the -// language-specific configuration extension. -type Configurer struct{} - -// RegisterFlags registers command-line flags used by the extension. This -// method is called once with the root configuration when Gazelle -// starts. RegisterFlags may set an initial values in Config.Exts. When flags -// are set, they should modify these values. -func (py *Configurer) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config) {} - -// CheckFlags validates the configuration after command line flags are parsed. -// This is called once with the root configuration when Gazelle starts. -// CheckFlags may set default values in flags or make implied changes. -func (py *Configurer) CheckFlags(fs *flag.FlagSet, c *config.Config) error { - return nil -} - -// KnownDirectives returns a list of directive keys that this Configurer can -// interpret. Gazelle prints errors for directives that are not recoginized by -// any Configurer. -func (py *Configurer) KnownDirectives() []string { - return []string{ - pythonconfig.PythonExtensionDirective, - pythonconfig.PythonRootDirective, - pythonconfig.PythonManifestFileNameDirective, - pythonconfig.IgnoreFilesDirective, - pythonconfig.IgnoreDependenciesDirective, - pythonconfig.ValidateImportStatementsDirective, - pythonconfig.GenerationMode, - pythonconfig.LibraryNamingConvention, - pythonconfig.BinaryNamingConvention, - pythonconfig.TestNamingConvention, - } -} - -// Configure modifies the configuration using directives and other information -// extracted from a build file. Configure is called in each directory. -// -// c is the configuration for the current directory. It starts out as a copy -// of the configuration for the parent directory. -// -// rel is the slash-separated relative path from the repository root to -// the current directory. It is "" for the root directory itself. -// -// f is the build file for the current directory or nil if there is no -// existing build file. -func (py *Configurer) Configure(c *config.Config, rel string, f *rule.File) { - // Create the root config. - if _, exists := c.Exts[languageName]; !exists { - rootConfig := pythonconfig.New(c.RepoRoot, "") - c.Exts[languageName] = pythonconfig.Configs{"": rootConfig} - } - - configs := c.Exts[languageName].(pythonconfig.Configs) - - config, exists := configs[rel] - if !exists { - parent := configs.ParentForPackage(rel) - config = parent.NewChild() - configs[rel] = config - } - - if f == nil { - return - } - - gazelleManifestFilename := "gazelle_python.yaml" - - for _, d := range f.Directives { - switch d.Key { - case "exclude": - // We record the exclude directive for coarse-grained packages - // since we do manual tree traversal in this mode. - config.AddExcludedPattern(strings.TrimSpace(d.Value)) - case pythonconfig.PythonExtensionDirective: - switch d.Value { - case "enabled": - config.SetExtensionEnabled(true) - case "disabled": - config.SetExtensionEnabled(false) - default: - err := fmt.Errorf("invalid value for directive %q: %s: possible values are enabled/disabled", - pythonconfig.PythonExtensionDirective, d.Value) - log.Fatal(err) - } - case pythonconfig.PythonRootDirective: - config.SetPythonProjectRoot(rel) - case pythonconfig.PythonManifestFileNameDirective: - gazelleManifestFilename = strings.TrimSpace(d.Value) - case pythonconfig.IgnoreFilesDirective: - for _, ignoreFile := range strings.Split(d.Value, ",") { - config.AddIgnoreFile(ignoreFile) - } - case pythonconfig.IgnoreDependenciesDirective: - for _, ignoreDependency := range strings.Split(d.Value, ",") { - config.AddIgnoreDependency(ignoreDependency) - } - case pythonconfig.ValidateImportStatementsDirective: - v, err := strconv.ParseBool(strings.TrimSpace(d.Value)) - if err != nil { - log.Fatal(err) - } - config.SetValidateImportStatements(v) - case pythonconfig.GenerationMode: - switch pythonconfig.GenerationModeType(strings.TrimSpace(d.Value)) { - case pythonconfig.GenerationModePackage: - config.SetCoarseGrainedGeneration(false) - case pythonconfig.GenerationModeProject: - config.SetCoarseGrainedGeneration(true) - default: - err := fmt.Errorf("invalid value for directive %q: %s", - pythonconfig.GenerationMode, d.Value) - log.Fatal(err) - } - case pythonconfig.LibraryNamingConvention: - config.SetLibraryNamingConvention(strings.TrimSpace(d.Value)) - case pythonconfig.BinaryNamingConvention: - config.SetBinaryNamingConvention(strings.TrimSpace(d.Value)) - case pythonconfig.TestNamingConvention: - config.SetTestNamingConvention(strings.TrimSpace(d.Value)) - } - } - - gazelleManifestPath := filepath.Join(c.RepoRoot, rel, gazelleManifestFilename) - gazelleManifest, err := py.loadGazelleManifest(gazelleManifestPath) - if err != nil { - log.Fatal(err) - } - if gazelleManifest != nil { - config.SetGazelleManifest(gazelleManifest) - } -} - -func (py *Configurer) loadGazelleManifest(gazelleManifestPath string) (*manifest.Manifest, error) { - if _, err := os.Stat(gazelleManifestPath); err != nil { - if os.IsNotExist(err) { - return nil, nil - } - return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err) - } - manifestFile := new(manifest.File) - if err := manifestFile.Decode(gazelleManifestPath); err != nil { - return nil, fmt.Errorf("failed to load Gazelle manifest at %q: %w", gazelleManifestPath, err) - } - return manifestFile.Manifest, nil -} diff --git a/gazelle/fix.go b/gazelle/fix.go deleted file mode 100644 index c669f21d27..0000000000 --- a/gazelle/fix.go +++ /dev/null @@ -1,13 +0,0 @@ -package python - -import ( - "github.com/bazelbuild/bazel-gazelle/config" - "github.com/bazelbuild/bazel-gazelle/rule" -) - -// Fix repairs deprecated usage of language-specific rules in f. This is -// called before the file is indexed. Unless c.ShouldFix is true, fixes -// that delete or rename rules should not be performed. -func (py *Python) Fix(c *config.Config, f *rule.File) { - // TODO(f0rmiga): implement. -} diff --git a/gazelle/generate.go b/gazelle/generate.go deleted file mode 100644 index 43000c8ae8..0000000000 --- a/gazelle/generate.go +++ /dev/null @@ -1,438 +0,0 @@ -package python - -import ( - "fmt" - "io/fs" - "log" - "os" - "path/filepath" - "strings" - - "github.com/bazelbuild/bazel-gazelle/config" - "github.com/bazelbuild/bazel-gazelle/label" - "github.com/bazelbuild/bazel-gazelle/language" - "github.com/bazelbuild/bazel-gazelle/rule" - "github.com/bmatcuk/doublestar" - "github.com/emirpasic/gods/lists/singlylinkedlist" - "github.com/emirpasic/gods/sets/treeset" - godsutils "github.com/emirpasic/gods/utils" - - "github.com/bazelbuild/rules_python/gazelle/pythonconfig" -) - -const ( - pyLibraryEntrypointFilename = "__init__.py" - pyBinaryEntrypointFilename = "__main__.py" - pyTestEntrypointFilename = "__test__.py" - pyTestEntrypointTargetname = "__test__" - conftestFilename = "conftest.py" - conftestTargetname = "conftest" -) - -var ( - buildFilenames = []string{"BUILD", "BUILD.bazel"} -) - -func GetActualKindName(kind string, args language.GenerateArgs) string { - if kindOverride, ok := args.Config.KindMap[kind]; ok { - return kindOverride.KindName - } - return kind -} - -// GenerateRules extracts build metadata from source files in a directory. -// GenerateRules is called in each directory where an update is requested -// in depth-first post-order. -func (py *Python) GenerateRules(args language.GenerateArgs) language.GenerateResult { - cfgs := args.Config.Exts[languageName].(pythonconfig.Configs) - cfg := cfgs[args.Rel] - - if !cfg.ExtensionEnabled() { - return language.GenerateResult{} - } - - if !isBazelPackage(args.Dir) { - if cfg.CoarseGrainedGeneration() { - // Determine if the current directory is the root of the coarse-grained - // generation. If not, return without generating anything. - parent := cfg.Parent() - if parent != nil && parent.CoarseGrainedGeneration() { - return language.GenerateResult{} - } - } else if !hasEntrypointFile(args.Dir) { - return language.GenerateResult{} - } - } - - actualPyBinaryKind := GetActualKindName(pyBinaryKind, args) - actualPyLibraryKind := GetActualKindName(pyLibraryKind, args) - actualPyTestKind := GetActualKindName(pyTestKind, args) - - pythonProjectRoot := cfg.PythonProjectRoot() - - packageName := filepath.Base(args.Dir) - - pyLibraryFilenames := treeset.NewWith(godsutils.StringComparator) - pyTestFilenames := treeset.NewWith(godsutils.StringComparator) - pyFileNames := treeset.NewWith(godsutils.StringComparator) - - // hasPyBinary controls whether a py_binary target should be generated for - // this package or not. - hasPyBinary := false - - // hasPyTestFile and hasPyTestTarget control whether a py_test target should - // be generated for this package or not. - hasPyTestFile := false - hasPyTestTarget := false - hasConftestFile := false - - for _, f := range args.RegularFiles { - if cfg.IgnoresFile(filepath.Base(f)) { - continue - } - - ext := filepath.Ext(f) - if ext == ".py" { - pyFileNames.Add(f) - } - if !hasPyBinary && f == pyBinaryEntrypointFilename { - hasPyBinary = true - } else if !hasPyTestFile && f == pyTestEntrypointFilename { - hasPyTestFile = true - } else if !hasConftestFile && f == conftestTargetname { - hasConftestFile = true - } else if strings.HasSuffix(f, "_test.py") || (strings.HasPrefix(f, "test_") && ext == ".py") { - pyTestFilenames.Add(f) - } else if ext == ".py" { - pyLibraryFilenames.Add(f) - } - } - - // If a __test__.py file was not found on disk, search for targets that are - // named __test__. - if !hasPyTestFile && args.File != nil { - for _, rule := range args.File.Rules { - if rule.Name() == pyTestEntrypointTargetname { - hasPyTestTarget = true - break - } - } - } - - // Add files from subdirectories if they meet the criteria. - for _, d := range args.Subdirs { - // boundaryPackages represents child Bazel packages that are used as a - // boundary to stop processing under that tree. - boundaryPackages := make(map[string]struct{}) - err := filepath.WalkDir( - filepath.Join(args.Dir, d), - func(path string, entry fs.DirEntry, err error) error { - if err != nil { - return err - } - // Ignore the path if it crosses any boundary package. Walking - // the tree is still important because subsequent paths can - // represent files that have not crossed any boundaries. - for bp := range boundaryPackages { - if strings.HasPrefix(path, bp) { - return nil - } - } - if entry.IsDir() { - // If we are visiting a directory, we determine if we should - // halt digging the tree based on a few criterias: - // 1. The directory has a BUILD or BUILD.bazel files. Then - // it doesn't matter at all what it has since it's a - // separate Bazel package. - // 2. (only for fine-grained generation) The directory has - // an __init__.py, __main__.py or __test__.py, meaning - // a BUILD file will be generated. - if isBazelPackage(path) { - boundaryPackages[path] = struct{}{} - return nil - } - - if !cfg.CoarseGrainedGeneration() && hasEntrypointFile(path) { - return fs.SkipDir - } - - return nil - } - if filepath.Ext(path) == ".py" { - if cfg.CoarseGrainedGeneration() || !isEntrypointFile(path) { - f, _ := filepath.Rel(args.Dir, path) - excludedPatterns := cfg.ExcludedPatterns() - if excludedPatterns != nil { - it := excludedPatterns.Iterator() - for it.Next() { - excludedPattern := it.Value().(string) - isExcluded, err := doublestar.Match(excludedPattern, f) - if err != nil { - return err - } - if isExcluded { - return nil - } - } - } - baseName := filepath.Base(path) - if strings.HasSuffix(baseName, "_test.py") || strings.HasPrefix(baseName, "test_") { - pyTestFilenames.Add(f) - } else { - pyLibraryFilenames.Add(f) - } - } - } - return nil - }, - ) - if err != nil { - log.Printf("ERROR: %v\n", err) - return language.GenerateResult{} - } - } - - parser := newPython3Parser(args.Config.RepoRoot, args.Rel, cfg.IgnoresDependency) - visibility := fmt.Sprintf("//%s:__subpackages__", pythonProjectRoot) - - var result language.GenerateResult - result.Gen = make([]*rule.Rule, 0) - - collisionErrors := singlylinkedlist.New() - - if !hasPyTestFile && !hasPyTestTarget { - it := pyTestFilenames.Iterator() - for it.Next() { - pyLibraryFilenames.Add(it.Value()) - } - } - - var pyLibrary *rule.Rule - if !pyLibraryFilenames.Empty() { - deps, err := parser.parse(pyLibraryFilenames) - if err != nil { - log.Fatalf("ERROR: %v\n", err) - } - - pyLibraryTargetName := cfg.RenderLibraryName(packageName) - - // Check if a target with the same name we are generating alredy exists, - // and if it is of a different kind from the one we are generating. If - // so, we have to throw an error since Gazelle won't generate it - // correctly. - if args.File != nil { - for _, t := range args.File.Rules { - if t.Name() == pyLibraryTargetName && t.Kind() != actualPyLibraryKind { - fqTarget := label.New("", args.Rel, pyLibraryTargetName) - err := fmt.Errorf("failed to generate target %q of kind %q: "+ - "a target of kind %q with the same name already exists. "+ - "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), actualPyLibraryKind, t.Kind(), pythonconfig.LibraryNamingConvention) - collisionErrors.Add(err) - } - } - } - - pyLibrary = newTargetBuilder(pyLibraryKind, pyLibraryTargetName, pythonProjectRoot, args.Rel, pyFileNames). - addVisibility(visibility). - addSrcs(pyLibraryFilenames). - addModuleDependencies(deps). - generateImportsAttribute(). - build() - - result.Gen = append(result.Gen, pyLibrary) - result.Imports = append(result.Imports, pyLibrary.PrivateAttr(config.GazelleImportsKey)) - } - - if hasPyBinary { - deps, err := parser.parseSingle(pyBinaryEntrypointFilename) - if err != nil { - log.Fatalf("ERROR: %v\n", err) - } - - pyBinaryTargetName := cfg.RenderBinaryName(packageName) - - // Check if a target with the same name we are generating alredy exists, - // and if it is of a different kind from the one we are generating. If - // so, we have to throw an error since Gazelle won't generate it - // correctly. - if args.File != nil { - for _, t := range args.File.Rules { - if t.Name() == pyBinaryTargetName && t.Kind() != actualPyBinaryKind { - fqTarget := label.New("", args.Rel, pyBinaryTargetName) - err := fmt.Errorf("failed to generate target %q of kind %q: "+ - "a target of kind %q with the same name already exists. "+ - "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), actualPyBinaryKind, t.Kind(), pythonconfig.BinaryNamingConvention) - collisionErrors.Add(err) - } - } - } - - pyBinaryTarget := newTargetBuilder(pyBinaryKind, pyBinaryTargetName, pythonProjectRoot, args.Rel, pyFileNames). - setMain(pyBinaryEntrypointFilename). - addVisibility(visibility). - addSrc(pyBinaryEntrypointFilename). - addModuleDependencies(deps). - generateImportsAttribute() - - if pyLibrary != nil { - pyBinaryTarget.addModuleDependency(module{Name: pyLibrary.PrivateAttr(uuidKey).(string)}) - } - - pyBinary := pyBinaryTarget.build() - - result.Gen = append(result.Gen, pyBinary) - result.Imports = append(result.Imports, pyBinary.PrivateAttr(config.GazelleImportsKey)) - } - - var conftest *rule.Rule - if hasConftestFile { - deps, err := parser.parseSingle(conftestFilename) - if err != nil { - log.Fatalf("ERROR: %v\n", err) - } - - // Check if a target with the same name we are generating already - // exists, and if it is of a different kind from the one we are - // generating. If so, we have to throw an error since Gazelle won't - // generate it correctly. - if args.File != nil { - for _, t := range args.File.Rules { - if t.Name() == conftestTargetname && t.Kind() != actualPyLibraryKind { - fqTarget := label.New("", args.Rel, conftestTargetname) - err := fmt.Errorf("failed to generate target %q of kind %q: "+ - "a target of kind %q with the same name already exists.", - fqTarget.String(), actualPyLibraryKind, t.Kind()) - collisionErrors.Add(err) - } - } - } - - conftestTarget := newTargetBuilder(pyLibraryKind, conftestTargetname, pythonProjectRoot, args.Rel, pyFileNames). - addSrc(conftestFilename). - addModuleDependencies(deps). - addVisibility(visibility). - setTestonly(). - generateImportsAttribute() - - conftest = conftestTarget.build() - - result.Gen = append(result.Gen, conftest) - result.Imports = append(result.Imports, conftest.PrivateAttr(config.GazelleImportsKey)) - } - - var pyTestTargets []*targetBuilder - newPyTestTargetBuilder := func(srcs *treeset.Set, pyTestTargetName string) *targetBuilder { - deps, err := parser.parse(srcs) - if err != nil { - log.Fatalf("ERROR: %v\n", err) - } - // Check if a target with the same name we are generating already - // exists, and if it is of a different kind from the one we are - // generating. If so, we have to throw an error since Gazelle won't - // generate it correctly. - if args.File != nil { - for _, t := range args.File.Rules { - if t.Name() == pyTestTargetName && t.Kind() != actualPyTestKind { - fqTarget := label.New("", args.Rel, pyTestTargetName) - err := fmt.Errorf("failed to generate target %q of kind %q: "+ - "a target of kind %q with the same name already exists. "+ - "Use the '# gazelle:%s' directive to change the naming convention.", - fqTarget.String(), actualPyTestKind, t.Kind(), pythonconfig.TestNamingConvention) - collisionErrors.Add(err) - } - } - } - return newTargetBuilder(pyTestKind, pyTestTargetName, pythonProjectRoot, args.Rel, pyFileNames). - addSrcs(srcs). - addModuleDependencies(deps). - generateImportsAttribute() - } - if hasPyTestTarget { - - pyTestTargetName := cfg.RenderTestName(packageName) - pyTestTarget := newPyTestTargetBuilder(pyTestFilenames, pyTestTargetName) - - if hasPyTestTarget { - entrypointTarget := fmt.Sprintf(":%s", pyTestEntrypointTargetname) - main := fmt.Sprintf(":%s", pyTestEntrypointFilename) - pyTestTarget. - addSrc(entrypointTarget). - addResolvedDependency(entrypointTarget). - setMain(main) - } else { - pyTestTarget.setMain(pyTestEntrypointFilename) - } - pyTestTargets = append(pyTestTargets, pyTestTarget) - } else { - // Create one py_test target per file - pyTestFilenames.Each(func(index int, testFile interface{}) { - srcs := treeset.NewWith(godsutils.StringComparator, testFile) - pyTestTargetName := strings.TrimSuffix(filepath.Base(testFile.(string)), ".py") - pyTestTargets = append(pyTestTargets, newPyTestTargetBuilder(srcs, pyTestTargetName)) - }) - } - - for _, pyTestTarget := range pyTestTargets { - if conftest != nil { - pyTestTarget.addModuleDependency(module{Name: strings.TrimSuffix(conftestFilename, ".py")}) - } - pyTest := pyTestTarget.build() - - result.Gen = append(result.Gen, pyTest) - result.Imports = append(result.Imports, pyTest.PrivateAttr(config.GazelleImportsKey)) - } - - if !collisionErrors.Empty() { - it := collisionErrors.Iterator() - for it.Next() { - log.Printf("ERROR: %v\n", it.Value()) - } - os.Exit(1) - } - - return result -} - -// isBazelPackage determines if the directory is a Bazel package by probing for -// the existence of a known BUILD file name. -func isBazelPackage(dir string) bool { - for _, buildFilename := range buildFilenames { - path := filepath.Join(dir, buildFilename) - if _, err := os.Stat(path); err == nil { - return true - } - } - return false -} - -// hasEntrypointFile determines if the directory has any of the established -// entrypoint filenames. -func hasEntrypointFile(dir string) bool { - for _, entrypointFilename := range []string{ - pyLibraryEntrypointFilename, - pyBinaryEntrypointFilename, - pyTestEntrypointFilename, - } { - path := filepath.Join(dir, entrypointFilename) - if _, err := os.Stat(path); err == nil { - return true - } - } - return false -} - -// isEntrypointFile returns whether the given path is an entrypoint file. The -// given path can be absolute or relative. -func isEntrypointFile(path string) bool { - basePath := filepath.Base(path) - switch basePath { - case pyLibraryEntrypointFilename, - pyBinaryEntrypointFilename, - pyTestEntrypointFilename: - return true - default: - return false - } -} diff --git a/gazelle/kinds.go b/gazelle/kinds.go deleted file mode 100644 index fa0f4ed98a..0000000000 --- a/gazelle/kinds.go +++ /dev/null @@ -1,88 +0,0 @@ -package python - -import ( - "github.com/bazelbuild/bazel-gazelle/rule" -) - -const ( - pyBinaryKind = "py_binary" - pyLibraryKind = "py_library" - pyTestKind = "py_test" -) - -// Kinds returns a map that maps rule names (kinds) and information on how to -// match and merge attributes that may be found in rules of those kinds. -func (*Python) Kinds() map[string]rule.KindInfo { - return pyKinds -} - -var pyKinds = map[string]rule.KindInfo{ - pyBinaryKind: { - MatchAny: true, - NonEmptyAttrs: map[string]bool{ - "deps": true, - "main": true, - "srcs": true, - "imports": true, - "visibility": true, - }, - SubstituteAttrs: map[string]bool{}, - MergeableAttrs: map[string]bool{ - "srcs": true, - }, - ResolveAttrs: map[string]bool{ - "deps": true, - }, - }, - pyLibraryKind: { - MatchAny: true, - NonEmptyAttrs: map[string]bool{ - "deps": true, - "srcs": true, - "imports": true, - "visibility": true, - }, - SubstituteAttrs: map[string]bool{}, - MergeableAttrs: map[string]bool{ - "srcs": true, - }, - ResolveAttrs: map[string]bool{ - "deps": true, - }, - }, - pyTestKind: { - MatchAny: true, - NonEmptyAttrs: map[string]bool{ - "deps": true, - "main": true, - "srcs": true, - "imports": true, - "visibility": true, - }, - SubstituteAttrs: map[string]bool{}, - MergeableAttrs: map[string]bool{ - "srcs": true, - }, - ResolveAttrs: map[string]bool{ - "deps": true, - }, - }, -} - -// Loads returns .bzl files and symbols they define. Every rule generated by -// GenerateRules, now or in the past, should be loadable from one of these -// files. -func (py *Python) Loads() []rule.LoadInfo { - return pyLoads -} - -var pyLoads = []rule.LoadInfo{ - { - Name: "@rules_python//python:defs.bzl", - Symbols: []string{ - pyBinaryKind, - pyLibraryKind, - pyTestKind, - }, - }, -} diff --git a/gazelle/language.go b/gazelle/language.go deleted file mode 100644 index 877ac6d065..0000000000 --- a/gazelle/language.go +++ /dev/null @@ -1,18 +0,0 @@ -package python - -import ( - "github.com/bazelbuild/bazel-gazelle/language" -) - -// Python satisfies the language.Language interface. It is the Gazelle extension -// for Python rules. -type Python struct { - Configurer - Resolver -} - -// NewLanguage initializes a new Python that satisfies the language.Language -// interface. This is the entrypoint for the extension initialization. -func NewLanguage() language.Language { - return &Python{} -} diff --git a/gazelle/manifest/test/run.sh b/gazelle/manifest/test/run.sh deleted file mode 100755 index 4b24b51ae4..0000000000 --- a/gazelle/manifest/test/run.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -# This file exists to allow passing the runfile paths to the Go program via -# environment variables. - -set -o errexit -o nounset - -"${_TEST_BINARY}" --requirements "${_TEST_REQUIREMENTS}" --manifest "${_TEST_MANIFEST}" \ No newline at end of file diff --git a/gazelle/parse.py b/gazelle/parse.py deleted file mode 100644 index b892229386..0000000000 --- a/gazelle/parse.py +++ /dev/null @@ -1,92 +0,0 @@ -# parse.py is a long-living program that communicates over STDIN and STDOUT. -# STDIN receives parse requests, one per line. It outputs the parsed modules and -# comments from all the files from each request. - -import ast -import concurrent.futures -import json -import os -import sys -from io import BytesIO -from tokenize import COMMENT, tokenize - - -def parse_import_statements(content, filepath): - modules = list() - tree = ast.parse(content) - for node in ast.walk(tree): - if isinstance(node, ast.Import): - for subnode in node.names: - module = { - "name": subnode.name, - "lineno": node.lineno, - "filepath": filepath, - "from": "", - } - modules.append(module) - elif isinstance(node, ast.ImportFrom) and node.level == 0: - for subnode in node.names: - module = { - "name": f"{node.module}.{subnode.name}", - "lineno": node.lineno, - "filepath": filepath, - "from": node.module, - } - modules.append(module) - return modules - - -def parse_comments(content): - comments = list() - g = tokenize(BytesIO(content.encode("utf-8")).readline) - for toknum, tokval, _, _, _ in g: - if toknum == COMMENT: - comments.append(tokval) - return comments - - -def parse(repo_root, rel_package_path, filename): - rel_filepath = os.path.join(rel_package_path, filename) - abs_filepath = os.path.join(repo_root, rel_filepath) - with open(abs_filepath, "r") as file: - content = file.read() - # From simple benchmarks, 2 workers gave the best performance here. - with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: - modules_future = executor.submit( - parse_import_statements, content, rel_filepath - ) - comments_future = executor.submit(parse_comments, content) - modules = modules_future.result() - comments = comments_future.result() - output = { - "modules": modules, - "comments": comments, - } - return output - - -def main(stdin, stdout): - with concurrent.futures.ProcessPoolExecutor() as executor: - for parse_request in stdin: - parse_request = json.loads(parse_request) - repo_root = parse_request["repo_root"] - rel_package_path = parse_request["rel_package_path"] - filenames = parse_request["filenames"] - outputs = list() - if len(filenames) == 1: - outputs.append(parse(repo_root, rel_package_path, filenames[0])) - else: - futures = [ - executor.submit(parse, repo_root, rel_package_path, filename) - for filename in filenames - if filename != "" - ] - for future in concurrent.futures.as_completed(futures): - outputs.append(future.result()) - print(json.dumps(outputs), end="", file=stdout, flush=True) - stdout.buffer.write(bytes([0])) - stdout.flush() - - -if __name__ == "__main__": - exit(main(sys.stdin, sys.stdout)) diff --git a/gazelle/parser.go b/gazelle/parser.go deleted file mode 100644 index d287caf233..0000000000 --- a/gazelle/parser.go +++ /dev/null @@ -1,254 +0,0 @@ -package python - -import ( - "bufio" - "context" - "encoding/json" - "fmt" - "io" - "log" - "os" - "os/exec" - "strings" - "sync" - "time" - - "github.com/bazelbuild/rules_go/go/tools/bazel" - "github.com/emirpasic/gods/sets/treeset" - godsutils "github.com/emirpasic/gods/utils" -) - -var ( - parserStdin io.Writer - parserStdout io.Reader - parserMutex sync.Mutex -) - -func init() { - parseScriptRunfile, err := bazel.Runfile("gazelle/parse") - if err != nil { - log.Printf("failed to initialize parser: %v\n", err) - os.Exit(1) - } - - ctx := context.Background() - ctx, parserCancel := context.WithTimeout(ctx, time.Minute*5) - cmd := exec.CommandContext(ctx, parseScriptRunfile) - - cmd.Stderr = os.Stderr - - stdin, err := cmd.StdinPipe() - if err != nil { - log.Printf("failed to initialize parser: %v\n", err) - os.Exit(1) - } - parserStdin = stdin - - stdout, err := cmd.StdoutPipe() - if err != nil { - log.Printf("failed to initialize parser: %v\n", err) - os.Exit(1) - } - parserStdout = stdout - - if err := cmd.Start(); err != nil { - log.Printf("failed to initialize parser: %v\n", err) - os.Exit(1) - } - - go func() { - defer parserCancel() - if err := cmd.Wait(); err != nil { - log.Printf("failed to wait for parser: %v\n", err) - os.Exit(1) - } - }() -} - -// python3Parser implements a parser for Python files that extracts the modules -// as seen in the import statements. -type python3Parser struct { - // The value of language.GenerateArgs.Config.RepoRoot. - repoRoot string - // The value of language.GenerateArgs.Rel. - relPackagePath string - // The function that determines if a dependency is ignored from a Gazelle - // directive. It's the signature of pythonconfig.Config.IgnoresDependency. - ignoresDependency func(dep string) bool -} - -// newPython3Parser constructs a new python3Parser. -func newPython3Parser( - repoRoot string, - relPackagePath string, - ignoresDependency func(dep string) bool, -) *python3Parser { - return &python3Parser{ - repoRoot: repoRoot, - relPackagePath: relPackagePath, - ignoresDependency: ignoresDependency, - } -} - -// parseSingle parses a single Python file and returns the extracted modules -// from the import statements as well as the parsed comments. -func (p *python3Parser) parseSingle(pyFilename string) (*treeset.Set, error) { - pyFilenames := treeset.NewWith(godsutils.StringComparator) - pyFilenames.Add(pyFilename) - return p.parse(pyFilenames) -} - -// parse parses multiple Python files and returns the extracted modules from -// the import statements as well as the parsed comments. -func (p *python3Parser) parse(pyFilenames *treeset.Set) (*treeset.Set, error) { - parserMutex.Lock() - defer parserMutex.Unlock() - - modules := treeset.NewWith(moduleComparator) - - req := map[string]interface{}{ - "repo_root": p.repoRoot, - "rel_package_path": p.relPackagePath, - "filenames": pyFilenames.Values(), - } - encoder := json.NewEncoder(parserStdin) - if err := encoder.Encode(&req); err != nil { - return nil, fmt.Errorf("failed to parse: %w", err) - } - - reader := bufio.NewReader(parserStdout) - data, err := reader.ReadBytes(0) - if err != nil { - return nil, fmt.Errorf("failed to parse: %w", err) - } - data = data[:len(data)-1] - var allRes []parserResponse - if err := json.Unmarshal(data, &allRes); err != nil { - return nil, fmt.Errorf("failed to parse: %w", err) - } - - for _, res := range allRes { - annotations := annotationsFromComments(res.Comments) - - for _, m := range res.Modules { - // Check for ignored dependencies set via an annotation to the Python - // module. - if annotations.ignores(m.Name) || annotations.ignores(m.From) { - continue - } - - // Check for ignored dependencies set via a Gazelle directive in a BUILD - // file. - if p.ignoresDependency(m.Name) || p.ignoresDependency(m.From) { - continue - } - - modules.Add(m) - } - } - - return modules, nil -} - -// parserResponse represents a response returned by the parser.py for a given -// parsed Python module. -type parserResponse struct { - // The modules depended by the parsed module. - Modules []module `json:"modules"` - // The comments contained in the parsed module. This contains the - // annotations as they are comments in the Python module. - Comments []comment `json:"comments"` -} - -// module represents a fully-qualified, dot-separated, Python module as seen on -// the import statement, alongside the line number where it happened. -type module struct { - // The fully-qualified, dot-separated, Python module name as seen on import - // statements. - Name string `json:"name"` - // The line number where the import happened. - LineNumber uint32 `json:"lineno"` - // The path to the module file relative to the Bazel workspace root. - Filepath string `json:"filepath"` - // If this was a from import, e.g. from foo import bar, From indicates the module - // from which it is imported. - From string `json:"from"` -} - -// moduleComparator compares modules by name. -func moduleComparator(a, b interface{}) int { - return godsutils.StringComparator(a.(module).Name, b.(module).Name) -} - -// annotationKind represents Gazelle annotation kinds. -type annotationKind string - -const ( - // The Gazelle annotation prefix. - annotationPrefix string = "gazelle:" - // The ignore annotation kind. E.g. '# gazelle:ignore '. - annotationKindIgnore annotationKind = "ignore" -) - -// comment represents a Python comment. -type comment string - -// asAnnotation returns an annotation object if the comment has the -// annotationPrefix. -func (c *comment) asAnnotation() *annotation { - uncomment := strings.TrimLeft(string(*c), "# ") - if !strings.HasPrefix(uncomment, annotationPrefix) { - return nil - } - withoutPrefix := strings.TrimPrefix(uncomment, annotationPrefix) - annotationParts := strings.SplitN(withoutPrefix, " ", 2) - return &annotation{ - kind: annotationKind(annotationParts[0]), - value: annotationParts[1], - } -} - -// annotation represents a single Gazelle annotation parsed from a Python -// comment. -type annotation struct { - kind annotationKind - value string -} - -// annotations represent the collection of all Gazelle annotations parsed out of -// the comments of a Python module. -type annotations struct { - // The parsed modules to be ignored by Gazelle. - ignore map[string]struct{} -} - -// annotationsFromComments returns all the annotations parsed out of the -// comments of a Python module. -func annotationsFromComments(comments []comment) *annotations { - ignore := make(map[string]struct{}) - for _, comment := range comments { - annotation := comment.asAnnotation() - if annotation != nil { - if annotation.kind == annotationKindIgnore { - modules := strings.Split(annotation.value, ",") - for _, m := range modules { - if m == "" { - continue - } - m = strings.TrimSpace(m) - ignore[m] = struct{}{} - } - } - } - } - return &annotations{ - ignore: ignore, - } -} - -// ignored returns true if the given module was ignored via the ignore -// annotation. -func (a *annotations) ignores(module string) bool { - _, ignores := a.ignore[module] - return ignores -} diff --git a/gazelle/python_test.go b/gazelle/python_test.go deleted file mode 100644 index 99656552dd..0000000000 --- a/gazelle/python_test.go +++ /dev/null @@ -1,211 +0,0 @@ -/* Copyright 2020 The Bazel Authors. All rights reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This test file was first seen on: -// https://github.com/bazelbuild/bazel-skylib/blob/f80bc733d4b9f83d427ce3442be2e07427b2cc8d/gazelle/bzl/BUILD. -// It was modified for the needs of this extension. - -package python_test - -import ( - "bytes" - "context" - "errors" - "fmt" - "io/ioutil" - "os" - "os/exec" - "path/filepath" - "strings" - "testing" - "time" - - "github.com/bazelbuild/bazel-gazelle/testtools" - "github.com/bazelbuild/rules_go/go/tools/bazel" - "github.com/emirpasic/gods/lists/singlylinkedlist" - "github.com/ghodss/yaml" -) - -const ( - extensionDir = "gazelle/" - testDataPath = extensionDir + "testdata/" - gazelleBinaryName = "gazelle_python_binary" -) - -var gazellePath = mustFindGazelle() - -func TestGazelleBinary(t *testing.T) { - tests := map[string][]bazel.RunfileEntry{} - - runfiles, err := bazel.ListRunfiles() - if err != nil { - t.Fatalf("bazel.ListRunfiles() error: %v", err) - } - for _, f := range runfiles { - if strings.HasPrefix(f.ShortPath, testDataPath) { - relativePath := strings.TrimPrefix(f.ShortPath, testDataPath) - parts := strings.SplitN(relativePath, "/", 2) - if len(parts) < 2 { - // This file is not a part of a testcase since it must be in a dir that - // is the test case and then have a path inside of that. - continue - } - - tests[parts[0]] = append(tests[parts[0]], f) - } - } - if len(tests) == 0 { - t.Fatal("no tests found") - } - - for testName, files := range tests { - testPath(t, testName, files) - } -} - -func testPath(t *testing.T, name string, files []bazel.RunfileEntry) { - t.Run(name, func(t *testing.T) { - var inputs []testtools.FileSpec - var goldens []testtools.FileSpec - - var config *testYAML - for _, f := range files { - path := f.Path - trim := testDataPath + name + "/" - shortPath := strings.TrimPrefix(f.ShortPath, trim) - info, err := os.Stat(path) - if err != nil { - t.Fatalf("os.Stat(%q) error: %v", path, err) - } - - if info.IsDir() { - continue - } - - content, err := ioutil.ReadFile(path) - if err != nil { - t.Errorf("ioutil.ReadFile(%q) error: %v", path, err) - } - - if filepath.Base(shortPath) == "test.yaml" { - if config != nil { - t.Fatal("only 1 test.yaml is supported") - } - config = new(testYAML) - if err := yaml.Unmarshal(content, config); err != nil { - t.Fatal(err) - } - } - - if strings.HasSuffix(shortPath, ".in") { - inputs = append(inputs, testtools.FileSpec{ - Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".in")), - Content: string(content), - }) - } else if strings.HasSuffix(shortPath, ".out") { - goldens = append(goldens, testtools.FileSpec{ - Path: filepath.Join(name, strings.TrimSuffix(shortPath, ".out")), - Content: string(content), - }) - } else { - inputs = append(inputs, testtools.FileSpec{ - Path: filepath.Join(name, shortPath), - Content: string(content), - }) - goldens = append(goldens, testtools.FileSpec{ - Path: filepath.Join(name, shortPath), - Content: string(content), - }) - } - } - - testdataDir, cleanup := testtools.CreateFiles(t, inputs) - defer cleanup() - defer func() { - if t.Failed() { - filepath.Walk(testdataDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - t.Logf("%q exists", strings.TrimPrefix(path, testdataDir)) - return nil - }) - } - }() - - workspaceRoot := filepath.Join(testdataDir, name) - - args := []string{"-build_file_name=BUILD,BUILD.bazel"} - - ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) - defer cancel() - cmd := exec.CommandContext(ctx, gazellePath, args...) - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - cmd.Dir = workspaceRoot - if err := cmd.Run(); err != nil { - var e *exec.ExitError - if !errors.As(err, &e) { - t.Fatal(err) - } - } - errs := singlylinkedlist.New() - actualExitCode := cmd.ProcessState.ExitCode() - if config.Expect.ExitCode != actualExitCode { - errs.Add(fmt.Errorf("expected gazelle exit code: %d\ngot: %d", - config.Expect.ExitCode, actualExitCode, - )) - } - actualStdout := stdout.String() - if strings.TrimSpace(config.Expect.Stdout) != strings.TrimSpace(actualStdout) { - errs.Add(fmt.Errorf("expected gazelle stdout: %s\ngot: %s", - config.Expect.Stdout, actualStdout, - )) - } - actualStderr := stderr.String() - if strings.TrimSpace(config.Expect.Stderr) != strings.TrimSpace(actualStderr) { - errs.Add(fmt.Errorf("expected gazelle stderr: %s\ngot: %s", - config.Expect.Stderr, actualStderr, - )) - } - if !errs.Empty() { - errsIt := errs.Iterator() - for errsIt.Next() { - err := errsIt.Value().(error) - t.Log(err) - } - t.FailNow() - } - - testtools.CheckFiles(t, testdataDir, goldens) - }) -} - -func mustFindGazelle() string { - gazellePath, ok := bazel.FindBinary(extensionDir, gazelleBinaryName) - if !ok { - panic("could not find gazelle binary") - } - return gazellePath -} - -type testYAML struct { - Expect struct { - ExitCode int `json:"exit_code"` - Stdout string `json:"stdout"` - Stderr string `json:"stderr"` - } `json:"expect"` -} diff --git a/gazelle/resolve.go b/gazelle/resolve.go deleted file mode 100644 index 220876da60..0000000000 --- a/gazelle/resolve.go +++ /dev/null @@ -1,301 +0,0 @@ -package python - -import ( - "fmt" - "log" - "os" - "path/filepath" - "strings" - - "github.com/bazelbuild/bazel-gazelle/config" - "github.com/bazelbuild/bazel-gazelle/label" - "github.com/bazelbuild/bazel-gazelle/repo" - "github.com/bazelbuild/bazel-gazelle/resolve" - "github.com/bazelbuild/bazel-gazelle/rule" - bzl "github.com/bazelbuild/buildtools/build" - "github.com/emirpasic/gods/sets/treeset" - godsutils "github.com/emirpasic/gods/utils" - - "github.com/bazelbuild/rules_python/gazelle/pythonconfig" -) - -const languageName = "py" - -const ( - // resolvedDepsKey is the attribute key used to pass dependencies that don't - // need to be resolved by the dependency resolver in the Resolver step. - resolvedDepsKey = "_gazelle_python_resolved_deps" - // uuidKey is the attribute key used to uniquely identify a py_library - // target that should be imported by a py_test or py_binary in the same - // Bazel package. - uuidKey = "_gazelle_python_library_uuid" -) - -// Resolver satisfies the resolve.Resolver interface. It resolves dependencies -// in rules generated by this extension. -type Resolver struct{} - -// Name returns the name of the language. This is the prefix of the kinds of -// rules generated. E.g. py_library and py_binary. -func (*Resolver) Name() string { return languageName } - -// Imports returns a list of ImportSpecs that can be used to import the rule -// r. This is used to populate RuleIndex. -// -// If nil is returned, the rule will not be indexed. If any non-nil slice is -// returned, including an empty slice, the rule will be indexed. -func (py *Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec { - cfgs := c.Exts[languageName].(pythonconfig.Configs) - cfg := cfgs[f.Pkg] - srcs := r.AttrStrings("srcs") - provides := make([]resolve.ImportSpec, 0, len(srcs)+1) - for _, src := range srcs { - ext := filepath.Ext(src) - if ext == ".py" { - pythonProjectRoot := cfg.PythonProjectRoot() - provide := importSpecFromSrc(pythonProjectRoot, f.Pkg, src) - provides = append(provides, provide) - } - } - if r.PrivateAttr(uuidKey) != nil { - provide := resolve.ImportSpec{ - Lang: languageName, - Imp: r.PrivateAttr(uuidKey).(string), - } - provides = append(provides, provide) - } - if len(provides) == 0 { - return nil - } - return provides -} - -// importSpecFromSrc determines the ImportSpec based on the target that contains the src so that -// the target can be indexed for import statements that match the calculated src relative to the its -// Python project root. -func importSpecFromSrc(pythonProjectRoot, bzlPkg, src string) resolve.ImportSpec { - pythonPkgDir := filepath.Join(bzlPkg, filepath.Dir(src)) - relPythonPkgDir, err := filepath.Rel(pythonProjectRoot, pythonPkgDir) - if err != nil { - panic(fmt.Errorf("unexpected failure: %v", err)) - } - if relPythonPkgDir == "." { - relPythonPkgDir = "" - } - pythonPkg := strings.ReplaceAll(relPythonPkgDir, "/", ".") - filename := filepath.Base(src) - if filename == pyLibraryEntrypointFilename { - if pythonPkg != "" { - return resolve.ImportSpec{ - Lang: languageName, - Imp: pythonPkg, - } - } - } - moduleName := strings.TrimSuffix(filename, ".py") - var imp string - if pythonPkg == "" { - imp = moduleName - } else { - imp = fmt.Sprintf("%s.%s", pythonPkg, moduleName) - } - return resolve.ImportSpec{ - Lang: languageName, - Imp: imp, - } -} - -// Embeds returns a list of labels of rules that the given rule embeds. If -// a rule is embedded by another importable rule of the same language, only -// the embedding rule will be indexed. The embedding rule will inherit -// the imports of the embedded rule. -func (py *Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label { - // TODO(f0rmiga): implement. - return make([]label.Label, 0) -} - -// Resolve translates imported libraries for a given rule into Bazel -// dependencies. Information about imported libraries is returned for each -// rule generated by language.GenerateRules in -// language.GenerateResult.Imports. Resolve generates a "deps" attribute (or -// the appropriate language-specific equivalent) for each import according to -// language-specific rules and heuristics. -func (py *Resolver) Resolve( - c *config.Config, - ix *resolve.RuleIndex, - rc *repo.RemoteCache, - r *rule.Rule, - modulesRaw interface{}, - from label.Label, -) { - // TODO(f0rmiga): may need to be defensive here once this Gazelle extension - // join with the main Gazelle binary with other rules. It may conflict with - // other generators that generate py_* targets. - deps := treeset.NewWith(godsutils.StringComparator) - if modulesRaw != nil { - cfgs := c.Exts[languageName].(pythonconfig.Configs) - cfg := cfgs[from.Pkg] - pythonProjectRoot := cfg.PythonProjectRoot() - modules := modulesRaw.(*treeset.Set) - it := modules.Iterator() - explainDependency := os.Getenv("EXPLAIN_DEPENDENCY") - hasFatalError := false - MODULES_LOOP: - for it.Next() { - mod := it.Value().(module) - moduleParts := strings.Split(mod.Name, ".") - possibleModules := []string{mod.Name} - for len(moduleParts) > 1 { - // Iterate back through the possible imports until - // a match is found. - // For example, "from foo.bar import baz" where bar is a variable, we should try - // `foo.bar.baz` first, then `foo.bar`, then `foo`. In the first case, the import could be file `baz.py` - // in the directory `foo/bar`. - // Or, the import could be variable `bar` in file `foo/bar.py`. - // The import could also be from a standard module, e.g. `six.moves`, where - // the dependency is actually `six`. - moduleParts = moduleParts[:len(moduleParts)-1] - possibleModules = append(possibleModules, strings.Join(moduleParts, ".")) - } - errs := []error{} - POSSIBLE_MODULE_LOOP: - for _, moduleName := range possibleModules { - imp := resolve.ImportSpec{Lang: languageName, Imp: moduleName} - if override, ok := resolve.FindRuleWithOverride(c, imp, languageName); ok { - if override.Repo == "" { - override.Repo = from.Repo - } - if !override.Equal(from) { - if override.Repo == from.Repo { - override.Repo = "" - } - dep := override.String() - deps.Add(dep) - if explainDependency == dep { - log.Printf("Explaining dependency (%s): "+ - "in the target %q, the file %q imports %q at line %d, "+ - "which resolves using the \"gazelle:resolve\" directive.\n", - explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber) - } - continue MODULES_LOOP - } - } else { - if dep, ok := cfg.FindThirdPartyDependency(moduleName); ok { - deps.Add(dep) - if explainDependency == dep { - log.Printf("Explaining dependency (%s): "+ - "in the target %q, the file %q imports %q at line %d, "+ - "which resolves from the third-party module %q from the wheel %q.\n", - explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber, mod.Name, dep) - } - continue MODULES_LOOP - } else { - matches := ix.FindRulesByImportWithConfig(c, imp, languageName) - if len(matches) == 0 { - // Check if the imported module is part of the standard library. - if isStd, err := isStdModule(module{Name: moduleName}); err != nil { - log.Println("Error checking if standard module: ", err) - hasFatalError = true - continue POSSIBLE_MODULE_LOOP - } else if isStd { - continue MODULES_LOOP - } else if cfg.ValidateImportStatements() { - err := fmt.Errorf( - "%[1]q at line %[2]d from %[3]q is an invalid dependency: possible solutions:\n"+ - "\t1. Add it as a dependency in the requirements.txt file.\n"+ - "\t2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.\n"+ - "\t3. Ignore it with a comment '# gazelle:ignore %[1]s' in the Python file.\n", - moduleName, mod.LineNumber, mod.Filepath, - ) - errs = append(errs, err) - continue POSSIBLE_MODULE_LOOP - } - } - filteredMatches := make([]resolve.FindResult, 0, len(matches)) - for _, match := range matches { - if match.IsSelfImport(from) { - // Prevent from adding itself as a dependency. - continue MODULES_LOOP - } - filteredMatches = append(filteredMatches, match) - } - if len(filteredMatches) == 0 { - continue POSSIBLE_MODULE_LOOP - } - if len(filteredMatches) > 1 { - sameRootMatches := make([]resolve.FindResult, 0, len(filteredMatches)) - for _, match := range filteredMatches { - if strings.HasPrefix(match.Label.Pkg, pythonProjectRoot) { - sameRootMatches = append(sameRootMatches, match) - } - } - if len(sameRootMatches) != 1 { - err := fmt.Errorf( - "multiple targets (%s) may be imported with %q at line %d in %q "+ - "- this must be fixed using the \"gazelle:resolve\" directive", - targetListFromResults(filteredMatches), moduleName, mod.LineNumber, mod.Filepath) - errs = append(errs, err) - continue POSSIBLE_MODULE_LOOP - } - filteredMatches = sameRootMatches - } - matchLabel := filteredMatches[0].Label.Rel(from.Repo, from.Pkg) - dep := matchLabel.String() - deps.Add(dep) - if explainDependency == dep { - log.Printf("Explaining dependency (%s): "+ - "in the target %q, the file %q imports %q at line %d, "+ - "which resolves from the first-party indexed labels.\n", - explainDependency, from.String(), mod.Filepath, moduleName, mod.LineNumber) - } - continue MODULES_LOOP - } - } - } // End possible modules loop. - if len(errs) > 0 { - // If, after trying all possible modules, we still haven't found anything, error out. - joinedErrs := "" - for _, err := range errs { - joinedErrs = fmt.Sprintf("%s%s\n", joinedErrs, err) - } - log.Printf("ERROR: failed to validate dependencies for target %q: %v\n", from.String(), joinedErrs) - hasFatalError = true - } - } - if hasFatalError { - os.Exit(1) - } - } - resolvedDeps := r.PrivateAttr(resolvedDepsKey).(*treeset.Set) - if !resolvedDeps.Empty() { - it := resolvedDeps.Iterator() - for it.Next() { - deps.Add(it.Value()) - } - } - if !deps.Empty() { - r.SetAttr("deps", convertDependencySetToExpr(deps)) - } -} - -// targetListFromResults returns a string with the human-readable list of -// targets contained in the given results. -func targetListFromResults(results []resolve.FindResult) string { - list := make([]string, len(results)) - for i, result := range results { - list[i] = result.Label.String() - } - return strings.Join(list, ", ") -} - -// convertDependencySetToExpr converts the given set of dependencies to an -// expression to be used in the deps attribute. -func convertDependencySetToExpr(set *treeset.Set) bzl.Expr { - deps := make([]bzl.Expr, set.Size()) - it := set.Iterator() - for it.Next() { - dep := it.Value().(string) - deps[it.Index()] = &bzl.StringExpr{Value: dep} - } - return &bzl.ListExpr{List: deps} -} diff --git a/gazelle/std_modules.go b/gazelle/std_modules.go deleted file mode 100644 index f7d0c243d5..0000000000 --- a/gazelle/std_modules.go +++ /dev/null @@ -1,98 +0,0 @@ -package python - -import ( - "bufio" - "context" - "fmt" - "io" - "log" - "os" - "os/exec" - "strconv" - "strings" - "sync" - "time" - - "github.com/bazelbuild/rules_go/go/tools/bazel" -) - -var ( - stdModulesStdin io.Writer - stdModulesStdout io.Reader - stdModulesMutex sync.Mutex - stdModulesSeen map[string]struct{} -) - -func init() { - stdModulesSeen = make(map[string]struct{}) - - stdModulesScriptRunfile, err := bazel.Runfile("gazelle/std_modules") - if err != nil { - log.Printf("failed to initialize std_modules: %v\n", err) - os.Exit(1) - } - - ctx := context.Background() - ctx, stdModulesCancel := context.WithTimeout(ctx, time.Minute*5) - cmd := exec.CommandContext(ctx, stdModulesScriptRunfile) - - cmd.Stderr = os.Stderr - cmd.Env = []string{} - - stdin, err := cmd.StdinPipe() - if err != nil { - log.Printf("failed to initialize std_modules: %v\n", err) - os.Exit(1) - } - stdModulesStdin = stdin - - stdout, err := cmd.StdoutPipe() - if err != nil { - log.Printf("failed to initialize std_modules: %v\n", err) - os.Exit(1) - } - stdModulesStdout = stdout - - if err := cmd.Start(); err != nil { - log.Printf("failed to initialize std_modules: %v\n", err) - os.Exit(1) - } - - go func() { - defer stdModulesCancel() - if err := cmd.Wait(); err != nil { - log.Printf("failed to wait for std_modules: %v\n", err) - os.Exit(1) - } - }() -} - -func isStdModule(m module) (bool, error) { - if _, seen := stdModulesSeen[m.Name]; seen { - return true, nil - } - stdModulesMutex.Lock() - defer stdModulesMutex.Unlock() - - fmt.Fprintf(stdModulesStdin, "%s\n", m.Name) - - stdoutReader := bufio.NewReader(stdModulesStdout) - line, err := stdoutReader.ReadString('\n') - if err != nil { - return false, err - } - if len(line) == 0 { - return false, fmt.Errorf("unexpected empty output from std_modules") - } - - isStd, err := strconv.ParseBool(strings.TrimSpace(line)) - if err != nil { - return false, err - } - - if isStd { - stdModulesSeen[m.Name] = struct{}{} - return true, nil - } - return false, nil -} diff --git a/gazelle/std_modules.py b/gazelle/std_modules.py deleted file mode 100644 index ccd1dcd3aa..0000000000 --- a/gazelle/std_modules.py +++ /dev/null @@ -1,39 +0,0 @@ -# std_modules.py is a long-living program that communicates over STDIN and -# STDOUT. STDIN receives module names, one per line. For each module statement -# it evaluates, it outputs true/false for whether the module is part of the -# standard library or not. - -import site -import sys - - -# Don't return any paths, all userland site-packages should be ignored. -def __override_getusersitepackages__(): - return "" - - -site.getusersitepackages = __override_getusersitepackages__ - - -def is_std_modules(module): - try: - __import__(module, globals(), locals(), [], 0) - return True - except Exception: - return False - - -def main(stdin, stdout): - for module in stdin: - module = module.strip() - # Don't print the boolean directly as it is captilized in Python. - print( - "true" if is_std_modules(module) else "false", - end="\n", - file=stdout, - ) - stdout.flush() - - -if __name__ == "__main__": - exit(main(sys.stdin, sys.stdout)) diff --git a/gazelle/target.go b/gazelle/target.go deleted file mode 100644 index 2b41248cc2..0000000000 --- a/gazelle/target.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2023 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package python - -import ( - "github.com/bazelbuild/bazel-gazelle/config" - "github.com/bazelbuild/bazel-gazelle/rule" - "github.com/emirpasic/gods/sets/treeset" - godsutils "github.com/emirpasic/gods/utils" - "path/filepath" -) - -// targetBuilder builds targets to be generated by Gazelle. -type targetBuilder struct { - kind string - name string - pythonProjectRoot string - bzlPackage string - srcs *treeset.Set - siblingSrcs *treeset.Set - deps *treeset.Set - resolvedDeps *treeset.Set - visibility *treeset.Set - main *string - imports []string - testonly bool -} - -// newTargetBuilder constructs a new targetBuilder. -func newTargetBuilder(kind, name, pythonProjectRoot, bzlPackage string, siblingSrcs *treeset.Set) *targetBuilder { - return &targetBuilder{ - kind: kind, - name: name, - pythonProjectRoot: pythonProjectRoot, - bzlPackage: bzlPackage, - srcs: treeset.NewWith(godsutils.StringComparator), - siblingSrcs: siblingSrcs, - deps: treeset.NewWith(moduleComparator), - resolvedDeps: treeset.NewWith(godsutils.StringComparator), - visibility: treeset.NewWith(godsutils.StringComparator), - } -} - -// addSrc adds a single src to the target. -func (t *targetBuilder) addSrc(src string) *targetBuilder { - t.srcs.Add(src) - return t -} - -// addSrcs copies all values from the provided srcs to the target. -func (t *targetBuilder) addSrcs(srcs *treeset.Set) *targetBuilder { - it := srcs.Iterator() - for it.Next() { - t.srcs.Add(it.Value().(string)) - } - return t -} - -// addModuleDependency adds a single module dep to the target. -func (t *targetBuilder) addModuleDependency(dep module) *targetBuilder { - fileName := dep.Name + ".py" - if dep.From != "" { - fileName = dep.From + ".py" - } - if t.siblingSrcs.Contains(fileName) && fileName != filepath.Base(dep.Filepath) { - // importing another module from the same package, converting to absolute imports to make - // dependency resolution easier - dep.Name = importSpecFromSrc(t.pythonProjectRoot, t.bzlPackage, fileName).Imp - } - t.deps.Add(dep) - return t -} - -// addModuleDependencies copies all values from the provided deps to the target. -func (t *targetBuilder) addModuleDependencies(deps *treeset.Set) *targetBuilder { - it := deps.Iterator() - for it.Next() { - t.addModuleDependency(it.Value().(module)) - } - return t -} - -// addResolvedDependency adds a single dependency the target that has already -// been resolved or generated. The Resolver step doesn't process it further. -func (t *targetBuilder) addResolvedDependency(dep string) *targetBuilder { - t.resolvedDeps.Add(dep) - return t -} - -// addVisibility adds a visibility to the target. -func (t *targetBuilder) addVisibility(visibility string) *targetBuilder { - t.visibility.Add(visibility) - return t -} - -// setMain sets the main file to the target. -func (t *targetBuilder) setMain(main string) *targetBuilder { - t.main = &main - return t -} - -// setTestonly sets the testonly attribute to true. -func (t *targetBuilder) setTestonly() *targetBuilder { - t.testonly = true - return t -} - -// generateImportsAttribute generates the imports attribute. -// These are a list of import directories to be added to the PYTHONPATH. In our -// case, the value we add is on Bazel sub-packages to be able to perform imports -// relative to the root project package. -func (t *targetBuilder) generateImportsAttribute() *targetBuilder { - p, _ := filepath.Rel(t.bzlPackage, t.pythonProjectRoot) - p = filepath.Clean(p) - if p == "." { - return t - } - t.imports = []string{p} - return t -} - -// build returns the assembled *rule.Rule for the target. -func (t *targetBuilder) build() *rule.Rule { - r := rule.NewRule(t.kind, t.name) - if !t.srcs.Empty() { - r.SetAttr("srcs", t.srcs.Values()) - } - if !t.visibility.Empty() { - r.SetAttr("visibility", t.visibility.Values()) - } - if t.main != nil { - r.SetAttr("main", *t.main) - } - if t.imports != nil { - r.SetAttr("imports", t.imports) - } - if !t.deps.Empty() { - r.SetPrivateAttr(config.GazelleImportsKey, t.deps) - } - if t.testonly { - r.SetAttr("testonly", true) - } - r.SetPrivateAttr(resolvedDepsKey, t.resolvedDeps) - return r -} \ No newline at end of file diff --git a/gazelle/testdata/README.md b/gazelle/testdata/README.md deleted file mode 100644 index 6c25d4894c..0000000000 --- a/gazelle/testdata/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Gazelle Python extension test cases - -Each directory is a test case that contains `BUILD.in` and `BUILD.out` files for -assertion. `BUILD.in` is used as how the build file looks before running -Gazelle, and `BUILD.out` how the build file should look like after running -Gazelle. - -Each test case is a Bazel workspace and Gazelle will run with its working -directory set to the root of this workspace, though, the test runner will find -`test.yaml` files and use them to determine the directory Gazelle should use for -each inner Python project. The `test.yaml` file is a manifest for the test - -check for the existing ones for examples. diff --git a/gazelle/testdata/dependency_resolution_order/BUILD.in b/gazelle/testdata/dependency_resolution_order/BUILD.in deleted file mode 100644 index 71a5c5adda..0000000000 --- a/gazelle/testdata/dependency_resolution_order/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:resolve py bar //somewhere/bar diff --git a/gazelle/testdata/dependency_resolution_order/BUILD.out b/gazelle/testdata/dependency_resolution_order/BUILD.out deleted file mode 100644 index 2ba2c84c9a..0000000000 --- a/gazelle/testdata/dependency_resolution_order/BUILD.out +++ /dev/null @@ -1,14 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:resolve py bar //somewhere/bar - -py_library( - name = "dependency_resolution_order", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], - deps = [ - "//baz", - "//somewhere/bar", - "@gazelle_python_test//pypi__some_foo", - ], -) diff --git a/gazelle/testdata/dependency_resolution_order/README.md b/gazelle/testdata/dependency_resolution_order/README.md deleted file mode 100644 index 75ceb0b1b5..0000000000 --- a/gazelle/testdata/dependency_resolution_order/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Dependency resolution order - -This asserts that the generator resolves the dependencies in the right order: - -1. Explicit resolution via gazelle:resolve. -2. Third-party dependencies matching in the `modules_mapping.json`. -3. Indexed generated first-party dependencies. diff --git a/gazelle/testdata/dependency_resolution_order/WORKSPACE b/gazelle/testdata/dependency_resolution_order/WORKSPACE deleted file mode 100644 index 4959898cdd..0000000000 --- a/gazelle/testdata/dependency_resolution_order/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a test data Bazel workspace. diff --git a/gazelle/testdata/dependency_resolution_order/__init__.py b/gazelle/testdata/dependency_resolution_order/__init__.py deleted file mode 100644 index f2a1c081ad..0000000000 --- a/gazelle/testdata/dependency_resolution_order/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -import sys - -import bar -import baz -import foo - -_ = sys -_ = bar -_ = baz -_ = foo diff --git a/gazelle/testdata/dependency_resolution_order/bar/BUILD.in b/gazelle/testdata/dependency_resolution_order/bar/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/dependency_resolution_order/bar/BUILD.out b/gazelle/testdata/dependency_resolution_order/bar/BUILD.out deleted file mode 100644 index da9915ddbe..0000000000 --- a/gazelle/testdata/dependency_resolution_order/bar/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/dependency_resolution_order/bar/__init__.py b/gazelle/testdata/dependency_resolution_order/bar/__init__.py deleted file mode 100644 index 76c3313f0e..0000000000 --- a/gazelle/testdata/dependency_resolution_order/bar/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import os - -_ = os diff --git a/gazelle/testdata/dependency_resolution_order/baz/BUILD.in b/gazelle/testdata/dependency_resolution_order/baz/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/dependency_resolution_order/baz/BUILD.out b/gazelle/testdata/dependency_resolution_order/baz/BUILD.out deleted file mode 100644 index 749fd3d490..0000000000 --- a/gazelle/testdata/dependency_resolution_order/baz/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "baz", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/dependency_resolution_order/baz/__init__.py b/gazelle/testdata/dependency_resolution_order/baz/__init__.py deleted file mode 100644 index 76c3313f0e..0000000000 --- a/gazelle/testdata/dependency_resolution_order/baz/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import os - -_ = os diff --git a/gazelle/testdata/dependency_resolution_order/foo/BUILD.in b/gazelle/testdata/dependency_resolution_order/foo/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/dependency_resolution_order/foo/BUILD.out b/gazelle/testdata/dependency_resolution_order/foo/BUILD.out deleted file mode 100644 index 4404d30461..0000000000 --- a/gazelle/testdata/dependency_resolution_order/foo/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/dependency_resolution_order/foo/__init__.py b/gazelle/testdata/dependency_resolution_order/foo/__init__.py deleted file mode 100644 index 76c3313f0e..0000000000 --- a/gazelle/testdata/dependency_resolution_order/foo/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import os - -_ = os diff --git a/gazelle/testdata/dependency_resolution_order/gazelle_python.yaml b/gazelle/testdata/dependency_resolution_order/gazelle_python.yaml deleted file mode 100644 index 7e911bf29b..0000000000 --- a/gazelle/testdata/dependency_resolution_order/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - foo: some_foo - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.in b/gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.out b/gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.out deleted file mode 100644 index a0d421b8dc..0000000000 --- a/gazelle/testdata/dependency_resolution_order/somewhere/bar/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/dependency_resolution_order/somewhere/bar/__init__.py b/gazelle/testdata/dependency_resolution_order/somewhere/bar/__init__.py deleted file mode 100644 index 76c3313f0e..0000000000 --- a/gazelle/testdata/dependency_resolution_order/somewhere/bar/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import os - -_ = os diff --git a/gazelle/testdata/dependency_resolution_order/test.yaml b/gazelle/testdata/dependency_resolution_order/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/dependency_resolution_order/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/disable_import_statements_validation/BUILD.in b/gazelle/testdata/disable_import_statements_validation/BUILD.in deleted file mode 100644 index 741aff66ed..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_validate_import_statements false diff --git a/gazelle/testdata/disable_import_statements_validation/BUILD.out b/gazelle/testdata/disable_import_statements_validation/BUILD.out deleted file mode 100644 index 964db6d484..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_validate_import_statements false - -py_library( - name = "disable_import_statements_validation", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/disable_import_statements_validation/README.md b/gazelle/testdata/disable_import_statements_validation/README.md deleted file mode 100644 index a80fffec5e..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Disable import statements validation - -This test case asserts that the module's validation step is not performed. diff --git a/gazelle/testdata/disable_import_statements_validation/WORKSPACE b/gazelle/testdata/disable_import_statements_validation/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/disable_import_statements_validation/__init__.py b/gazelle/testdata/disable_import_statements_validation/__init__.py deleted file mode 100644 index 88eba74539..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import abcdefg - -_ = abcdefg diff --git a/gazelle/testdata/disable_import_statements_validation/test.yaml b/gazelle/testdata/disable_import_statements_validation/test.yaml deleted file mode 100644 index 36dd656b39..0000000000 --- a/gazelle/testdata/disable_import_statements_validation/test.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -expect: - exit_code: 0 diff --git a/gazelle/testdata/dont_rename_target/BUILD.in b/gazelle/testdata/dont_rename_target/BUILD.in deleted file mode 100644 index 33e8ec25cb..0000000000 --- a/gazelle/testdata/dont_rename_target/BUILD.in +++ /dev/null @@ -1,5 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "my_custom_target", -) diff --git a/gazelle/testdata/dont_rename_target/BUILD.out b/gazelle/testdata/dont_rename_target/BUILD.out deleted file mode 100644 index 62772e30b5..0000000000 --- a/gazelle/testdata/dont_rename_target/BUILD.out +++ /dev/null @@ -1,7 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "my_custom_target", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/dont_rename_target/README.md b/gazelle/testdata/dont_rename_target/README.md deleted file mode 100644 index 19f9d6637a..0000000000 --- a/gazelle/testdata/dont_rename_target/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Don't rename target - -This test case asserts that an existing target with a custom name doesn't get -renamed by the Gazelle extension. diff --git a/gazelle/testdata/dont_rename_target/WORKSPACE b/gazelle/testdata/dont_rename_target/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/dont_rename_target/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/dont_rename_target/__init__.py b/gazelle/testdata/dont_rename_target/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/dont_rename_target/test.yaml b/gazelle/testdata/dont_rename_target/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/dont_rename_target/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/file_name_matches_import_statement/BUILD.in b/gazelle/testdata/file_name_matches_import_statement/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/file_name_matches_import_statement/BUILD.out b/gazelle/testdata/file_name_matches_import_statement/BUILD.out deleted file mode 100644 index fd6c48559d..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "file_name_matches_import_statement", - srcs = [ - "__init__.py", - "rest_framework.py", - ], - visibility = ["//:__subpackages__"], - deps = ["@gazelle_python_test//pypi__djangorestframework"], -) diff --git a/gazelle/testdata/file_name_matches_import_statement/README.md b/gazelle/testdata/file_name_matches_import_statement/README.md deleted file mode 100644 index 591adc1c27..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# File name matches import statement - -This test case asserts that a file with an import statement that matches its own -name does the right thing of resolving the third-party package. diff --git a/gazelle/testdata/file_name_matches_import_statement/WORKSPACE b/gazelle/testdata/file_name_matches_import_statement/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/file_name_matches_import_statement/__init__.py b/gazelle/testdata/file_name_matches_import_statement/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/file_name_matches_import_statement/gazelle_python.yaml b/gazelle/testdata/file_name_matches_import_statement/gazelle_python.yaml deleted file mode 100644 index 63e6966941..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - rest_framework: djangorestframework - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/file_name_matches_import_statement/rest_framework.py b/gazelle/testdata/file_name_matches_import_statement/rest_framework.py deleted file mode 100644 index 9bede69c55..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/rest_framework.py +++ /dev/null @@ -1,3 +0,0 @@ -import rest_framework - -_ = rest_framework diff --git a/gazelle/testdata/file_name_matches_import_statement/test.yaml b/gazelle/testdata/file_name_matches_import_statement/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/file_name_matches_import_statement/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/first_party_dependencies/BUILD.in b/gazelle/testdata/first_party_dependencies/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/first_party_dependencies/BUILD.out b/gazelle/testdata/first_party_dependencies/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/first_party_dependencies/README.md b/gazelle/testdata/first_party_dependencies/README.md deleted file mode 100644 index f57e255fa7..0000000000 --- a/gazelle/testdata/first_party_dependencies/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# First-party dependencies - -There are 2 different scenarios that the extension needs to handle: - -1. Import statements that match sub-directory names. -2. Import statements that don't match sub-directory names and need a hint from - the user via directives. - -This test case asserts that the generated targets cover both scenarios. - -With the hint we need to check if it's a .py file or a directory with `__init__.py` file. diff --git a/gazelle/testdata/first_party_dependencies/WORKSPACE b/gazelle/testdata/first_party_dependencies/WORKSPACE deleted file mode 100644 index 4959898cdd..0000000000 --- a/gazelle/testdata/first_party_dependencies/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a test data Bazel workspace. diff --git a/gazelle/testdata/first_party_dependencies/one/BUILD.in b/gazelle/testdata/first_party_dependencies/one/BUILD.in deleted file mode 100644 index 6948b47b10..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_root diff --git a/gazelle/testdata/first_party_dependencies/one/BUILD.out b/gazelle/testdata/first_party_dependencies/one/BUILD.out deleted file mode 100644 index c96a56106d..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/BUILD.out +++ /dev/null @@ -1,15 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -# gazelle:python_root - -py_binary( - name = "one_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//one:__subpackages__"], - deps = [ - "//one/bar", - "//one/bar/baz", - "//one/foo", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/__main__.py b/gazelle/testdata/first_party_dependencies/one/__main__.py deleted file mode 100644 index 2d241cc41e..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/__main__.py +++ /dev/null @@ -1,12 +0,0 @@ -import os - -from bar import bar -from bar.baz import baz -from foo import foo - -if __name__ == "__main__": - INIT_FILENAME = "__init__.py" - dirname = os.path.dirname(os.path.abspath(__file__)) - assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) - assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) - assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/BUILD.in b/gazelle/testdata/first_party_dependencies/one/bar/BUILD.in deleted file mode 100644 index 7fe1f496d1..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/BUILD.in +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/BUILD.out b/gazelle/testdata/first_party_dependencies/one/bar/BUILD.out deleted file mode 100644 index 470bf82ce9..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - imports = [".."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/__init__.py b/gazelle/testdata/first_party_dependencies/one/bar/__init__.py deleted file mode 100644 index e311ff122a..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def bar(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.in b/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.in deleted file mode 100644 index 886a89cc3d..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.in +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "baz", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.out b/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.out deleted file mode 100644 index a0172452e1..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/baz/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "baz", - srcs = ["__init__.py"], - imports = ["../.."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/bar/baz/__init__.py b/gazelle/testdata/first_party_dependencies/one/bar/baz/__init__.py deleted file mode 100644 index e74f519643..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/bar/baz/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def baz(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/first_party_dependencies/one/foo/BUILD.in b/gazelle/testdata/first_party_dependencies/one/foo/BUILD.in deleted file mode 100644 index 0ee9a303bf..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/foo/BUILD.in +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - "//two:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/foo/BUILD.out b/gazelle/testdata/first_party_dependencies/one/foo/BUILD.out deleted file mode 100644 index 464fabb684..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/foo/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - imports = [".."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - "//two:__subpackages__", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/one/foo/__init__.py b/gazelle/testdata/first_party_dependencies/one/foo/__init__.py deleted file mode 100644 index 8aeca3de74..0000000000 --- a/gazelle/testdata/first_party_dependencies/one/foo/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def foo(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/first_party_dependencies/test.yaml b/gazelle/testdata/first_party_dependencies/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/first_party_dependencies/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/first_party_dependencies/three/BUILD.in b/gazelle/testdata/first_party_dependencies/three/BUILD.in deleted file mode 100644 index 6948b47b10..0000000000 --- a/gazelle/testdata/first_party_dependencies/three/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_root diff --git a/gazelle/testdata/first_party_dependencies/three/BUILD.out b/gazelle/testdata/first_party_dependencies/three/BUILD.out deleted file mode 100644 index ccfb3e0c08..0000000000 --- a/gazelle/testdata/first_party_dependencies/three/BUILD.out +++ /dev/null @@ -1,14 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_root - -py_library( - name = "three", - srcs = ["__init__.py"], - visibility = ["//three:__subpackages__"], - deps = [ - "//one/bar", - "//one/bar/baz", - "//one/foo", - ], -) diff --git a/gazelle/testdata/first_party_dependencies/three/__init__.py b/gazelle/testdata/first_party_dependencies/three/__init__.py deleted file mode 100644 index 41bec88fd3..0000000000 --- a/gazelle/testdata/first_party_dependencies/three/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -import os - -from bar import bar -from bar.baz import baz -from foo import foo - -_ = os -_ = bar -_ = baz -_ = foo diff --git a/gazelle/testdata/first_party_dependencies/two/BUILD.in b/gazelle/testdata/first_party_dependencies/two/BUILD.in deleted file mode 100644 index 6948b47b10..0000000000 --- a/gazelle/testdata/first_party_dependencies/two/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_root diff --git a/gazelle/testdata/first_party_dependencies/two/BUILD.out b/gazelle/testdata/first_party_dependencies/two/BUILD.out deleted file mode 100644 index 182db08f0e..0000000000 --- a/gazelle/testdata/first_party_dependencies/two/BUILD.out +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_root - -py_library( - name = "two", - srcs = ["__init__.py"], - visibility = ["//two:__subpackages__"], - deps = ["//one/foo"], -) diff --git a/gazelle/testdata/first_party_dependencies/two/__init__.py b/gazelle/testdata/first_party_dependencies/two/__init__.py deleted file mode 100644 index a0bb5c8715..0000000000 --- a/gazelle/testdata/first_party_dependencies/two/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -import os - -from foo import foo - -_ = os -_ = foo diff --git a/gazelle/testdata/first_party_file_and_directory_modules/BUILD.in b/gazelle/testdata/first_party_file_and_directory_modules/BUILD.in deleted file mode 100644 index fb90e4cbde..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:resolve py foo //foo diff --git a/gazelle/testdata/first_party_file_and_directory_modules/BUILD.out b/gazelle/testdata/first_party_file_and_directory_modules/BUILD.out deleted file mode 100644 index 264205b964..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/BUILD.out +++ /dev/null @@ -1,25 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -# gazelle:resolve py foo //foo - -py_library( - name = "first_party_file_and_directory_modules", - srcs = [ - "baz.py", - "foo.py", - ], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "first_party_file_and_directory_modules_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [ - ":first_party_file_and_directory_modules", - "//foo", - "//one", - "//undiscoverable/package1/subpackage1", - ], -) diff --git a/gazelle/testdata/first_party_file_and_directory_modules/README.md b/gazelle/testdata/first_party_file_and_directory_modules/README.md deleted file mode 100644 index 2a173b4305..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# First-party file and directory module dependencies - -This test case asserts that a `py_library` is generated with the dependencies -pointing to the correct first-party target that contains a Python module file -that was imported directly instead of a directory containing `__init__.py`. - -Also, it asserts that the directory with the `__init__.py` file is selected -instead of a module file with same. E.g. `foo/__init__.py` takes precedence over -`foo.py` when `import foo` exists. diff --git a/gazelle/testdata/first_party_file_and_directory_modules/WORKSPACE b/gazelle/testdata/first_party_file_and_directory_modules/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/first_party_file_and_directory_modules/__main__.py b/gazelle/testdata/first_party_file_and_directory_modules/__main__.py deleted file mode 100644 index acf5f10a71..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/__main__.py +++ /dev/null @@ -1,11 +0,0 @@ -import foo -from baz import baz as another_baz -from foo.bar import baz -from one.two import two -from package1.subpackage1.module1 import find_me - -assert not hasattr(foo, "foo") -assert baz() == "baz from foo/bar.py" -assert another_baz() == "baz from baz.py" -assert two() == "two" -assert find_me() == "found" diff --git a/gazelle/testdata/first_party_file_and_directory_modules/baz.py b/gazelle/testdata/first_party_file_and_directory_modules/baz.py deleted file mode 100644 index b161d6ab5e..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/baz.py +++ /dev/null @@ -1,2 +0,0 @@ -def baz(): - return "baz from baz.py" diff --git a/gazelle/testdata/first_party_file_and_directory_modules/foo.py b/gazelle/testdata/first_party_file_and_directory_modules/foo.py deleted file mode 100644 index af3cbda705..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/foo.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - print("foo") diff --git a/gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.in b/gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.out b/gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.out deleted file mode 100644 index 3decd902e0..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/foo/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = [ - "__init__.py", - "bar.py", - ], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//one"], -) diff --git a/gazelle/testdata/first_party_file_and_directory_modules/foo/__init__.py b/gazelle/testdata/first_party_file_and_directory_modules/foo/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/foo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/first_party_file_and_directory_modules/foo/bar.py b/gazelle/testdata/first_party_file_and_directory_modules/foo/bar.py deleted file mode 100644 index d6524cca2a..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/foo/bar.py +++ /dev/null @@ -1,7 +0,0 @@ -import one.two as two - -_ = two - - -def baz(): - return "baz from foo/bar.py" diff --git a/gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.in b/gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.out b/gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.out deleted file mode 100644 index 7063141808..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/one/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "one", - srcs = [ - "__init__.py", - "two.py", - ], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/first_party_file_and_directory_modules/one/__init__.py b/gazelle/testdata/first_party_file_and_directory_modules/one/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/one/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/first_party_file_and_directory_modules/one/two.py b/gazelle/testdata/first_party_file_and_directory_modules/one/two.py deleted file mode 100644 index 0020c44f2f..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/one/two.py +++ /dev/null @@ -1,2 +0,0 @@ -def two(): - return "two" diff --git a/gazelle/testdata/first_party_file_and_directory_modules/test.yaml b/gazelle/testdata/first_party_file_and_directory_modules/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in deleted file mode 100644 index 6948b47b10..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_root diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out deleted file mode 100644 index 6948b47b10..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_root diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in deleted file mode 100644 index c7d0e48a57..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.in +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "subpackage1", - srcs = [ - "__init__.py", - "module1.py", - ], - imports = ["../.."], - # Manual fix to visibility after initial generation. - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out deleted file mode 100644 index c7d0e48a57..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "subpackage1", - srcs = [ - "__init__.py", - "module1.py", - ], - imports = ["../.."], - # Manual fix to visibility after initial generation. - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py b/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py deleted file mode 100644 index 0ff1c4256c..0000000000 --- a/gazelle/testdata/first_party_file_and_directory_modules/undiscoverable/package1/subpackage1/module1.py +++ /dev/null @@ -1,2 +0,0 @@ -def find_me(): - return "found" diff --git a/gazelle/testdata/from_imports/BUILD.in b/gazelle/testdata/from_imports/BUILD.in deleted file mode 100644 index 93f2259140..0000000000 --- a/gazelle/testdata/from_imports/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_extension enabled diff --git a/gazelle/testdata/from_imports/BUILD.out b/gazelle/testdata/from_imports/BUILD.out deleted file mode 100644 index 93f2259140..0000000000 --- a/gazelle/testdata/from_imports/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_extension enabled diff --git a/gazelle/testdata/from_imports/README.md b/gazelle/testdata/from_imports/README.md deleted file mode 100644 index 161dd18e33..0000000000 --- a/gazelle/testdata/from_imports/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# From Imports - -This test case simulates imports of the form: - -```python -from foo import bar -``` diff --git a/gazelle/testdata/from_imports/WORKSPACE b/gazelle/testdata/from_imports/WORKSPACE deleted file mode 100644 index 4959898cdd..0000000000 --- a/gazelle/testdata/from_imports/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a test data Bazel workspace. diff --git a/gazelle/testdata/from_imports/foo/BUILD.in b/gazelle/testdata/from_imports/foo/BUILD.in deleted file mode 100644 index 8b13789179..0000000000 --- a/gazelle/testdata/from_imports/foo/BUILD.in +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gazelle/testdata/from_imports/foo/BUILD.out b/gazelle/testdata/from_imports/foo/BUILD.out deleted file mode 100644 index 4404d30461..0000000000 --- a/gazelle/testdata/from_imports/foo/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/from_imports/foo/__init__.py b/gazelle/testdata/from_imports/foo/__init__.py deleted file mode 100644 index 8c4ff6a255..0000000000 --- a/gazelle/testdata/from_imports/foo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -foo = "foo" diff --git a/gazelle/testdata/from_imports/foo/bar/BUILD.in b/gazelle/testdata/from_imports/foo/bar/BUILD.in deleted file mode 100644 index fbbec0284b..0000000000 --- a/gazelle/testdata/from_imports/foo/bar/BUILD.in +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_ignore_files baz.py - -py_library( - name = "baz", - srcs = [ - "baz.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) - -py_library( - name = "bar", - srcs = [ - "__init__.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/foo/bar/BUILD.out b/gazelle/testdata/from_imports/foo/bar/BUILD.out deleted file mode 100644 index fbbec0284b..0000000000 --- a/gazelle/testdata/from_imports/foo/bar/BUILD.out +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_ignore_files baz.py - -py_library( - name = "baz", - srcs = [ - "baz.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) - -py_library( - name = "bar", - srcs = [ - "__init__.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/foo/bar/__init__.py b/gazelle/testdata/from_imports/foo/bar/__init__.py deleted file mode 100644 index 2e96e096cc..0000000000 --- a/gazelle/testdata/from_imports/foo/bar/__init__.py +++ /dev/null @@ -1 +0,0 @@ -bar = "bar" diff --git a/gazelle/testdata/from_imports/foo/bar/baz.py b/gazelle/testdata/from_imports/foo/bar/baz.py deleted file mode 100644 index a15f053fe4..0000000000 --- a/gazelle/testdata/from_imports/foo/bar/baz.py +++ /dev/null @@ -1 +0,0 @@ -baz = "baz" diff --git a/gazelle/testdata/from_imports/gazelle_python.yaml b/gazelle/testdata/from_imports/gazelle_python.yaml deleted file mode 100644 index 5f7922f40f..0000000000 --- a/gazelle/testdata/from_imports/gazelle_python.yaml +++ /dev/null @@ -1,5 +0,0 @@ -manifest: - modules_mapping: - boto3: rootboto3 - boto4: rootboto4 - pip_deps_repository_name: root_pip_deps diff --git a/gazelle/testdata/from_imports/import_from_init_py/BUILD.in b/gazelle/testdata/from_imports/import_from_init_py/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_from_init_py/BUILD.out b/gazelle/testdata/from_imports/import_from_init_py/BUILD.out deleted file mode 100644 index 99b48610c2..0000000000 --- a/gazelle/testdata/from_imports/import_from_init_py/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_from_init_py", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//foo/bar"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_from_init_py/__init__.py b/gazelle/testdata/from_imports/import_from_init_py/__init__.py deleted file mode 100644 index 350a327d20..0000000000 --- a/gazelle/testdata/from_imports/import_from_init_py/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# bar is a variable inside foo/bar/__init__.py -from foo.bar import bar diff --git a/gazelle/testdata/from_imports/import_from_multiple/BUILD.in b/gazelle/testdata/from_imports/import_from_multiple/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_from_multiple/BUILD.out b/gazelle/testdata/from_imports/import_from_multiple/BUILD.out deleted file mode 100644 index d8219bb4d1..0000000000 --- a/gazelle/testdata/from_imports/import_from_multiple/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_from_multiple", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = [ - "//foo/bar", - "//foo/bar:baz", - ], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_from_multiple/__init__.py b/gazelle/testdata/from_imports/import_from_multiple/__init__.py deleted file mode 100644 index 864059b428..0000000000 --- a/gazelle/testdata/from_imports/import_from_multiple/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# Import multiple values from the same import. -from foo.bar import bar, baz diff --git a/gazelle/testdata/from_imports/import_nested_file/BUILD.in b/gazelle/testdata/from_imports/import_nested_file/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_nested_file/BUILD.out b/gazelle/testdata/from_imports/import_nested_file/BUILD.out deleted file mode 100644 index 662da9c9a0..0000000000 --- a/gazelle/testdata/from_imports/import_nested_file/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_nested_file", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//foo/bar:baz"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_nested_file/__init__.py b/gazelle/testdata/from_imports/import_nested_file/__init__.py deleted file mode 100644 index d5e6b2592b..0000000000 --- a/gazelle/testdata/from_imports/import_nested_file/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# baz.py is a file at foo/bar/baz.py -from foo.bar import baz diff --git a/gazelle/testdata/from_imports/import_nested_module/BUILD.in b/gazelle/testdata/from_imports/import_nested_module/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_nested_module/BUILD.out b/gazelle/testdata/from_imports/import_nested_module/BUILD.out deleted file mode 100644 index ec6da507dd..0000000000 --- a/gazelle/testdata/from_imports/import_nested_module/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_nested_module", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//foo/bar"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_nested_module/__init__.py b/gazelle/testdata/from_imports/import_nested_module/__init__.py deleted file mode 100644 index 3b04f00fed..0000000000 --- a/gazelle/testdata/from_imports/import_nested_module/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# bar is a module at foo/bar/__init__.py -from foo import bar diff --git a/gazelle/testdata/from_imports/import_nested_var/BUILD.in b/gazelle/testdata/from_imports/import_nested_var/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_nested_var/BUILD.out b/gazelle/testdata/from_imports/import_nested_var/BUILD.out deleted file mode 100644 index 8ee527e17a..0000000000 --- a/gazelle/testdata/from_imports/import_nested_var/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_nested_var", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//foo/bar:baz"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_nested_var/__init__.py b/gazelle/testdata/from_imports/import_nested_var/__init__.py deleted file mode 100644 index de5069d540..0000000000 --- a/gazelle/testdata/from_imports/import_nested_var/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# baz is a variable in foo/bar/baz.py -from foo.bar.baz import baz diff --git a/gazelle/testdata/from_imports/import_top_level_var/BUILD.in b/gazelle/testdata/from_imports/import_top_level_var/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/import_top_level_var/BUILD.out b/gazelle/testdata/from_imports/import_top_level_var/BUILD.out deleted file mode 100644 index 6b584d713b..0000000000 --- a/gazelle/testdata/from_imports/import_top_level_var/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "import_top_level_var", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], - deps = ["//foo"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/import_top_level_var/__init__.py b/gazelle/testdata/from_imports/import_top_level_var/__init__.py deleted file mode 100644 index 532f11a889..0000000000 --- a/gazelle/testdata/from_imports/import_top_level_var/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# foo is a variable in foo/__init__.py -from foo import foo diff --git a/gazelle/testdata/from_imports/std_module/BUILD.in b/gazelle/testdata/from_imports/std_module/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/from_imports/std_module/BUILD.out b/gazelle/testdata/from_imports/std_module/BUILD.out deleted file mode 100644 index 4903999afc..0000000000 --- a/gazelle/testdata/from_imports/std_module/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "std_module", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) \ No newline at end of file diff --git a/gazelle/testdata/from_imports/std_module/__init__.py b/gazelle/testdata/from_imports/std_module/__init__.py deleted file mode 100644 index 7e6bc9dc02..0000000000 --- a/gazelle/testdata/from_imports/std_module/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# Gazelle should recognize this from import -# as the standard module __future__. -from __future__ import print_function diff --git a/gazelle/testdata/from_imports/test.yaml b/gazelle/testdata/from_imports/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/from_imports/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/generated_test_entrypoint/BUILD.in b/gazelle/testdata/generated_test_entrypoint/BUILD.in deleted file mode 100644 index 06616fb1ae..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/BUILD.in +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -something( - name = "__test__", -) - -py_library( - name = "generated_test_entrypoint", - srcs = ["__init__.py"], -) diff --git a/gazelle/testdata/generated_test_entrypoint/BUILD.out b/gazelle/testdata/generated_test_entrypoint/BUILD.out deleted file mode 100644 index 48df0688a6..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/BUILD.out +++ /dev/null @@ -1,24 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") - -something( - name = "__test__", -) - -py_library( - name = "generated_test_entrypoint", - srcs = [ - "__init__.py", - "foo.py", - ], - visibility = ["//:__subpackages__"], -) - -py_test( - name = "generated_test_entrypoint_test", - srcs = [":__test__"], - main = ":__test__.py", - deps = [ - ":__test__", - ":generated_test_entrypoint", - ], -) diff --git a/gazelle/testdata/generated_test_entrypoint/README.md b/gazelle/testdata/generated_test_entrypoint/README.md deleted file mode 100644 index 69f8415999..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Generated test entrypoint - -This test case asserts that a `py_test` is generated using a target named -`__test__` as its `main` entrypoint. diff --git a/gazelle/testdata/generated_test_entrypoint/WORKSPACE b/gazelle/testdata/generated_test_entrypoint/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/generated_test_entrypoint/__init__.py b/gazelle/testdata/generated_test_entrypoint/__init__.py deleted file mode 100644 index 6a49193fe4..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from foo import foo - -_ = foo diff --git a/gazelle/testdata/generated_test_entrypoint/foo.py b/gazelle/testdata/generated_test_entrypoint/foo.py deleted file mode 100644 index cf68624419..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/foo.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "foo" diff --git a/gazelle/testdata/generated_test_entrypoint/test.yaml b/gazelle/testdata/generated_test_entrypoint/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/generated_test_entrypoint/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/ignored_invalid_imported_module/BUILD.in b/gazelle/testdata/ignored_invalid_imported_module/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/ignored_invalid_imported_module/BUILD.out b/gazelle/testdata/ignored_invalid_imported_module/BUILD.out deleted file mode 100644 index 3cd47a6fe0..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "ignored_invalid_imported_module", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], - deps = ["@gazelle_python_test//pypi__foo"], -) diff --git a/gazelle/testdata/ignored_invalid_imported_module/README.md b/gazelle/testdata/ignored_invalid_imported_module/README.md deleted file mode 100644 index 55dcc9bf7b..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Ignored invalid imported module - -This test case asserts that the module's validation step succeeds as expected. diff --git a/gazelle/testdata/ignored_invalid_imported_module/WORKSPACE b/gazelle/testdata/ignored_invalid_imported_module/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/ignored_invalid_imported_module/__init__.py b/gazelle/testdata/ignored_invalid_imported_module/__init__.py deleted file mode 100644 index 4301453aec..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# gazelle:ignore abcdefg1,abcdefg2 -# gazelle:ignore abcdefg3 - -import abcdefg1 -import abcdefg2 -import abcdefg3 -import foo - -_ = abcdefg1 -_ = abcdefg2 -_ = abcdefg3 -_ = foo - -try: - # gazelle:ignore grpc - import grpc - - grpc_available = True -except ImportError: - grpc_available = False - -_ = grpc diff --git a/gazelle/testdata/ignored_invalid_imported_module/gazelle_python.yaml b/gazelle/testdata/ignored_invalid_imported_module/gazelle_python.yaml deleted file mode 100644 index 54b3148810..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - foo: foo - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/ignored_invalid_imported_module/test.yaml b/gazelle/testdata/ignored_invalid_imported_module/test.yaml deleted file mode 100644 index 36dd656b39..0000000000 --- a/gazelle/testdata/ignored_invalid_imported_module/test.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -expect: - exit_code: 0 diff --git a/gazelle/testdata/invalid_imported_module/BUILD.in b/gazelle/testdata/invalid_imported_module/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/invalid_imported_module/BUILD.out b/gazelle/testdata/invalid_imported_module/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/invalid_imported_module/README.md b/gazelle/testdata/invalid_imported_module/README.md deleted file mode 100644 index 85e6f45954..0000000000 --- a/gazelle/testdata/invalid_imported_module/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Invalid imported module - -This test case asserts that the module's validation step fails as expected. diff --git a/gazelle/testdata/invalid_imported_module/WORKSPACE b/gazelle/testdata/invalid_imported_module/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/invalid_imported_module/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/invalid_imported_module/__init__.py b/gazelle/testdata/invalid_imported_module/__init__.py deleted file mode 100644 index c100931cc4..0000000000 --- a/gazelle/testdata/invalid_imported_module/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -try: - import grpc - - grpc_available = True -except ImportError: - grpc_available = False - -_ = grpc diff --git a/gazelle/testdata/invalid_imported_module/test.yaml b/gazelle/testdata/invalid_imported_module/test.yaml deleted file mode 100644 index f12c36b505..0000000000 --- a/gazelle/testdata/invalid_imported_module/test.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -expect: - exit_code: 1 - stderr: | - gazelle: ERROR: failed to validate dependencies for target "//:invalid_imported_module": "grpc" at line 2 from "__init__.py" is an invalid dependency: possible solutions: - 1. Add it as a dependency in the requirements.txt file. - 2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive. - 3. Ignore it with a comment '# gazelle:ignore grpc' in the Python file. diff --git a/gazelle/testdata/monorepo/BUILD.in b/gazelle/testdata/monorepo/BUILD.in deleted file mode 100644 index adc9e83069..0000000000 --- a/gazelle/testdata/monorepo/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_extension disabled diff --git a/gazelle/testdata/monorepo/BUILD.out b/gazelle/testdata/monorepo/BUILD.out deleted file mode 100644 index adc9e83069..0000000000 --- a/gazelle/testdata/monorepo/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_extension disabled diff --git a/gazelle/testdata/monorepo/README.md b/gazelle/testdata/monorepo/README.md deleted file mode 100644 index b3ac3d27bd..0000000000 --- a/gazelle/testdata/monorepo/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Monorepo - -This test case focuses on having multiple configurations tweaked in combination -to simulate a monorepo. diff --git a/gazelle/testdata/monorepo/WORKSPACE b/gazelle/testdata/monorepo/WORKSPACE deleted file mode 100644 index 4959898cdd..0000000000 --- a/gazelle/testdata/monorepo/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a test data Bazel workspace. diff --git a/gazelle/testdata/monorepo/coarse_grained/BUILD.in b/gazelle/testdata/monorepo/coarse_grained/BUILD.in deleted file mode 100644 index b85b32105e..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/BUILD.in +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:python_generation_mode project - -# gazelle:exclude bar/baz/*_excluded.py - -py_library( - name = "coarse_grained", - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/monorepo/coarse_grained/BUILD.out b/gazelle/testdata/monorepo/coarse_grained/BUILD.out deleted file mode 100644 index 0fba9515a1..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/BUILD.out +++ /dev/null @@ -1,20 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:python_generation_mode project - -# gazelle:exclude bar/baz/*_excluded.py - -py_library( - name = "coarse_grained", - srcs = [ - "__init__.py", - "bar/__init__.py", - "bar/baz/__init__.py", - "bar/baz/hue.py", - "foo/__init__.py", - ], - visibility = ["//:__subpackages__"], - deps = ["@root_pip_deps//pypi__rootboto3"], -) diff --git a/gazelle/testdata/monorepo/coarse_grained/__init__.py b/gazelle/testdata/monorepo/coarse_grained/__init__.py deleted file mode 100644 index 2b5b044257..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/__init__.py +++ /dev/null @@ -1,12 +0,0 @@ -import os - -import boto3 -from bar import bar -from bar.baz import baz -from foo import foo - -_ = os -_ = boto3 -_ = bar -_ = baz -_ = foo diff --git a/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.in b/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.in deleted file mode 100644 index 421b48688a..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_generation_mode package diff --git a/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.out b/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.out deleted file mode 100644 index 837e59f99e..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/_boundary/BUILD.out +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_generation_mode package - -py_library( - name = "_boundary", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//coarse_grained:__subpackages__"], -) diff --git a/gazelle/testdata/monorepo/coarse_grained/_boundary/README.md b/gazelle/testdata/monorepo/coarse_grained/_boundary/README.md deleted file mode 100644 index 0e67695af3..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/_boundary/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# \_boundary - -This Bazel package must be before other packages in the `coarse_grained` -directory so that we assert that walking the tree still happens after ignoring -this package from the parent coarse-grained generation. diff --git a/gazelle/testdata/monorepo/coarse_grained/_boundary/__init__.py b/gazelle/testdata/monorepo/coarse_grained/_boundary/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/coarse_grained/bar/__init__.py b/gazelle/testdata/monorepo/coarse_grained/bar/__init__.py deleted file mode 100644 index f6ec21462a..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/bar/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -import os - -import boto3 - -_ = boto3 - - -def bar(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/coarse_grained/bar/baz/__init__.py b/gazelle/testdata/monorepo/coarse_grained/bar/baz/__init__.py deleted file mode 100644 index e74f519643..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/bar/baz/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def baz(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py b/gazelle/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/bar/baz/first_excluded.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/monorepo/coarse_grained/bar/baz/hue.py b/gazelle/testdata/monorepo/coarse_grained/bar/baz/hue.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/bar/baz/hue.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py b/gazelle/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/bar/baz/second_excluded.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/monorepo/coarse_grained/foo/__init__.py b/gazelle/testdata/monorepo/coarse_grained/foo/__init__.py deleted file mode 100644 index 8aeca3de74..0000000000 --- a/gazelle/testdata/monorepo/coarse_grained/foo/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def foo(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/gazelle_python.yaml b/gazelle/testdata/monorepo/gazelle_python.yaml deleted file mode 100644 index 5f7922f40f..0000000000 --- a/gazelle/testdata/monorepo/gazelle_python.yaml +++ /dev/null @@ -1,5 +0,0 @@ -manifest: - modules_mapping: - boto3: rootboto3 - boto4: rootboto4 - pip_deps_repository_name: root_pip_deps diff --git a/gazelle/testdata/monorepo/one/BUILD.in b/gazelle/testdata/monorepo/one/BUILD.in deleted file mode 100644 index b11b373468..0000000000 --- a/gazelle/testdata/monorepo/one/BUILD.in +++ /dev/null @@ -1,2 +0,0 @@ -# gazelle:python_extension enabled -# gazelle:python_root diff --git a/gazelle/testdata/monorepo/one/BUILD.out b/gazelle/testdata/monorepo/one/BUILD.out deleted file mode 100644 index a957227a9a..0000000000 --- a/gazelle/testdata/monorepo/one/BUILD.out +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -# gazelle:python_extension enabled -# gazelle:python_root - -py_binary( - name = "one_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//one:__subpackages__"], - deps = [ - "//one/bar", - "//one/bar/baz:modified_name_baz", - "//one/foo", - "@one_pip_deps//pypi__oneboto3", - ], -) diff --git a/gazelle/testdata/monorepo/one/__main__.py b/gazelle/testdata/monorepo/one/__main__.py deleted file mode 100644 index f08f5e8009..0000000000 --- a/gazelle/testdata/monorepo/one/__main__.py +++ /dev/null @@ -1,15 +0,0 @@ -import os - -import boto3 -from bar import bar -from bar.baz import baz -from foo import foo - -_ = boto3 - -if __name__ == "__main__": - INIT_FILENAME = "__init__.py" - dirname = os.path.dirname(os.path.abspath(__file__)) - assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) - assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) - assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/testdata/monorepo/one/bar/BUILD.in b/gazelle/testdata/monorepo/one/bar/BUILD.in deleted file mode 100644 index 7fe1f496d1..0000000000 --- a/gazelle/testdata/monorepo/one/bar/BUILD.in +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/monorepo/one/bar/BUILD.out b/gazelle/testdata/monorepo/one/bar/BUILD.out deleted file mode 100644 index 0e85623394..0000000000 --- a/gazelle/testdata/monorepo/one/bar/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["__init__.py"], - imports = [".."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], - deps = ["@one_pip_deps//pypi__oneboto3"], -) diff --git a/gazelle/testdata/monorepo/one/bar/__init__.py b/gazelle/testdata/monorepo/one/bar/__init__.py deleted file mode 100644 index f6ec21462a..0000000000 --- a/gazelle/testdata/monorepo/one/bar/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -import os - -import boto3 - -_ = boto3 - - -def bar(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/one/bar/baz/BUILD.in b/gazelle/testdata/monorepo/one/bar/baz/BUILD.in deleted file mode 100644 index 00ba8ed974..0000000000 --- a/gazelle/testdata/monorepo/one/bar/baz/BUILD.in +++ /dev/null @@ -1,10 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "modified_name_baz", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/monorepo/one/bar/baz/BUILD.out b/gazelle/testdata/monorepo/one/bar/baz/BUILD.out deleted file mode 100644 index 1eb52fcf88..0000000000 --- a/gazelle/testdata/monorepo/one/bar/baz/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "modified_name_baz", - srcs = ["__init__.py"], - imports = ["../.."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - ], -) diff --git a/gazelle/testdata/monorepo/one/bar/baz/__init__.py b/gazelle/testdata/monorepo/one/bar/baz/__init__.py deleted file mode 100644 index e74f519643..0000000000 --- a/gazelle/testdata/monorepo/one/bar/baz/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def baz(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/one/foo/BUILD.in b/gazelle/testdata/monorepo/one/foo/BUILD.in deleted file mode 100644 index 0ee9a303bf..0000000000 --- a/gazelle/testdata/monorepo/one/foo/BUILD.in +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - "//two:__subpackages__", - ], -) diff --git a/gazelle/testdata/monorepo/one/foo/BUILD.out b/gazelle/testdata/monorepo/one/foo/BUILD.out deleted file mode 100644 index 464fabb684..0000000000 --- a/gazelle/testdata/monorepo/one/foo/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["__init__.py"], - imports = [".."], - visibility = [ - "//one:__subpackages__", - "//three:__subpackages__", - "//two:__subpackages__", - ], -) diff --git a/gazelle/testdata/monorepo/one/foo/__init__.py b/gazelle/testdata/monorepo/one/foo/__init__.py deleted file mode 100644 index 8aeca3de74..0000000000 --- a/gazelle/testdata/monorepo/one/foo/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def foo(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/one/gazelle_python.yaml b/gazelle/testdata/monorepo/one/gazelle_python.yaml deleted file mode 100644 index 67c53451b4..0000000000 --- a/gazelle/testdata/monorepo/one/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - boto3: oneboto3 - pip_deps_repository_name: one_pip_deps diff --git a/gazelle/testdata/monorepo/test.yaml b/gazelle/testdata/monorepo/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/monorepo/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/monorepo/three/BUILD.in b/gazelle/testdata/monorepo/three/BUILD.in deleted file mode 100644 index 79bb63fa49..0000000000 --- a/gazelle/testdata/monorepo/three/BUILD.in +++ /dev/null @@ -1,5 +0,0 @@ -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:resolve py bar //one/bar -# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz -# gazelle:resolve py foo //one/foo diff --git a/gazelle/testdata/monorepo/three/BUILD.out b/gazelle/testdata/monorepo/three/BUILD.out deleted file mode 100644 index 0da269d644..0000000000 --- a/gazelle/testdata/monorepo/three/BUILD.out +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:resolve py bar //one/bar -# gazelle:resolve py bar.baz //one/bar/baz:modified_name_baz -# gazelle:resolve py foo //one/foo - -py_library( - name = "three", - srcs = ["__init__.py"], - visibility = ["//three:__subpackages__"], - deps = [ - "//coarse_grained", - "//one/bar", - "//one/bar/baz:modified_name_baz", - "//one/foo", - "@root_pip_deps//pypi__rootboto4", - "@three_pip_deps_threeboto3//:pkg", - ], -) diff --git a/gazelle/testdata/monorepo/three/__init__.py b/gazelle/testdata/monorepo/three/__init__.py deleted file mode 100644 index 6f12bd8033..0000000000 --- a/gazelle/testdata/monorepo/three/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -import os - -import bar.baz.hue as hue -import boto3 -import boto4 -from bar import bar -from bar.baz import baz -from foo import foo - -_ = os -_ = boto3 -_ = boto4 -_ = bar -_ = baz -_ = foo -_ = hue diff --git a/gazelle/testdata/monorepo/three/gazelle_python.yaml b/gazelle/testdata/monorepo/three/gazelle_python.yaml deleted file mode 100644 index d46a88f444..0000000000 --- a/gazelle/testdata/monorepo/three/gazelle_python.yaml +++ /dev/null @@ -1,6 +0,0 @@ -manifest: - modules_mapping: - boto3: threeboto3 - pip_repository: - name: three_pip_deps - incremental: true diff --git a/gazelle/testdata/monorepo/two/BUILD.in b/gazelle/testdata/monorepo/two/BUILD.in deleted file mode 100644 index 31812e0535..0000000000 --- a/gazelle/testdata/monorepo/two/BUILD.in +++ /dev/null @@ -1,3 +0,0 @@ -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:resolve py foo //one/foo diff --git a/gazelle/testdata/monorepo/two/BUILD.out b/gazelle/testdata/monorepo/two/BUILD.out deleted file mode 100644 index 4b638edea2..0000000000 --- a/gazelle/testdata/monorepo/two/BUILD.out +++ /dev/null @@ -1,15 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_extension enabled -# gazelle:python_root -# gazelle:resolve py foo //one/foo - -py_library( - name = "two", - srcs = ["__init__.py"], - visibility = ["//two:__subpackages__"], - deps = [ - "//one/foo", - "@two_pip_deps//pypi__twoboto3", - ], -) diff --git a/gazelle/testdata/monorepo/two/__init__.py b/gazelle/testdata/monorepo/two/__init__.py deleted file mode 100644 index fb3e877fe5..0000000000 --- a/gazelle/testdata/monorepo/two/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -import os - -import boto3 -from foo import foo - -_ = os -_ = boto3 -_ = foo diff --git a/gazelle/testdata/monorepo/two/gazelle_python.yaml b/gazelle/testdata/monorepo/two/gazelle_python.yaml deleted file mode 100644 index 3bc5939e58..0000000000 --- a/gazelle/testdata/monorepo/two/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - boto3: twoboto3 - pip_deps_repository_name: two_pip_deps diff --git a/gazelle/testdata/monorepo/wont_generate/BUILD.in b/gazelle/testdata/monorepo/wont_generate/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/BUILD.out b/gazelle/testdata/monorepo/wont_generate/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/__main__.py b/gazelle/testdata/monorepo/wont_generate/__main__.py deleted file mode 100644 index 2d241cc41e..0000000000 --- a/gazelle/testdata/monorepo/wont_generate/__main__.py +++ /dev/null @@ -1,12 +0,0 @@ -import os - -from bar import bar -from bar.baz import baz -from foo import foo - -if __name__ == "__main__": - INIT_FILENAME = "__init__.py" - dirname = os.path.dirname(os.path.abspath(__file__)) - assert bar() == os.path.join(dirname, "bar", INIT_FILENAME) - assert baz() == os.path.join(dirname, "bar", "baz", INIT_FILENAME) - assert foo() == os.path.join(dirname, "foo", INIT_FILENAME) diff --git a/gazelle/testdata/monorepo/wont_generate/bar/BUILD.in b/gazelle/testdata/monorepo/wont_generate/bar/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/bar/BUILD.out b/gazelle/testdata/monorepo/wont_generate/bar/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/bar/__init__.py b/gazelle/testdata/monorepo/wont_generate/bar/__init__.py deleted file mode 100644 index e311ff122a..0000000000 --- a/gazelle/testdata/monorepo/wont_generate/bar/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def bar(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.in b/gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.out b/gazelle/testdata/monorepo/wont_generate/bar/baz/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/bar/baz/__init__.py b/gazelle/testdata/monorepo/wont_generate/bar/baz/__init__.py deleted file mode 100644 index e74f519643..0000000000 --- a/gazelle/testdata/monorepo/wont_generate/bar/baz/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def baz(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/monorepo/wont_generate/foo/BUILD.in b/gazelle/testdata/monorepo/wont_generate/foo/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/foo/BUILD.out b/gazelle/testdata/monorepo/wont_generate/foo/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/monorepo/wont_generate/foo/__init__.py b/gazelle/testdata/monorepo/wont_generate/foo/__init__.py deleted file mode 100644 index 8aeca3de74..0000000000 --- a/gazelle/testdata/monorepo/wont_generate/foo/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os - - -def foo(): - return os.path.abspath(__file__) diff --git a/gazelle/testdata/naming_convention/BUILD.in b/gazelle/testdata/naming_convention/BUILD.in deleted file mode 100644 index 7517848a92..0000000000 --- a/gazelle/testdata/naming_convention/BUILD.in +++ /dev/null @@ -1,3 +0,0 @@ -# gazelle:python_library_naming_convention my_$package_name$_library -# gazelle:python_binary_naming_convention my_$package_name$_binary -# gazelle:python_test_naming_convention my_$package_name$_test diff --git a/gazelle/testdata/naming_convention/BUILD.out b/gazelle/testdata/naming_convention/BUILD.out deleted file mode 100644 index e2f067489c..0000000000 --- a/gazelle/testdata/naming_convention/BUILD.out +++ /dev/null @@ -1,26 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") - -# gazelle:python_library_naming_convention my_$package_name$_library -# gazelle:python_binary_naming_convention my_$package_name$_binary -# gazelle:python_test_naming_convention my_$package_name$_test - -py_library( - name = "my_naming_convention_library", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "my_naming_convention_binary", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [":my_naming_convention_library"], -) - -py_test( - name = "my_naming_convention_test", - srcs = ["__test__.py"], - main = "__test__.py", - deps = [":my_naming_convention_library"], -) diff --git a/gazelle/testdata/naming_convention/README.md b/gazelle/testdata/naming_convention/README.md deleted file mode 100644 index 9dd88ecd24..0000000000 --- a/gazelle/testdata/naming_convention/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Naming convention - -This test case asserts that py\_{library,binary,test} targets are generated -correctly based on the directives that control their naming conventions. diff --git a/gazelle/testdata/naming_convention/WORKSPACE b/gazelle/testdata/naming_convention/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/naming_convention/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/naming_convention/__init__.py b/gazelle/testdata/naming_convention/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/__main__.py b/gazelle/testdata/naming_convention/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/__test__.py b/gazelle/testdata/naming_convention/__test__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/__test__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/dont_rename/BUILD.in b/gazelle/testdata/naming_convention/dont_rename/BUILD.in deleted file mode 100644 index 8d2ae35fd4..0000000000 --- a/gazelle/testdata/naming_convention/dont_rename/BUILD.in +++ /dev/null @@ -1,7 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") - -py_library( - name = "dont_rename", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/naming_convention/dont_rename/BUILD.out b/gazelle/testdata/naming_convention/dont_rename/BUILD.out deleted file mode 100644 index 4d4ead86b4..0000000000 --- a/gazelle/testdata/naming_convention/dont_rename/BUILD.out +++ /dev/null @@ -1,25 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") - -py_library( - name = "dont_rename", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "my_dont_rename_binary", - srcs = ["__main__.py"], - imports = [".."], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [":dont_rename"], -) - -py_test( - name = "my_dont_rename_test", - srcs = ["__test__.py"], - imports = [".."], - main = "__test__.py", - deps = [":dont_rename"], -) diff --git a/gazelle/testdata/naming_convention/dont_rename/__init__.py b/gazelle/testdata/naming_convention/dont_rename/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/dont_rename/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/dont_rename/__main__.py b/gazelle/testdata/naming_convention/dont_rename/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/dont_rename/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/dont_rename/__test__.py b/gazelle/testdata/naming_convention/dont_rename/__test__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/dont_rename/__test__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/resolve_conflict/BUILD.in b/gazelle/testdata/naming_convention/resolve_conflict/BUILD.in deleted file mode 100644 index c81e735d7e..0000000000 --- a/gazelle/testdata/naming_convention/resolve_conflict/BUILD.in +++ /dev/null @@ -1,5 +0,0 @@ -go_library(name = "resolve_conflict") - -go_binary(name = "resolve_conflict_bin") - -go_test(name = "resolve_conflict_test") diff --git a/gazelle/testdata/naming_convention/resolve_conflict/BUILD.out b/gazelle/testdata/naming_convention/resolve_conflict/BUILD.out deleted file mode 100644 index 3fa5de2b79..0000000000 --- a/gazelle/testdata/naming_convention/resolve_conflict/BUILD.out +++ /dev/null @@ -1,31 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") - -go_library(name = "resolve_conflict") - -go_binary(name = "resolve_conflict_bin") - -go_test(name = "resolve_conflict_test") - -py_library( - name = "my_resolve_conflict_library", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "my_resolve_conflict_binary", - srcs = ["__main__.py"], - imports = [".."], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [":my_resolve_conflict_library"], -) - -py_test( - name = "my_resolve_conflict_test", - srcs = ["__test__.py"], - imports = [".."], - main = "__test__.py", - deps = [":my_resolve_conflict_library"], -) diff --git a/gazelle/testdata/naming_convention/resolve_conflict/__init__.py b/gazelle/testdata/naming_convention/resolve_conflict/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/resolve_conflict/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/resolve_conflict/__main__.py b/gazelle/testdata/naming_convention/resolve_conflict/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/resolve_conflict/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/resolve_conflict/__test__.py b/gazelle/testdata/naming_convention/resolve_conflict/__test__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention/resolve_conflict/__test__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention/test.yaml b/gazelle/testdata/naming_convention/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/naming_convention/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/naming_convention_binary_fail/BUILD.in b/gazelle/testdata/naming_convention_binary_fail/BUILD.in deleted file mode 100644 index fd4dc1c5b7..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -go_binary(name = "naming_convention_binary_fail_bin") diff --git a/gazelle/testdata/naming_convention_binary_fail/BUILD.out b/gazelle/testdata/naming_convention_binary_fail/BUILD.out deleted file mode 100644 index fd4dc1c5b7..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -go_binary(name = "naming_convention_binary_fail_bin") diff --git a/gazelle/testdata/naming_convention_binary_fail/README.md b/gazelle/testdata/naming_convention_binary_fail/README.md deleted file mode 100644 index a58bbe45dd..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Naming convention py_binary fail - -This test case asserts that a py_binary is not generated due to a naming conflict -with existing target. diff --git a/gazelle/testdata/naming_convention_binary_fail/WORKSPACE b/gazelle/testdata/naming_convention_binary_fail/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/naming_convention_binary_fail/__main__.py b/gazelle/testdata/naming_convention_binary_fail/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention_binary_fail/test.yaml b/gazelle/testdata/naming_convention_binary_fail/test.yaml deleted file mode 100644 index bc30dd0858..0000000000 --- a/gazelle/testdata/naming_convention_binary_fail/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -expect: - exit_code: 1 - stderr: > - gazelle: ERROR: failed to generate target "//:naming_convention_binary_fail_bin" of kind "py_binary": - a target of kind "go_binary" with the same name already exists. - Use the '# gazelle:python_binary_naming_convention' directive to change the naming convention. diff --git a/gazelle/testdata/naming_convention_library_fail/BUILD.in b/gazelle/testdata/naming_convention_library_fail/BUILD.in deleted file mode 100644 index a6840843c1..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -go_library(name = "naming_convention_library_fail") diff --git a/gazelle/testdata/naming_convention_library_fail/BUILD.out b/gazelle/testdata/naming_convention_library_fail/BUILD.out deleted file mode 100644 index a6840843c1..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -go_library(name = "naming_convention_library_fail") diff --git a/gazelle/testdata/naming_convention_library_fail/README.md b/gazelle/testdata/naming_convention_library_fail/README.md deleted file mode 100644 index cd36917251..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Naming convention py_library fail - -This test case asserts that a py_library is not generated due to a naming conflict -with existing target. diff --git a/gazelle/testdata/naming_convention_library_fail/WORKSPACE b/gazelle/testdata/naming_convention_library_fail/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/naming_convention_library_fail/__init__.py b/gazelle/testdata/naming_convention_library_fail/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention_library_fail/test.yaml b/gazelle/testdata/naming_convention_library_fail/test.yaml deleted file mode 100644 index 3743c324df..0000000000 --- a/gazelle/testdata/naming_convention_library_fail/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -expect: - exit_code: 1 - stderr: > - gazelle: ERROR: failed to generate target "//:naming_convention_library_fail" of kind "py_library": - a target of kind "go_library" with the same name already exists. - Use the '# gazelle:python_library_naming_convention' directive to change the naming convention. diff --git a/gazelle/testdata/naming_convention_test_fail/BUILD.in b/gazelle/testdata/naming_convention_test_fail/BUILD.in deleted file mode 100644 index 2091253114..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -go_test(name = "naming_convention_test_fail_test") diff --git a/gazelle/testdata/naming_convention_test_fail/BUILD.out b/gazelle/testdata/naming_convention_test_fail/BUILD.out deleted file mode 100644 index 2091253114..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -go_test(name = "naming_convention_test_fail_test") diff --git a/gazelle/testdata/naming_convention_test_fail/README.md b/gazelle/testdata/naming_convention_test_fail/README.md deleted file mode 100644 index 886c1e368c..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Naming convention py_test fail - -This test case asserts that a py_test is not generated due to a naming conflict -with existing target. diff --git a/gazelle/testdata/naming_convention_test_fail/WORKSPACE b/gazelle/testdata/naming_convention_test_fail/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/naming_convention_test_fail/__test__.py b/gazelle/testdata/naming_convention_test_fail/__test__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/__test__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/naming_convention_test_fail/test.yaml b/gazelle/testdata/naming_convention_test_fail/test.yaml deleted file mode 100644 index fc4e24e830..0000000000 --- a/gazelle/testdata/naming_convention_test_fail/test.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -expect: - exit_code: 1 - stderr: > - gazelle: ERROR: failed to generate target "//:naming_convention_test_fail_test" of kind "py_test": - a target of kind "go_test" with the same name already exists. - Use the '# gazelle:python_test_naming_convention' directive to change the naming convention. diff --git a/gazelle/testdata/python_ignore_dependencies_directive/BUILD.in b/gazelle/testdata/python_ignore_dependencies_directive/BUILD.in deleted file mode 100644 index 1ba277afbb..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/BUILD.in +++ /dev/null @@ -1,2 +0,0 @@ -# gazelle:python_ignore_dependencies foo,bar, baz -# gazelle:python_ignore_dependencies foo.bar.baz diff --git a/gazelle/testdata/python_ignore_dependencies_directive/BUILD.out b/gazelle/testdata/python_ignore_dependencies_directive/BUILD.out deleted file mode 100644 index 37ae4f9aa1..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_ignore_dependencies foo,bar, baz -# gazelle:python_ignore_dependencies foo.bar.baz - -py_library( - name = "python_ignore_dependencies_directive", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], - deps = ["@gazelle_python_test//pypi__boto3"], -) diff --git a/gazelle/testdata/python_ignore_dependencies_directive/README.md b/gazelle/testdata/python_ignore_dependencies_directive/README.md deleted file mode 100644 index 75f61e1baf..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# python_ignore_dependencies directive - -This test case asserts that the target is generated ignoring some of the -dependencies. diff --git a/gazelle/testdata/python_ignore_dependencies_directive/WORKSPACE b/gazelle/testdata/python_ignore_dependencies_directive/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/python_ignore_dependencies_directive/__init__.py b/gazelle/testdata/python_ignore_dependencies_directive/__init__.py deleted file mode 100644 index 79935a70c4..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -import bar -import boto3 -import foo -import foo.bar.baz -from baz import baz as bazfn - -_ = foo -_ = bar -_ = bazfn -_ = baz -_ = boto3 diff --git a/gazelle/testdata/python_ignore_dependencies_directive/gazelle_python.yaml b/gazelle/testdata/python_ignore_dependencies_directive/gazelle_python.yaml deleted file mode 100644 index 7288b798e1..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - boto3: boto3 - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/python_ignore_dependencies_directive/test.yaml b/gazelle/testdata/python_ignore_dependencies_directive/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/python_ignore_dependencies_directive/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/python_ignore_files_directive/BUILD.in b/gazelle/testdata/python_ignore_files_directive/BUILD.in deleted file mode 100644 index 6277446576..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_ignore_files some_other.py diff --git a/gazelle/testdata/python_ignore_files_directive/BUILD.out b/gazelle/testdata/python_ignore_files_directive/BUILD.out deleted file mode 100644 index 1fe6030053..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/BUILD.out +++ /dev/null @@ -1,9 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -# gazelle:python_ignore_files some_other.py - -py_library( - name = "python_ignore_files_directive", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/python_ignore_files_directive/README.md b/gazelle/testdata/python_ignore_files_directive/README.md deleted file mode 100644 index 710118d6a4..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# python_ignore_files directive - -This test case asserts that no targets are generated for ignored files. diff --git a/gazelle/testdata/python_ignore_files_directive/WORKSPACE b/gazelle/testdata/python_ignore_files_directive/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/python_ignore_files_directive/__init__.py b/gazelle/testdata/python_ignore_files_directive/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/bar/BUILD.in b/gazelle/testdata/python_ignore_files_directive/bar/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/python_ignore_files_directive/bar/BUILD.out b/gazelle/testdata/python_ignore_files_directive/bar/BUILD.out deleted file mode 100644 index af3c3983db..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/bar/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "bar", - srcs = ["baz.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/python_ignore_files_directive/bar/baz.py b/gazelle/testdata/python_ignore_files_directive/bar/baz.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/bar/baz.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/bar/some_other.py b/gazelle/testdata/python_ignore_files_directive/bar/some_other.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/bar/some_other.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/foo/BUILD.in b/gazelle/testdata/python_ignore_files_directive/foo/BUILD.in deleted file mode 100644 index c3049cabf5..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/foo/BUILD.in +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_ignore_files baz.py diff --git a/gazelle/testdata/python_ignore_files_directive/foo/BUILD.out b/gazelle/testdata/python_ignore_files_directive/foo/BUILD.out deleted file mode 100644 index c3049cabf5..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/foo/BUILD.out +++ /dev/null @@ -1 +0,0 @@ -# gazelle:python_ignore_files baz.py diff --git a/gazelle/testdata/python_ignore_files_directive/foo/baz.py b/gazelle/testdata/python_ignore_files_directive/foo/baz.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/foo/baz.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/setup.py b/gazelle/testdata/python_ignore_files_directive/setup.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/setup.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/some_other.py b/gazelle/testdata/python_ignore_files_directive/some_other.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/some_other.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_ignore_files_directive/test.yaml b/gazelle/testdata/python_ignore_files_directive/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/python_ignore_files_directive/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/python_target_with_test_in_name/BUILD.in b/gazelle/testdata/python_target_with_test_in_name/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/python_target_with_test_in_name/BUILD.out b/gazelle/testdata/python_target_with_test_in_name/BUILD.out deleted file mode 100644 index bdde605c09..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "python_target_with_test_in_name", - srcs = [ - "__init__.py", - "not_a_real_test.py", - "test_not_a_real.py", - ], - visibility = ["//:__subpackages__"], - deps = ["@gazelle_python_test//pypi__boto3"], -) diff --git a/gazelle/testdata/python_target_with_test_in_name/README.md b/gazelle/testdata/python_target_with_test_in_name/README.md deleted file mode 100644 index 8b592e10a7..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Python target with test in name - -Cover the case where a python file either starts with `test_` or ends with `_test`, but is not an actual test. diff --git a/gazelle/testdata/python_target_with_test_in_name/WORKSPACE b/gazelle/testdata/python_target_with_test_in_name/WORKSPACE deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/python_target_with_test_in_name/__init__.py b/gazelle/testdata/python_target_with_test_in_name/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/python_target_with_test_in_name/gazelle_python.yaml b/gazelle/testdata/python_target_with_test_in_name/gazelle_python.yaml deleted file mode 100644 index 7288b798e1..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - boto3: boto3 - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/python_target_with_test_in_name/not_a_real_test.py b/gazelle/testdata/python_target_with_test_in_name/not_a_real_test.py deleted file mode 100644 index 57c019daab..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/not_a_real_test.py +++ /dev/null @@ -1,3 +0,0 @@ -import boto3 - -_ = boto3 diff --git a/gazelle/testdata/python_target_with_test_in_name/test.yaml b/gazelle/testdata/python_target_with_test_in_name/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/python_target_with_test_in_name/test_not_a_real.py b/gazelle/testdata/python_target_with_test_in_name/test_not_a_real.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/python_target_with_test_in_name/test_not_a_real.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/relative_imports/BUILD.in b/gazelle/testdata/relative_imports/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/relative_imports/BUILD.out b/gazelle/testdata/relative_imports/BUILD.out deleted file mode 100644 index 2c0862748b..0000000000 --- a/gazelle/testdata/relative_imports/BUILD.out +++ /dev/null @@ -1,21 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -py_library( - name = "relative_imports", - srcs = [ - "package1/module1.py", - "package1/module2.py", - ], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "relative_imports_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [ - ":relative_imports", - "//package2", - ], -) diff --git a/gazelle/testdata/relative_imports/README.md b/gazelle/testdata/relative_imports/README.md deleted file mode 100644 index 1937cbcf4a..0000000000 --- a/gazelle/testdata/relative_imports/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Relative imports - -This test case asserts that the generated targets handle relative imports in -Python correctly. diff --git a/gazelle/testdata/relative_imports/WORKSPACE b/gazelle/testdata/relative_imports/WORKSPACE deleted file mode 100644 index 4959898cdd..0000000000 --- a/gazelle/testdata/relative_imports/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a test data Bazel workspace. diff --git a/gazelle/testdata/relative_imports/__main__.py b/gazelle/testdata/relative_imports/__main__.py deleted file mode 100644 index 4fb887a803..0000000000 --- a/gazelle/testdata/relative_imports/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -from package1.module1 import function1 -from package2.module3 import function3 - -print(function1()) -print(function3()) diff --git a/gazelle/testdata/relative_imports/package1/module1.py b/gazelle/testdata/relative_imports/package1/module1.py deleted file mode 100644 index 69cdde2633..0000000000 --- a/gazelle/testdata/relative_imports/package1/module1.py +++ /dev/null @@ -1,5 +0,0 @@ -from .module2 import function2 - - -def function1(): - return "function1 " + function2() diff --git a/gazelle/testdata/relative_imports/package1/module2.py b/gazelle/testdata/relative_imports/package1/module2.py deleted file mode 100644 index 1e731b4ec1..0000000000 --- a/gazelle/testdata/relative_imports/package1/module2.py +++ /dev/null @@ -1,2 +0,0 @@ -def function2(): - return "function2" diff --git a/gazelle/testdata/relative_imports/package2/BUILD.in b/gazelle/testdata/relative_imports/package2/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/relative_imports/package2/BUILD.out b/gazelle/testdata/relative_imports/package2/BUILD.out deleted file mode 100644 index bbbc9f8e95..0000000000 --- a/gazelle/testdata/relative_imports/package2/BUILD.out +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "package2", - srcs = [ - "__init__.py", - "module3.py", - "module4.py", - "subpackage1/module5.py", - ], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/relative_imports/package2/__init__.py b/gazelle/testdata/relative_imports/package2/__init__.py deleted file mode 100644 index fd0384ba7e..0000000000 --- a/gazelle/testdata/relative_imports/package2/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -class Class1: - def method1(self): - return "method1" diff --git a/gazelle/testdata/relative_imports/package2/module3.py b/gazelle/testdata/relative_imports/package2/module3.py deleted file mode 100644 index a5102dd8bd..0000000000 --- a/gazelle/testdata/relative_imports/package2/module3.py +++ /dev/null @@ -1,7 +0,0 @@ -from . import Class1 -from .subpackage1.module5 import function5 - - -def function3(): - c1 = Class1() - return "function3 " + c1.method1() + " " + function5() diff --git a/gazelle/testdata/relative_imports/package2/module4.py b/gazelle/testdata/relative_imports/package2/module4.py deleted file mode 100644 index 6e69699985..0000000000 --- a/gazelle/testdata/relative_imports/package2/module4.py +++ /dev/null @@ -1,2 +0,0 @@ -def function4(): - return "function4" diff --git a/gazelle/testdata/relative_imports/package2/subpackage1/module5.py b/gazelle/testdata/relative_imports/package2/subpackage1/module5.py deleted file mode 100644 index ac1f7257df..0000000000 --- a/gazelle/testdata/relative_imports/package2/subpackage1/module5.py +++ /dev/null @@ -1,5 +0,0 @@ -from ..module4 import function4 - - -def function5(): - return "function5 " + function4() diff --git a/gazelle/testdata/relative_imports/test.yaml b/gazelle/testdata/relative_imports/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/relative_imports/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/simple_binary/BUILD.in b/gazelle/testdata/simple_binary/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/simple_binary/BUILD.out b/gazelle/testdata/simple_binary/BUILD.out deleted file mode 100644 index 35aa7089ec..0000000000 --- a/gazelle/testdata/simple_binary/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "simple_binary_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/simple_binary/README.md b/gazelle/testdata/simple_binary/README.md deleted file mode 100644 index 00c90dcf65..0000000000 --- a/gazelle/testdata/simple_binary/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Simple binary - -This test case asserts that a simple `py_binary` is generated as expected. diff --git a/gazelle/testdata/simple_binary/WORKSPACE b/gazelle/testdata/simple_binary/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/simple_binary/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/simple_binary/__main__.py b/gazelle/testdata/simple_binary/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_binary/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_binary/test.yaml b/gazelle/testdata/simple_binary/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/simple_binary/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/simple_binary_with_library/BUILD.in b/gazelle/testdata/simple_binary_with_library/BUILD.in deleted file mode 100644 index b60e84f17e..0000000000 --- a/gazelle/testdata/simple_binary_with_library/BUILD.in +++ /dev/null @@ -1,18 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "simple_binary_with_library", - srcs = [ - "__init__.py", - "bar.py", - "foo.py", - ], -) - -# This target should be kept unmodified by Gazelle. -py_library( - name = "custom", - srcs = [ - "bar.py", - ], -) diff --git a/gazelle/testdata/simple_binary_with_library/BUILD.out b/gazelle/testdata/simple_binary_with_library/BUILD.out deleted file mode 100644 index eddc15cacd..0000000000 --- a/gazelle/testdata/simple_binary_with_library/BUILD.out +++ /dev/null @@ -1,27 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -py_library( - name = "simple_binary_with_library", - srcs = [ - "__init__.py", - "bar.py", - "foo.py", - ], - visibility = ["//:__subpackages__"], -) - -# This target should be kept unmodified by Gazelle. -py_library( - name = "custom", - srcs = [ - "bar.py", - ], -) - -py_binary( - name = "simple_binary_with_library_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [":simple_binary_with_library"], -) diff --git a/gazelle/testdata/simple_binary_with_library/README.md b/gazelle/testdata/simple_binary_with_library/README.md deleted file mode 100644 index cfc81a3581..0000000000 --- a/gazelle/testdata/simple_binary_with_library/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Simple binary with library - -This test case asserts that a simple `py_binary` is generated as expected -referencing a `py_library`. diff --git a/gazelle/testdata/simple_binary_with_library/WORKSPACE b/gazelle/testdata/simple_binary_with_library/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/simple_binary_with_library/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/simple_binary_with_library/__init__.py b/gazelle/testdata/simple_binary_with_library/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_binary_with_library/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_binary_with_library/__main__.py b/gazelle/testdata/simple_binary_with_library/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_binary_with_library/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_binary_with_library/bar.py b/gazelle/testdata/simple_binary_with_library/bar.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_binary_with_library/bar.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_binary_with_library/foo.py b/gazelle/testdata/simple_binary_with_library/foo.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_binary_with_library/foo.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_binary_with_library/test.yaml b/gazelle/testdata/simple_binary_with_library/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/simple_binary_with_library/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/simple_library/BUILD.in b/gazelle/testdata/simple_library/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/simple_library/BUILD.out b/gazelle/testdata/simple_library/BUILD.out deleted file mode 100644 index 5793ac2066..0000000000 --- a/gazelle/testdata/simple_library/BUILD.out +++ /dev/null @@ -1,7 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "simple_library", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/simple_library/README.md b/gazelle/testdata/simple_library/README.md deleted file mode 100644 index f88bda1ba1..0000000000 --- a/gazelle/testdata/simple_library/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Simple library - -This test case asserts that a simple `py_library` is generated as expected. diff --git a/gazelle/testdata/simple_library/WORKSPACE b/gazelle/testdata/simple_library/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/simple_library/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/simple_library/__init__.py b/gazelle/testdata/simple_library/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_library/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_library/test.yaml b/gazelle/testdata/simple_library/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/simple_library/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/simple_library_without_init/BUILD.in b/gazelle/testdata/simple_library_without_init/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/simple_library_without_init/BUILD.out b/gazelle/testdata/simple_library_without_init/BUILD.out deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/simple_library_without_init/README.md b/gazelle/testdata/simple_library_without_init/README.md deleted file mode 100644 index 5c0a1cad9f..0000000000 --- a/gazelle/testdata/simple_library_without_init/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Simple library without `__init__.py` - -This test case asserts that a simple `py_library` is generated as expected -without an `__init__.py` but with a `BUILD` file marking it as a package. diff --git a/gazelle/testdata/simple_library_without_init/WORKSPACE b/gazelle/testdata/simple_library_without_init/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/simple_library_without_init/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/simple_library_without_init/foo/BUILD.in b/gazelle/testdata/simple_library_without_init/foo/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/simple_library_without_init/foo/BUILD.out b/gazelle/testdata/simple_library_without_init/foo/BUILD.out deleted file mode 100644 index 2faa046fc1..0000000000 --- a/gazelle/testdata/simple_library_without_init/foo/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = ["foo.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/simple_library_without_init/foo/foo.py b/gazelle/testdata/simple_library_without_init/foo/foo.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/simple_library_without_init/foo/foo.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/simple_library_without_init/test.yaml b/gazelle/testdata/simple_library_without_init/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/simple_library_without_init/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/simple_test/BUILD.in b/gazelle/testdata/simple_test/BUILD.in deleted file mode 100644 index ffd20ea85d..0000000000 --- a/gazelle/testdata/simple_test/BUILD.in +++ /dev/null @@ -1,6 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "simple_test", - srcs = ["__init__.py"], -) diff --git a/gazelle/testdata/simple_test/BUILD.out b/gazelle/testdata/simple_test/BUILD.out deleted file mode 100644 index ae2f982032..0000000000 --- a/gazelle/testdata/simple_test/BUILD.out +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") - -py_library( - name = "simple_test", - srcs = [ - "__init__.py", - "foo.py", - ], - visibility = ["//:__subpackages__"], -) - -py_test( - name = "simple_test_test", - srcs = ["__test__.py"], - main = "__test__.py", - deps = [":simple_test"], -) diff --git a/gazelle/testdata/simple_test/README.md b/gazelle/testdata/simple_test/README.md deleted file mode 100644 index 0cfbbebc02..0000000000 --- a/gazelle/testdata/simple_test/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Simple test - -This test case asserts that a simple `py_test` is generated as expected. diff --git a/gazelle/testdata/simple_test/WORKSPACE b/gazelle/testdata/simple_test/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/simple_test/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/simple_test/__init__.py b/gazelle/testdata/simple_test/__init__.py deleted file mode 100644 index 6a49193fe4..0000000000 --- a/gazelle/testdata/simple_test/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from foo import foo - -_ = foo diff --git a/gazelle/testdata/simple_test/__test__.py b/gazelle/testdata/simple_test/__test__.py deleted file mode 100644 index d6085a41b4..0000000000 --- a/gazelle/testdata/simple_test/__test__.py +++ /dev/null @@ -1,12 +0,0 @@ -import unittest - -from __init__ import foo - - -class FooTest(unittest.TestCase): - def test_foo(self): - self.assertEqual("foo", foo()) - - -if __name__ == "__main__": - unittest.main() diff --git a/gazelle/testdata/simple_test/foo.py b/gazelle/testdata/simple_test/foo.py deleted file mode 100644 index cf68624419..0000000000 --- a/gazelle/testdata/simple_test/foo.py +++ /dev/null @@ -1,2 +0,0 @@ -def foo(): - return "foo" diff --git a/gazelle/testdata/simple_test/test.yaml b/gazelle/testdata/simple_test/test.yaml deleted file mode 100644 index 36dd656b39..0000000000 --- a/gazelle/testdata/simple_test/test.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -expect: - exit_code: 0 diff --git a/gazelle/testdata/subdir_sources/BUILD.in b/gazelle/testdata/subdir_sources/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/BUILD.out b/gazelle/testdata/subdir_sources/BUILD.out deleted file mode 100644 index d03a8f05ac..0000000000 --- a/gazelle/testdata/subdir_sources/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary") - -py_binary( - name = "subdir_sources_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [ - "//foo", - "//one/two", - ], -) diff --git a/gazelle/testdata/subdir_sources/README.md b/gazelle/testdata/subdir_sources/README.md deleted file mode 100644 index 79ca3a2c20..0000000000 --- a/gazelle/testdata/subdir_sources/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Subdir sources - -This test case asserts that `py_library` targets are generated with sources from -subdirectories and that dependencies are added according to the target that the -imported source file belongs to. diff --git a/gazelle/testdata/subdir_sources/WORKSPACE b/gazelle/testdata/subdir_sources/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/subdir_sources/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/subdir_sources/__main__.py b/gazelle/testdata/subdir_sources/__main__.py deleted file mode 100644 index 3cc8834990..0000000000 --- a/gazelle/testdata/subdir_sources/__main__.py +++ /dev/null @@ -1,7 +0,0 @@ -import foo.bar.bar as bar -import foo.baz.baz as baz -import one.two.three as three - -_ = bar -_ = baz -_ = three diff --git a/gazelle/testdata/subdir_sources/foo/BUILD.in b/gazelle/testdata/subdir_sources/foo/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/BUILD.out b/gazelle/testdata/subdir_sources/foo/BUILD.out deleted file mode 100644 index f99857dc52..0000000000 --- a/gazelle/testdata/subdir_sources/foo/BUILD.out +++ /dev/null @@ -1,13 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "foo", - srcs = [ - "__init__.py", - "bar/bar.py", - "baz/baz.py", - "foo.py", - ], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/subdir_sources/foo/__init__.py b/gazelle/testdata/subdir_sources/foo/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/bar/bar.py b/gazelle/testdata/subdir_sources/foo/bar/bar.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/bar/bar.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/baz/baz.py b/gazelle/testdata/subdir_sources/foo/baz/baz.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/baz/baz.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/foo.py b/gazelle/testdata/subdir_sources/foo/foo.py deleted file mode 100644 index 6752f22f90..0000000000 --- a/gazelle/testdata/subdir_sources/foo/foo.py +++ /dev/null @@ -1,3 +0,0 @@ -import foo.bar.bar as bar - -_ = bar diff --git a/gazelle/testdata/subdir_sources/foo/has_build/BUILD.in b/gazelle/testdata/subdir_sources/foo/has_build/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/has_build/BUILD.out b/gazelle/testdata/subdir_sources/foo/has_build/BUILD.out deleted file mode 100644 index 0ef0cc12e6..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_build/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "has_build", - srcs = ["python/my_module.py"], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/subdir_sources/foo/has_build/python/my_module.py b/gazelle/testdata/subdir_sources/foo/has_build/python/my_module.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_build/python/my_module.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in b/gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.out b/gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.out deleted file mode 100644 index 79bd70a258..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_build_bazel/BUILD.bazel.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "has_build_bazel", - srcs = ["python/my_module.py"], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py b/gazelle/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_build_bazel/python/my_module.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_init/BUILD.in b/gazelle/testdata/subdir_sources/foo/has_init/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/has_init/BUILD.out b/gazelle/testdata/subdir_sources/foo/has_init/BUILD.out deleted file mode 100644 index ce59ee263e..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_init/BUILD.out +++ /dev/null @@ -1,11 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "has_init", - srcs = [ - "__init__.py", - "python/my_module.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/subdir_sources/foo/has_init/__init__.py b/gazelle/testdata/subdir_sources/foo/has_init/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_init/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_init/python/my_module.py b/gazelle/testdata/subdir_sources/foo/has_init/python/my_module.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_init/python/my_module.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_main/BUILD.in b/gazelle/testdata/subdir_sources/foo/has_main/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/has_main/BUILD.out b/gazelle/testdata/subdir_sources/foo/has_main/BUILD.out deleted file mode 100644 index 265c08bd57..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_main/BUILD.out +++ /dev/null @@ -1,17 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -py_library( - name = "has_main", - srcs = ["python/my_module.py"], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) - -py_binary( - name = "has_main_bin", - srcs = ["__main__.py"], - imports = ["../.."], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [":has_main"], -) diff --git a/gazelle/testdata/subdir_sources/foo/has_main/__main__.py b/gazelle/testdata/subdir_sources/foo/has_main/__main__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_main/__main__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_main/python/my_module.py b/gazelle/testdata/subdir_sources/foo/has_main/python/my_module.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_main/python/my_module.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_test/BUILD.in b/gazelle/testdata/subdir_sources/foo/has_test/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/foo/has_test/BUILD.out b/gazelle/testdata/subdir_sources/foo/has_test/BUILD.out deleted file mode 100644 index 80739d9a3f..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_test/BUILD.out +++ /dev/null @@ -1,16 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library", "py_test") - -py_library( - name = "has_test", - srcs = ["python/my_module.py"], - imports = ["../.."], - visibility = ["//:__subpackages__"], -) - -py_test( - name = "has_test_test", - srcs = ["__test__.py"], - imports = ["../.."], - main = "__test__.py", - deps = [":has_test"], -) diff --git a/gazelle/testdata/subdir_sources/foo/has_test/__test__.py b/gazelle/testdata/subdir_sources/foo/has_test/__test__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_test/__test__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/foo/has_test/python/my_module.py b/gazelle/testdata/subdir_sources/foo/has_test/python/my_module.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/foo/has_test/python/my_module.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/one/BUILD.in b/gazelle/testdata/subdir_sources/one/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/one/BUILD.out b/gazelle/testdata/subdir_sources/one/BUILD.out deleted file mode 100644 index f2e57456ca..0000000000 --- a/gazelle/testdata/subdir_sources/one/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "one", - srcs = ["__init__.py"], - imports = [".."], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/subdir_sources/one/__init__.py b/gazelle/testdata/subdir_sources/one/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/one/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/one/two/BUILD.in b/gazelle/testdata/subdir_sources/one/two/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/subdir_sources/one/two/BUILD.out b/gazelle/testdata/subdir_sources/one/two/BUILD.out deleted file mode 100644 index f632eedcf3..0000000000 --- a/gazelle/testdata/subdir_sources/one/two/BUILD.out +++ /dev/null @@ -1,12 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "two", - srcs = [ - "__init__.py", - "three.py", - ], - imports = ["../.."], - visibility = ["//:__subpackages__"], - deps = ["//foo"], -) diff --git a/gazelle/testdata/subdir_sources/one/two/__init__.py b/gazelle/testdata/subdir_sources/one/two/__init__.py deleted file mode 100644 index f6c7d2a988..0000000000 --- a/gazelle/testdata/subdir_sources/one/two/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -import foo.baz.baz as baz - -_ = baz diff --git a/gazelle/testdata/subdir_sources/one/two/three.py b/gazelle/testdata/subdir_sources/one/two/three.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/subdir_sources/one/two/three.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/subdir_sources/test.yaml b/gazelle/testdata/subdir_sources/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/subdir_sources/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/with_nested_import_statements/BUILD.in b/gazelle/testdata/with_nested_import_statements/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/with_nested_import_statements/BUILD.out b/gazelle/testdata/with_nested_import_statements/BUILD.out deleted file mode 100644 index bb2f34db55..0000000000 --- a/gazelle/testdata/with_nested_import_statements/BUILD.out +++ /dev/null @@ -1,8 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "with_nested_import_statements", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], - deps = ["@gazelle_python_test//pypi__boto3"], -) diff --git a/gazelle/testdata/with_nested_import_statements/README.md b/gazelle/testdata/with_nested_import_statements/README.md deleted file mode 100644 index 7213b34565..0000000000 --- a/gazelle/testdata/with_nested_import_statements/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# With nested import statements - -This test case asserts that a `py_library` is generated with dependencies -extracted from nested import statements from the Python source file. diff --git a/gazelle/testdata/with_nested_import_statements/WORKSPACE b/gazelle/testdata/with_nested_import_statements/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/with_nested_import_statements/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/with_nested_import_statements/__init__.py b/gazelle/testdata/with_nested_import_statements/__init__.py deleted file mode 100644 index 6871953f88..0000000000 --- a/gazelle/testdata/with_nested_import_statements/__init__.py +++ /dev/null @@ -1,11 +0,0 @@ -import os -import sys - -_ = os -_ = sys - - -def main(): - import boto3 - - _ = boto3 diff --git a/gazelle/testdata/with_nested_import_statements/gazelle_python.yaml b/gazelle/testdata/with_nested_import_statements/gazelle_python.yaml deleted file mode 100644 index 7288b798e1..0000000000 --- a/gazelle/testdata/with_nested_import_statements/gazelle_python.yaml +++ /dev/null @@ -1,4 +0,0 @@ -manifest: - modules_mapping: - boto3: boto3 - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/with_nested_import_statements/test.yaml b/gazelle/testdata/with_nested_import_statements/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/with_nested_import_statements/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/with_std_requirements/BUILD.in b/gazelle/testdata/with_std_requirements/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/with_std_requirements/BUILD.out b/gazelle/testdata/with_std_requirements/BUILD.out deleted file mode 100644 index a382ca88c2..0000000000 --- a/gazelle/testdata/with_std_requirements/BUILD.out +++ /dev/null @@ -1,7 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_library") - -py_library( - name = "with_std_requirements", - srcs = ["__init__.py"], - visibility = ["//:__subpackages__"], -) diff --git a/gazelle/testdata/with_std_requirements/README.md b/gazelle/testdata/with_std_requirements/README.md deleted file mode 100644 index 4eaf1b04c2..0000000000 --- a/gazelle/testdata/with_std_requirements/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# With std requirements - -This test case asserts that a `py_library` is generated without any `deps` since -it only imports Python standard library packages. diff --git a/gazelle/testdata/with_std_requirements/WORKSPACE b/gazelle/testdata/with_std_requirements/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/with_std_requirements/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/with_std_requirements/__init__.py b/gazelle/testdata/with_std_requirements/__init__.py deleted file mode 100644 index 154689a5f4..0000000000 --- a/gazelle/testdata/with_std_requirements/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import os -import sys - -_ = os -_ = sys diff --git a/gazelle/testdata/with_std_requirements/test.yaml b/gazelle/testdata/with_std_requirements/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/with_std_requirements/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/with_third_party_requirements/BUILD.in b/gazelle/testdata/with_third_party_requirements/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/with_third_party_requirements/BUILD.out b/gazelle/testdata/with_third_party_requirements/BUILD.out deleted file mode 100644 index 9854730a2e..0000000000 --- a/gazelle/testdata/with_third_party_requirements/BUILD.out +++ /dev/null @@ -1,27 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -py_library( - name = "with_third_party_requirements", - srcs = [ - "__init__.py", - "bar.py", - "foo.py", - ], - visibility = ["//:__subpackages__"], - deps = [ - "@gazelle_python_test//pypi__baz", - "@gazelle_python_test//pypi__boto3", - "@gazelle_python_test//pypi__djangorestframework", - ], -) - -py_binary( - name = "with_third_party_requirements_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [ - ":with_third_party_requirements", - "@gazelle_python_test//pypi__baz", - ], -) diff --git a/gazelle/testdata/with_third_party_requirements/README.md b/gazelle/testdata/with_third_party_requirements/README.md deleted file mode 100644 index b47101c8f8..0000000000 --- a/gazelle/testdata/with_third_party_requirements/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# With third-party requirements - -This test case asserts that a `py_library` is generated with dependencies -extracted from its sources and a `py_binary` is generated embeding the -`py_library` and inherits its dependencies, without specifying the `deps` again. diff --git a/gazelle/testdata/with_third_party_requirements/WORKSPACE b/gazelle/testdata/with_third_party_requirements/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/with_third_party_requirements/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/with_third_party_requirements/__init__.py b/gazelle/testdata/with_third_party_requirements/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/with_third_party_requirements/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/with_third_party_requirements/__main__.py b/gazelle/testdata/with_third_party_requirements/__main__.py deleted file mode 100644 index fe551aa423..0000000000 --- a/gazelle/testdata/with_third_party_requirements/__main__.py +++ /dev/null @@ -1,5 +0,0 @@ -import bar -import foo - -_ = bar -_ = foo diff --git a/gazelle/testdata/with_third_party_requirements/bar.py b/gazelle/testdata/with_third_party_requirements/bar.py deleted file mode 100644 index 19ddd97a87..0000000000 --- a/gazelle/testdata/with_third_party_requirements/bar.py +++ /dev/null @@ -1,11 +0,0 @@ -import os - -import bar -import boto3 -import rest_framework - -_ = os - -_ = bar -_ = boto3 -_ = rest_framework diff --git a/gazelle/testdata/with_third_party_requirements/foo.py b/gazelle/testdata/with_third_party_requirements/foo.py deleted file mode 100644 index 29a1f3b612..0000000000 --- a/gazelle/testdata/with_third_party_requirements/foo.py +++ /dev/null @@ -1,11 +0,0 @@ -import sys - -import boto3 -import foo -import rest_framework - -_ = sys - -_ = boto3 -_ = foo -_ = rest_framework diff --git a/gazelle/testdata/with_third_party_requirements/gazelle_python.yaml b/gazelle/testdata/with_third_party_requirements/gazelle_python.yaml deleted file mode 100644 index 76bb8bfa7b..0000000000 --- a/gazelle/testdata/with_third_party_requirements/gazelle_python.yaml +++ /dev/null @@ -1,7 +0,0 @@ -manifest: - modules_mapping: - boto3: boto3 - rest_framework: djangorestframework - foo: baz - bar: baz - pip_deps_repository_name: gazelle_python_test diff --git a/gazelle/testdata/with_third_party_requirements/test.yaml b/gazelle/testdata/with_third_party_requirements/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/with_third_party_requirements/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/BUILD.in b/gazelle/testdata/with_third_party_requirements_from_imports/BUILD.in deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/BUILD.out b/gazelle/testdata/with_third_party_requirements_from_imports/BUILD.out deleted file mode 100644 index 577f167143..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/BUILD.out +++ /dev/null @@ -1,25 +0,0 @@ -load("@rules_python//python:defs.bzl", "py_binary", "py_library") - -py_library( - name = "with_third_party_requirements_from_imports", - srcs = [ - "__init__.py", - "bar.py", - ], - visibility = ["//:__subpackages__"], - deps = [ - "@gazelle_python_test_google_cloud_aiplatform//:pkg", - "@gazelle_python_test_google_cloud_storage//:pkg", - ], -) - -py_binary( - name = "with_third_party_requirements_from_imports_bin", - srcs = ["__main__.py"], - main = "__main__.py", - visibility = ["//:__subpackages__"], - deps = [ - ":with_third_party_requirements_from_imports", - "@gazelle_python_test_google_cloud_aiplatform//:pkg", - ], -) diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/README.md b/gazelle/testdata/with_third_party_requirements_from_imports/README.md deleted file mode 100644 index c50a1ca100..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# With third-party requirements (from imports) - -This test case covers imports of the form: - -```python -from my_pip_dep import foo -``` - -for example - -```python -from google.cloud import aiplatform, storage -``` - -See https://github.com/bazelbuild/rules_python/issues/709 and https://github.com/sramirezmartin/gazelle-toy-example. diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/WORKSPACE b/gazelle/testdata/with_third_party_requirements_from_imports/WORKSPACE deleted file mode 100644 index faff6af87a..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/WORKSPACE +++ /dev/null @@ -1 +0,0 @@ -# This is a Bazel workspace for the Gazelle test data. diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/__init__.py b/gazelle/testdata/with_third_party_requirements_from_imports/__init__.py deleted file mode 100644 index 6b58ff30a8..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# For test purposes only. diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/__main__.py b/gazelle/testdata/with_third_party_requirements_from_imports/__main__.py deleted file mode 100644 index 9f529cb0df..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/__main__.py +++ /dev/null @@ -1,6 +0,0 @@ -from bar import main -from google.cloud import aiplatform - -if __name__ == "__main__": - print(aiplatform) - main() diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/bar.py b/gazelle/testdata/with_third_party_requirements_from_imports/bar.py deleted file mode 100644 index 99a4b1ce95..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/bar.py +++ /dev/null @@ -1,6 +0,0 @@ -from google.cloud import aiplatform, storage - - -def main(): - a = dir(aiplatform) - b = dir(storage) diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml b/gazelle/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml deleted file mode 100644 index 21edbc0a0d..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/gazelle_python.yaml +++ /dev/null @@ -1,1665 +0,0 @@ -manifest: - modules_mapping: - cachetools: cachetools - cachetools.__init__: cachetools - cachetools.func: cachetools - cachetools.keys: cachetools - certifi: certifi - certifi.__init__: certifi - certifi.__main__: certifi - certifi.core: certifi - charset_normalizer: charset_normalizer - charset_normalizer.__init__: charset_normalizer - charset_normalizer.api: charset_normalizer - charset_normalizer.assets: charset_normalizer - charset_normalizer.assets.__init__: charset_normalizer - charset_normalizer.cd: charset_normalizer - charset_normalizer.cli: charset_normalizer - charset_normalizer.cli.__init__: charset_normalizer - charset_normalizer.cli.normalizer: charset_normalizer - charset_normalizer.constant: charset_normalizer - charset_normalizer.legacy: charset_normalizer - charset_normalizer.md: charset_normalizer - charset_normalizer.models: charset_normalizer - charset_normalizer.utils: charset_normalizer - charset_normalizer.version: charset_normalizer - dateutil: python_dateutil - dateutil.__init__: python_dateutil - dateutil._common: python_dateutil - dateutil._version: python_dateutil - dateutil.easter: python_dateutil - dateutil.parser: python_dateutil - dateutil.parser.__init__: python_dateutil - dateutil.parser._parser: python_dateutil - dateutil.parser.isoparser: python_dateutil - dateutil.relativedelta: python_dateutil - dateutil.rrule: python_dateutil - dateutil.tz: python_dateutil - dateutil.tz.__init__: python_dateutil - dateutil.tz._common: python_dateutil - dateutil.tz._factories: python_dateutil - dateutil.tz.tz: python_dateutil - dateutil.tz.win: python_dateutil - dateutil.tzwin: python_dateutil - dateutil.utils: python_dateutil - dateutil.zoneinfo: python_dateutil - dateutil.zoneinfo.__init__: python_dateutil - dateutil.zoneinfo.rebuild: python_dateutil - docs.conf: google_cloud_resource_manager - google._async_resumable_media: google_resumable_media - google._async_resumable_media.__init__: google_resumable_media - google._async_resumable_media._download: google_resumable_media - google._async_resumable_media._helpers: google_resumable_media - google._async_resumable_media._upload: google_resumable_media - google._async_resumable_media.requests: google_resumable_media - google._async_resumable_media.requests.__init__: google_resumable_media - google._async_resumable_media.requests._request_helpers: google_resumable_media - google._async_resumable_media.requests.download: google_resumable_media - google._async_resumable_media.requests.upload: google_resumable_media - google.api: googleapis_common_protos - google.api.__init__: googleapis_common_protos - google.api.annotations_pb2: googleapis_common_protos - google.api.auth_pb2: googleapis_common_protos - google.api.backend_pb2: googleapis_common_protos - google.api.billing_pb2: googleapis_common_protos - google.api.client_pb2: googleapis_common_protos - google.api.config_change_pb2: googleapis_common_protos - google.api.consumer_pb2: googleapis_common_protos - google.api.context_pb2: googleapis_common_protos - google.api.control_pb2: googleapis_common_protos - google.api.distribution_pb2: googleapis_common_protos - google.api.documentation_pb2: googleapis_common_protos - google.api.endpoint_pb2: googleapis_common_protos - google.api.error_reason_pb2: googleapis_common_protos - google.api.field_behavior_pb2: googleapis_common_protos - google.api.http_pb2: googleapis_common_protos - google.api.httpbody_pb2: googleapis_common_protos - google.api.label_pb2: googleapis_common_protos - google.api.launch_stage_pb2: googleapis_common_protos - google.api.log_pb2: googleapis_common_protos - google.api.logging_pb2: googleapis_common_protos - google.api.metric_pb2: googleapis_common_protos - google.api.monitored_resource_pb2: googleapis_common_protos - google.api.monitoring_pb2: googleapis_common_protos - google.api.quota_pb2: googleapis_common_protos - google.api.resource_pb2: googleapis_common_protos - google.api.routing_pb2: googleapis_common_protos - google.api.service_pb2: googleapis_common_protos - google.api.source_info_pb2: googleapis_common_protos - google.api.system_parameter_pb2: googleapis_common_protos - google.api.usage_pb2: googleapis_common_protos - google.api.visibility_pb2: googleapis_common_protos - google.api_core: google_api_core - google.api_core.__init__: google_api_core - google.api_core.bidi: google_api_core - google.api_core.client_info: google_api_core - google.api_core.client_options: google_api_core - google.api_core.datetime_helpers: google_api_core - google.api_core.exceptions: google_api_core - google.api_core.extended_operation: google_api_core - google.api_core.future: google_api_core - google.api_core.future.__init__: google_api_core - google.api_core.future._helpers: google_api_core - google.api_core.future.async_future: google_api_core - google.api_core.future.base: google_api_core - google.api_core.future.polling: google_api_core - google.api_core.gapic_v1: google_api_core - google.api_core.gapic_v1.__init__: google_api_core - google.api_core.gapic_v1.client_info: google_api_core - google.api_core.gapic_v1.config: google_api_core - google.api_core.gapic_v1.config_async: google_api_core - google.api_core.gapic_v1.method: google_api_core - google.api_core.gapic_v1.method_async: google_api_core - google.api_core.gapic_v1.routing_header: google_api_core - google.api_core.general_helpers: google_api_core - google.api_core.grpc_helpers: google_api_core - google.api_core.grpc_helpers_async: google_api_core - google.api_core.iam: google_api_core - google.api_core.operation: google_api_core - google.api_core.operation_async: google_api_core - google.api_core.operations_v1: google_api_core - google.api_core.operations_v1.__init__: google_api_core - google.api_core.operations_v1.abstract_operations_client: google_api_core - google.api_core.operations_v1.operations_async_client: google_api_core - google.api_core.operations_v1.operations_client: google_api_core - google.api_core.operations_v1.operations_client_config: google_api_core - google.api_core.operations_v1.pagers: google_api_core - google.api_core.operations_v1.transports: google_api_core - google.api_core.operations_v1.transports.__init__: google_api_core - google.api_core.operations_v1.transports.base: google_api_core - google.api_core.operations_v1.transports.rest: google_api_core - google.api_core.page_iterator: google_api_core - google.api_core.page_iterator_async: google_api_core - google.api_core.path_template: google_api_core - google.api_core.protobuf_helpers: google_api_core - google.api_core.rest_helpers: google_api_core - google.api_core.rest_streaming: google_api_core - google.api_core.retry: google_api_core - google.api_core.retry_async: google_api_core - google.api_core.timeout: google_api_core - google.api_core.version: google_api_core - google.auth: google_auth - google.auth.__init__: google_auth - google.auth._cloud_sdk: google_auth - google.auth._credentials_async: google_auth - google.auth._default: google_auth - google.auth._default_async: google_auth - google.auth._helpers: google_auth - google.auth._jwt_async: google_auth - google.auth._oauth2client: google_auth - google.auth._service_account_info: google_auth - google.auth.app_engine: google_auth - google.auth.aws: google_auth - google.auth.compute_engine: google_auth - google.auth.compute_engine.__init__: google_auth - google.auth.compute_engine._metadata: google_auth - google.auth.compute_engine.credentials: google_auth - google.auth.credentials: google_auth - google.auth.crypt: google_auth - google.auth.crypt.__init__: google_auth - google.auth.crypt._cryptography_rsa: google_auth - google.auth.crypt._helpers: google_auth - google.auth.crypt._python_rsa: google_auth - google.auth.crypt.base: google_auth - google.auth.crypt.es256: google_auth - google.auth.crypt.rsa: google_auth - google.auth.downscoped: google_auth - google.auth.environment_vars: google_auth - google.auth.exceptions: google_auth - google.auth.external_account: google_auth - google.auth.iam: google_auth - google.auth.identity_pool: google_auth - google.auth.impersonated_credentials: google_auth - google.auth.jwt: google_auth - google.auth.transport: google_auth - google.auth.transport.__init__: google_auth - google.auth.transport._aiohttp_requests: google_auth - google.auth.transport._http_client: google_auth - google.auth.transport._mtls_helper: google_auth - google.auth.transport.grpc: google_auth - google.auth.transport.mtls: google_auth - google.auth.transport.requests: google_auth - google.auth.transport.urllib3: google_auth - google.auth.version: google_auth - google.cloud._helpers: google_cloud_core - google.cloud._helpers.__init__: google_cloud_core - google.cloud._http: google_cloud_core - google.cloud._http.__init__: google_cloud_core - google.cloud._testing: google_cloud_core - google.cloud._testing.__init__: google_cloud_core - google.cloud.aiplatform: google_cloud_aiplatform - google.cloud.aiplatform.__init__: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.__init__: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.match_service_pb2: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.match_service_pb2_grpc: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.matching_engine_index: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.matching_engine_index_config: google_cloud_aiplatform - google.cloud.aiplatform._matching_engine.matching_engine_index_endpoint: google_cloud_aiplatform - google.cloud.aiplatform.base: google_cloud_aiplatform - google.cloud.aiplatform.compat: google_cloud_aiplatform - google.cloud.aiplatform.compat.__init__: google_cloud_aiplatform - google.cloud.aiplatform.compat.services: google_cloud_aiplatform - google.cloud.aiplatform.compat.services.__init__: google_cloud_aiplatform - google.cloud.aiplatform.compat.types: google_cloud_aiplatform - google.cloud.aiplatform.compat.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.constants: google_cloud_aiplatform - google.cloud.aiplatform.constants.__init__: google_cloud_aiplatform - google.cloud.aiplatform.constants.base: google_cloud_aiplatform - google.cloud.aiplatform.constants.prediction: google_cloud_aiplatform - google.cloud.aiplatform.datasets: google_cloud_aiplatform - google.cloud.aiplatform.datasets.__init__: google_cloud_aiplatform - google.cloud.aiplatform.datasets._datasources: google_cloud_aiplatform - google.cloud.aiplatform.datasets.column_names_dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.image_dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.tabular_dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.text_dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.time_series_dataset: google_cloud_aiplatform - google.cloud.aiplatform.datasets.video_dataset: google_cloud_aiplatform - google.cloud.aiplatform.explain: google_cloud_aiplatform - google.cloud.aiplatform.explain.__init__: google_cloud_aiplatform - google.cloud.aiplatform.explain.lit: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.__init__: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.metadata_builder: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.__init__: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v1: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v1.saved_model_metadata_builder: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v2: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v2.__init__: google_cloud_aiplatform - google.cloud.aiplatform.explain.metadata.tf.v2.saved_model_metadata_builder: google_cloud_aiplatform - google.cloud.aiplatform.featurestore: google_cloud_aiplatform - google.cloud.aiplatform.featurestore.__init__: google_cloud_aiplatform - google.cloud.aiplatform.featurestore.entity_type: google_cloud_aiplatform - google.cloud.aiplatform.featurestore.feature: google_cloud_aiplatform - google.cloud.aiplatform.featurestore.featurestore: google_cloud_aiplatform - google.cloud.aiplatform.gapic: google_cloud_aiplatform - google.cloud.aiplatform.gapic.__init__: google_cloud_aiplatform - google.cloud.aiplatform.gapic.schema: google_cloud_aiplatform - google.cloud.aiplatform.gapic.schema.__init__: google_cloud_aiplatform - google.cloud.aiplatform.helpers: google_cloud_aiplatform - google.cloud.aiplatform.helpers.__init__: google_cloud_aiplatform - google.cloud.aiplatform.helpers.container_uri_builders: google_cloud_aiplatform - google.cloud.aiplatform.hyperparameter_tuning: google_cloud_aiplatform - google.cloud.aiplatform.initializer: google_cloud_aiplatform - google.cloud.aiplatform.jobs: google_cloud_aiplatform - google.cloud.aiplatform.metadata: google_cloud_aiplatform - google.cloud.aiplatform.metadata.__init__: google_cloud_aiplatform - google.cloud.aiplatform.metadata.artifact: google_cloud_aiplatform - google.cloud.aiplatform.metadata.constants: google_cloud_aiplatform - google.cloud.aiplatform.metadata.context: google_cloud_aiplatform - google.cloud.aiplatform.metadata.execution: google_cloud_aiplatform - google.cloud.aiplatform.metadata.metadata: google_cloud_aiplatform - google.cloud.aiplatform.metadata.metadata_store: google_cloud_aiplatform - google.cloud.aiplatform.metadata.resource: google_cloud_aiplatform - google.cloud.aiplatform.model_evaluation: google_cloud_aiplatform - google.cloud.aiplatform.model_evaluation.__init__: google_cloud_aiplatform - google.cloud.aiplatform.model_evaluation.model_evaluation: google_cloud_aiplatform - google.cloud.aiplatform.models: google_cloud_aiplatform - google.cloud.aiplatform.pipeline_jobs: google_cloud_aiplatform - google.cloud.aiplatform.schema: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.__init__: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.plugins.tf_profiler.profile_uploader: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.tensorboard_resource: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.uploader: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.uploader_main: google_cloud_aiplatform - google.cloud.aiplatform.tensorboard.uploader_utils: google_cloud_aiplatform - google.cloud.aiplatform.training_jobs: google_cloud_aiplatform - google.cloud.aiplatform.training_utils: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.__init__: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.__init__: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.cloud_profiler_utils: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.initializer: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.plugins.base_plugin: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tensorboard_api: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.plugins.tensorflow.tf_profiler: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.webserver: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.cloud_profiler.wsgi_types: google_cloud_aiplatform - google.cloud.aiplatform.training_utils.environment_variables: google_cloud_aiplatform - google.cloud.aiplatform.utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.__init__: google_cloud_aiplatform - google.cloud.aiplatform.utils.column_transformations_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.console_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.enhanced_library: google_cloud_aiplatform - google.cloud.aiplatform.utils.enhanced_library.__init__: google_cloud_aiplatform - google.cloud.aiplatform.utils.enhanced_library._decorators: google_cloud_aiplatform - google.cloud.aiplatform.utils.enhanced_library.value_converter: google_cloud_aiplatform - google.cloud.aiplatform.utils.featurestore_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.gcs_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.pipeline_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.resource_manager_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.source_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.tensorboard_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.worker_spec_utils: google_cloud_aiplatform - google.cloud.aiplatform.utils.yaml_utils: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.instance_v1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.params_v1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.tabular_regression: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.predict.prediction_v1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_tables: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.automl_video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1.schema.trainingjob.definition_v1.types.export_evaluated_data_items_config: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.instance_v1beta1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.params_v1beta1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.tabular_regression: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.time_series_forecasting: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.predict.prediction_v1beta1.types.video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_forecasting: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_object_detection: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_image_segmentation: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_tables: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_extraction: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_text_sentiment: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_time_series_forecasting: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_action_recognition: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_classification: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.automl_video_object_tracking: google_cloud_aiplatform - google.cloud.aiplatform.v1beta1.schema.trainingjob.definition_v1beta1.types.export_evaluated_data_items_config: google_cloud_aiplatform - google.cloud.aiplatform.version: google_cloud_aiplatform - google.cloud.aiplatform_v1: google_cloud_aiplatform - google.cloud.aiplatform_v1.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1.types: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.accelerator_type: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.annotation: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.annotation_spec: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.artifact: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.batch_prediction_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.completion_stats: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.context: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.custom_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.data_item: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.data_labeling_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.dataset: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.dataset_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.deployed_index_ref: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.deployed_model_ref: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.encryption_spec: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.endpoint: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.entity_type: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.env_var: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.event: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.execution: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.explanation: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.explanation_metadata: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.feature: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.feature_monitoring_stats: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.feature_selector: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.featurestore: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.featurestore_monitoring: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.featurestore_online_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.featurestore_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.hyperparameter_tuning_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.index: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.index_endpoint: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.index_endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.index_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.io: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.job_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.job_state: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.lineage_subgraph: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.machine_resources: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.manual_batch_tuning_parameters: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.metadata_schema: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.metadata_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.metadata_store: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.migratable_resource: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.migration_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model_deployment_monitoring_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model_evaluation: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model_evaluation_slice: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model_monitoring: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.model_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.operation: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.pipeline_job: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.pipeline_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.pipeline_state: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.prediction_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.specialist_pool: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.specialist_pool_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.study: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard_data: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard_experiment: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard_run: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard_service: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.tensorboard_time_series: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.training_pipeline: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.types: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.unmanaged_container_model: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.user_action_reference: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.value: google_cloud_aiplatform - google.cloud.aiplatform_v1.types.vizier_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.dataset_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_online_serving_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.featurestore_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_endpoint_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.index_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.job_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.metadata_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.migration_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.model_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.pipeline_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.prediction_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.specialist_pool_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.tensorboard_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.async_client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.client: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.pagers: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.transports: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.transports.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.transports.base: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.services.vizier_service.transports.grpc_asyncio: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.__init__: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.accelerator_type: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.annotation: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.annotation_spec: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.artifact: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.batch_prediction_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.completion_stats: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.context: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.custom_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.data_item: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.data_labeling_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.dataset: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.dataset_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.deployed_index_ref: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.deployed_model_ref: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.encryption_spec: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.endpoint: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.entity_type: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.env_var: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.event: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.execution: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.explanation: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.explanation_metadata: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.feature: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.feature_monitoring_stats: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.feature_selector: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.featurestore: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.featurestore_monitoring: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.featurestore_online_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.featurestore_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.hyperparameter_tuning_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.index: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.index_endpoint: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.index_endpoint_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.index_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.io: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.job_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.job_state: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.lineage_subgraph: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.machine_resources: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.manual_batch_tuning_parameters: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.metadata_schema: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.metadata_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.metadata_store: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.migratable_resource: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.migration_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model_deployment_monitoring_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model_evaluation: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model_evaluation_slice: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model_monitoring: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.model_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.operation: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.pipeline_job: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.pipeline_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.pipeline_state: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.prediction_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.specialist_pool: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.specialist_pool_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.study: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard_data: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard_experiment: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard_run: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard_service: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.tensorboard_time_series: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.training_pipeline: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.types: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.unmanaged_container_model: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.user_action_reference: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.value: google_cloud_aiplatform - google.cloud.aiplatform_v1beta1.types.vizier_service: google_cloud_aiplatform - google.cloud.bigquery: google_cloud_bigquery - google.cloud.bigquery.__init__: google_cloud_bigquery - google.cloud.bigquery._helpers: google_cloud_bigquery - google.cloud.bigquery._http: google_cloud_bigquery - google.cloud.bigquery._pandas_helpers: google_cloud_bigquery - google.cloud.bigquery._tqdm_helpers: google_cloud_bigquery - google.cloud.bigquery.client: google_cloud_bigquery - google.cloud.bigquery.dataset: google_cloud_bigquery - google.cloud.bigquery.dbapi: google_cloud_bigquery - google.cloud.bigquery.dbapi.__init__: google_cloud_bigquery - google.cloud.bigquery.dbapi._helpers: google_cloud_bigquery - google.cloud.bigquery.dbapi.connection: google_cloud_bigquery - google.cloud.bigquery.dbapi.cursor: google_cloud_bigquery - google.cloud.bigquery.dbapi.exceptions: google_cloud_bigquery - google.cloud.bigquery.dbapi.types: google_cloud_bigquery - google.cloud.bigquery.encryption_configuration: google_cloud_bigquery - google.cloud.bigquery.enums: google_cloud_bigquery - google.cloud.bigquery.exceptions: google_cloud_bigquery - google.cloud.bigquery.external_config: google_cloud_bigquery - google.cloud.bigquery.format_options: google_cloud_bigquery - google.cloud.bigquery.iam: google_cloud_bigquery - google.cloud.bigquery.job: google_cloud_bigquery - google.cloud.bigquery.job.__init__: google_cloud_bigquery - google.cloud.bigquery.job.base: google_cloud_bigquery - google.cloud.bigquery.job.copy_: google_cloud_bigquery - google.cloud.bigquery.job.extract: google_cloud_bigquery - google.cloud.bigquery.job.load: google_cloud_bigquery - google.cloud.bigquery.job.query: google_cloud_bigquery - google.cloud.bigquery.magics: google_cloud_bigquery - google.cloud.bigquery.magics.__init__: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser.__init__: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser.exceptions: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser.lexer: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser.parser: google_cloud_bigquery - google.cloud.bigquery.magics.line_arg_parser.visitors: google_cloud_bigquery - google.cloud.bigquery.magics.magics: google_cloud_bigquery - google.cloud.bigquery.model: google_cloud_bigquery - google.cloud.bigquery.opentelemetry_tracing: google_cloud_bigquery - google.cloud.bigquery.query: google_cloud_bigquery - google.cloud.bigquery.retry: google_cloud_bigquery - google.cloud.bigquery.routine: google_cloud_bigquery - google.cloud.bigquery.routine.__init__: google_cloud_bigquery - google.cloud.bigquery.routine.routine: google_cloud_bigquery - google.cloud.bigquery.schema: google_cloud_bigquery - google.cloud.bigquery.table: google_cloud_bigquery - google.cloud.bigquery.version: google_cloud_bigquery - google.cloud.bigquery_v2: google_cloud_bigquery - google.cloud.bigquery_v2.__init__: google_cloud_bigquery - google.cloud.bigquery_v2.types: google_cloud_bigquery - google.cloud.bigquery_v2.types.__init__: google_cloud_bigquery - google.cloud.bigquery_v2.types.encryption_config: google_cloud_bigquery - google.cloud.bigquery_v2.types.model: google_cloud_bigquery - google.cloud.bigquery_v2.types.model_reference: google_cloud_bigquery - google.cloud.bigquery_v2.types.standard_sql: google_cloud_bigquery - google.cloud.bigquery_v2.types.table_reference: google_cloud_bigquery - google.cloud.client: google_cloud_core - google.cloud.client.__init__: google_cloud_core - google.cloud.environment_vars: google_cloud_core - google.cloud.environment_vars.__init__: google_cloud_core - google.cloud.exceptions: google_cloud_core - google.cloud.exceptions.__init__: google_cloud_core - google.cloud.extended_operations_pb2: googleapis_common_protos - google.cloud.location.locations_pb2: googleapis_common_protos - google.cloud.obsolete: google_cloud_core - google.cloud.obsolete.__init__: google_cloud_core - google.cloud.operation: google_cloud_core - google.cloud.operation.__init__: google_cloud_core - google.cloud.resourcemanager: google_cloud_resource_manager - google.cloud.resourcemanager.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3: google_cloud_resource_manager - google.cloud.resourcemanager_v3.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.folders.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.organizations.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.projects.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_bindings.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_keys.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.async_client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.client: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.pagers: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.transports: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.transports.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.transports.base: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.transports.grpc: google_cloud_resource_manager - google.cloud.resourcemanager_v3.services.tag_values.transports.grpc_asyncio: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.__init__: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.folders: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.organizations: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.projects: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.tag_bindings: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.tag_keys: google_cloud_resource_manager - google.cloud.resourcemanager_v3.types.tag_values: google_cloud_resource_manager - google.cloud.storage: google_cloud_storage - google.cloud.storage.__init__: google_cloud_storage - google.cloud.storage._helpers: google_cloud_storage - google.cloud.storage._http: google_cloud_storage - google.cloud.storage._signing: google_cloud_storage - google.cloud.storage.acl: google_cloud_storage - google.cloud.storage.batch: google_cloud_storage - google.cloud.storage.blob: google_cloud_storage - google.cloud.storage.bucket: google_cloud_storage - google.cloud.storage.client: google_cloud_storage - google.cloud.storage.constants: google_cloud_storage - google.cloud.storage.fileio: google_cloud_storage - google.cloud.storage.hmac_key: google_cloud_storage - google.cloud.storage.iam: google_cloud_storage - google.cloud.storage.notification: google_cloud_storage - google.cloud.storage.retry: google_cloud_storage - google.cloud.storage.version: google_cloud_storage - google.cloud.version: google_cloud_core - google.gapic.metadata: googleapis_common_protos - google.gapic.metadata.__init__: googleapis_common_protos - google.gapic.metadata.gapic_metadata_pb2: googleapis_common_protos - google.iam.v1: grpc_google_iam_v1 - google.iam.v1.__init__: grpc_google_iam_v1 - google.iam.v1.iam_policy_pb2: grpc_google_iam_v1 - google.iam.v1.iam_policy_pb2_grpc: grpc_google_iam_v1 - google.iam.v1.logging: grpc_google_iam_v1 - google.iam.v1.logging.__init__: grpc_google_iam_v1 - google.iam.v1.logging.audit_data_pb2: grpc_google_iam_v1 - google.iam.v1.options_pb2: grpc_google_iam_v1 - google.iam.v1.options_pb2_grpc: grpc_google_iam_v1 - google.iam.v1.policy_pb2: grpc_google_iam_v1 - google.iam.v1.policy_pb2_grpc: grpc_google_iam_v1 - google.logging.type: googleapis_common_protos - google.logging.type.__init__: googleapis_common_protos - google.logging.type.http_request_pb2: googleapis_common_protos - google.logging.type.log_severity_pb2: googleapis_common_protos - google.longrunning: googleapis_common_protos - google.longrunning.__init__: googleapis_common_protos - google.longrunning.operations_grpc: googleapis_common_protos - google.longrunning.operations_grpc_pb2: googleapis_common_protos - google.longrunning.operations_pb2: googleapis_common_protos - google.longrunning.operations_pb2_grpc: googleapis_common_protos - google.longrunning.operations_proto: googleapis_common_protos - google.longrunning.operations_proto_pb2: googleapis_common_protos - google.oauth2: google_auth - google.oauth2.__init__: google_auth - google.oauth2._client: google_auth - google.oauth2._client_async: google_auth - google.oauth2._credentials_async: google_auth - google.oauth2._id_token_async: google_auth - google.oauth2._reauth_async: google_auth - google.oauth2._service_account_async: google_auth - google.oauth2.challenges: google_auth - google.oauth2.credentials: google_auth - google.oauth2.id_token: google_auth - google.oauth2.reauth: google_auth - google.oauth2.service_account: google_auth - google.oauth2.sts: google_auth - google.oauth2.utils: google_auth - google.protobuf: protobuf - google.protobuf.__init__: protobuf - google.protobuf.any_pb2: protobuf - google.protobuf.api_pb2: protobuf - google.protobuf.compiler: protobuf - google.protobuf.compiler.__init__: protobuf - google.protobuf.compiler.plugin_pb2: protobuf - google.protobuf.descriptor: protobuf - google.protobuf.descriptor_database: protobuf - google.protobuf.descriptor_pb2: protobuf - google.protobuf.descriptor_pool: protobuf - google.protobuf.duration_pb2: protobuf - google.protobuf.empty_pb2: protobuf - google.protobuf.field_mask_pb2: protobuf - google.protobuf.internal: protobuf - google.protobuf.internal.__init__: protobuf - google.protobuf.internal._api_implementation: protobuf - google.protobuf.internal.api_implementation: protobuf - google.protobuf.internal.builder: protobuf - google.protobuf.internal.containers: protobuf - google.protobuf.internal.decoder: protobuf - google.protobuf.internal.encoder: protobuf - google.protobuf.internal.enum_type_wrapper: protobuf - google.protobuf.internal.extension_dict: protobuf - google.protobuf.internal.message_listener: protobuf - google.protobuf.internal.python_message: protobuf - google.protobuf.internal.type_checkers: protobuf - google.protobuf.internal.well_known_types: protobuf - google.protobuf.internal.wire_format: protobuf - google.protobuf.json_format: protobuf - google.protobuf.message: protobuf - google.protobuf.message_factory: protobuf - google.protobuf.proto_builder: protobuf - google.protobuf.pyext: protobuf - google.protobuf.pyext.__init__: protobuf - google.protobuf.pyext._message: protobuf - google.protobuf.pyext.cpp_message: protobuf - google.protobuf.reflection: protobuf - google.protobuf.service: protobuf - google.protobuf.service_reflection: protobuf - google.protobuf.source_context_pb2: protobuf - google.protobuf.struct_pb2: protobuf - google.protobuf.symbol_database: protobuf - google.protobuf.text_encoding: protobuf - google.protobuf.text_format: protobuf - google.protobuf.timestamp_pb2: protobuf - google.protobuf.type_pb2: protobuf - google.protobuf.util: protobuf - google.protobuf.util.__init__: protobuf - google.protobuf.util.json_format_pb2: protobuf - google.protobuf.util.json_format_proto3_pb2: protobuf - google.protobuf.wrappers_pb2: protobuf - google.resumable_media: google_resumable_media - google.resumable_media.__init__: google_resumable_media - google.resumable_media._download: google_resumable_media - google.resumable_media._helpers: google_resumable_media - google.resumable_media._upload: google_resumable_media - google.resumable_media.common: google_resumable_media - google.resumable_media.requests: google_resumable_media - google.resumable_media.requests.__init__: google_resumable_media - google.resumable_media.requests._request_helpers: google_resumable_media - google.resumable_media.requests.download: google_resumable_media - google.resumable_media.requests.upload: google_resumable_media - google.rpc: googleapis_common_protos - google.rpc.__init__: googleapis_common_protos - google.rpc.code_pb2: googleapis_common_protos - google.rpc.context: googleapis_common_protos - google.rpc.context.__init__: googleapis_common_protos - google.rpc.context.attribute_context_pb2: googleapis_common_protos - google.rpc.error_details_pb2: googleapis_common_protos - google.rpc.status_pb2: googleapis_common_protos - google.type: googleapis_common_protos - google.type.__init__: googleapis_common_protos - google.type.calendar_period_pb2: googleapis_common_protos - google.type.color_pb2: googleapis_common_protos - google.type.date_pb2: googleapis_common_protos - google.type.datetime_pb2: googleapis_common_protos - google.type.dayofweek_pb2: googleapis_common_protos - google.type.decimal_pb2: googleapis_common_protos - google.type.expr_pb2: googleapis_common_protos - google.type.fraction_pb2: googleapis_common_protos - google.type.interval_pb2: googleapis_common_protos - google.type.latlng_pb2: googleapis_common_protos - google.type.localized_text_pb2: googleapis_common_protos - google.type.money_pb2: googleapis_common_protos - google.type.month_pb2: googleapis_common_protos - google.type.phone_number_pb2: googleapis_common_protos - google.type.postal_address_pb2: googleapis_common_protos - google.type.quaternion_pb2: googleapis_common_protos - google.type.timeofday_pb2: googleapis_common_protos - google_crc32c: google_crc32c - google_crc32c.__config__: google_crc32c - google_crc32c.__init__: google_crc32c - google_crc32c._checksum: google_crc32c - google_crc32c._crc32c: google_crc32c - google_crc32c.cext: google_crc32c - google_crc32c.libs.libcrc32c-672e1704: google_crc32c - google_crc32c.python: google_crc32c - grpc: grpcio - grpc.__init__: grpcio - grpc._auth: grpcio - grpc._channel: grpcio - grpc._common: grpcio - grpc._compression: grpcio - grpc._cython: grpcio - grpc._cython.__init__: grpcio - grpc._cython._cygrpc: grpcio - grpc._cython._cygrpc.__init__: grpcio - grpc._cython.cygrpc: grpcio - grpc._grpcio_metadata: grpcio - grpc._interceptor: grpcio - grpc._plugin_wrapping: grpcio - grpc._runtime_protos: grpcio - grpc._server: grpcio - grpc._simple_stubs: grpcio - grpc._utilities: grpcio - grpc.aio: grpcio - grpc.aio.__init__: grpcio - grpc.aio._base_call: grpcio - grpc.aio._base_channel: grpcio - grpc.aio._base_server: grpcio - grpc.aio._call: grpcio - grpc.aio._channel: grpcio - grpc.aio._interceptor: grpcio - grpc.aio._metadata: grpcio - grpc.aio._server: grpcio - grpc.aio._typing: grpcio - grpc.aio._utils: grpcio - grpc.beta: grpcio - grpc.beta.__init__: grpcio - grpc.beta._client_adaptations: grpcio - grpc.beta._metadata: grpcio - grpc.beta._server_adaptations: grpcio - grpc.beta.implementations: grpcio - grpc.beta.interfaces: grpcio - grpc.beta.utilities: grpcio - grpc.experimental: grpcio - grpc.experimental.__init__: grpcio - grpc.experimental.aio: grpcio - grpc.experimental.aio.__init__: grpcio - grpc.experimental.gevent: grpcio - grpc.experimental.session_cache: grpcio - grpc.framework: grpcio - grpc.framework.__init__: grpcio - grpc.framework.common: grpcio - grpc.framework.common.__init__: grpcio - grpc.framework.common.cardinality: grpcio - grpc.framework.common.style: grpcio - grpc.framework.foundation: grpcio - grpc.framework.foundation.__init__: grpcio - grpc.framework.foundation.abandonment: grpcio - grpc.framework.foundation.callable_util: grpcio - grpc.framework.foundation.future: grpcio - grpc.framework.foundation.logging_pool: grpcio - grpc.framework.foundation.stream: grpcio - grpc.framework.foundation.stream_util: grpcio - grpc.framework.interfaces: grpcio - grpc.framework.interfaces.__init__: grpcio - grpc.framework.interfaces.base: grpcio - grpc.framework.interfaces.base.__init__: grpcio - grpc.framework.interfaces.base.base: grpcio - grpc.framework.interfaces.base.utilities: grpcio - grpc.framework.interfaces.face: grpcio - grpc.framework.interfaces.face.__init__: grpcio - grpc.framework.interfaces.face.face: grpcio - grpc.framework.interfaces.face.utilities: grpcio - grpc_status: grpcio_status - grpc_status.__init__: grpcio_status - grpc_status._async: grpcio_status - grpc_status._common: grpcio_status - grpc_status.rpc_status: grpcio_status - idna: idna - idna.__init__: idna - idna.codec: idna - idna.compat: idna - idna.core: idna - idna.idnadata: idna - idna.intranges: idna - idna.package_data: idna - idna.uts46data: idna - packaging: packaging - packaging.__about__: packaging - packaging.__init__: packaging - packaging._manylinux: packaging - packaging._musllinux: packaging - packaging._structures: packaging - packaging.markers: packaging - packaging.requirements: packaging - packaging.specifiers: packaging - packaging.tags: packaging - packaging.utils: packaging - packaging.version: packaging - proto: proto_plus - proto.__init__: proto_plus - proto._file_info: proto_plus - proto._package_info: proto_plus - proto.datetime_helpers: proto_plus - proto.enums: proto_plus - proto.fields: proto_plus - proto.marshal: proto_plus - proto.marshal.__init__: proto_plus - proto.marshal.collections: proto_plus - proto.marshal.collections.__init__: proto_plus - proto.marshal.collections.maps: proto_plus - proto.marshal.collections.repeated: proto_plus - proto.marshal.compat: proto_plus - proto.marshal.marshal: proto_plus - proto.marshal.rules: proto_plus - proto.marshal.rules.__init__: proto_plus - proto.marshal.rules.bytes: proto_plus - proto.marshal.rules.dates: proto_plus - proto.marshal.rules.enums: proto_plus - proto.marshal.rules.message: proto_plus - proto.marshal.rules.stringy_numbers: proto_plus - proto.marshal.rules.struct: proto_plus - proto.marshal.rules.wrappers: proto_plus - proto.message: proto_plus - proto.modules: proto_plus - proto.primitives: proto_plus - proto.utils: proto_plus - pyasn1: pyasn1 - pyasn1.__init__: pyasn1 - pyasn1.codec: pyasn1 - pyasn1.codec.__init__: pyasn1 - pyasn1.codec.ber: pyasn1 - pyasn1.codec.ber.__init__: pyasn1 - pyasn1.codec.ber.decoder: pyasn1 - pyasn1.codec.ber.encoder: pyasn1 - pyasn1.codec.ber.eoo: pyasn1 - pyasn1.codec.cer: pyasn1 - pyasn1.codec.cer.__init__: pyasn1 - pyasn1.codec.cer.decoder: pyasn1 - pyasn1.codec.cer.encoder: pyasn1 - pyasn1.codec.der: pyasn1 - pyasn1.codec.der.__init__: pyasn1 - pyasn1.codec.der.decoder: pyasn1 - pyasn1.codec.der.encoder: pyasn1 - pyasn1.codec.native: pyasn1 - pyasn1.codec.native.__init__: pyasn1 - pyasn1.codec.native.decoder: pyasn1 - pyasn1.codec.native.encoder: pyasn1 - pyasn1.compat: pyasn1 - pyasn1.compat.__init__: pyasn1 - pyasn1.compat.binary: pyasn1 - pyasn1.compat.calling: pyasn1 - pyasn1.compat.dateandtime: pyasn1 - pyasn1.compat.integer: pyasn1 - pyasn1.compat.octets: pyasn1 - pyasn1.compat.string: pyasn1 - pyasn1.debug: pyasn1 - pyasn1.error: pyasn1 - pyasn1.type: pyasn1 - pyasn1.type.__init__: pyasn1 - pyasn1.type.base: pyasn1 - pyasn1.type.char: pyasn1 - pyasn1.type.constraint: pyasn1 - pyasn1.type.error: pyasn1 - pyasn1.type.namedtype: pyasn1 - pyasn1.type.namedval: pyasn1 - pyasn1.type.opentype: pyasn1 - pyasn1.type.tag: pyasn1 - pyasn1.type.tagmap: pyasn1 - pyasn1.type.univ: pyasn1 - pyasn1.type.useful: pyasn1 - pyasn1_modules: pyasn1_modules - pyasn1_modules.__init__: pyasn1_modules - pyasn1_modules.pem: pyasn1_modules - pyasn1_modules.rfc1155: pyasn1_modules - pyasn1_modules.rfc1157: pyasn1_modules - pyasn1_modules.rfc1901: pyasn1_modules - pyasn1_modules.rfc1902: pyasn1_modules - pyasn1_modules.rfc1905: pyasn1_modules - pyasn1_modules.rfc2251: pyasn1_modules - pyasn1_modules.rfc2314: pyasn1_modules - pyasn1_modules.rfc2315: pyasn1_modules - pyasn1_modules.rfc2437: pyasn1_modules - pyasn1_modules.rfc2459: pyasn1_modules - pyasn1_modules.rfc2511: pyasn1_modules - pyasn1_modules.rfc2560: pyasn1_modules - pyasn1_modules.rfc2631: pyasn1_modules - pyasn1_modules.rfc2634: pyasn1_modules - pyasn1_modules.rfc2985: pyasn1_modules - pyasn1_modules.rfc2986: pyasn1_modules - pyasn1_modules.rfc3114: pyasn1_modules - pyasn1_modules.rfc3161: pyasn1_modules - pyasn1_modules.rfc3274: pyasn1_modules - pyasn1_modules.rfc3279: pyasn1_modules - pyasn1_modules.rfc3280: pyasn1_modules - pyasn1_modules.rfc3281: pyasn1_modules - pyasn1_modules.rfc3412: pyasn1_modules - pyasn1_modules.rfc3414: pyasn1_modules - pyasn1_modules.rfc3447: pyasn1_modules - pyasn1_modules.rfc3560: pyasn1_modules - pyasn1_modules.rfc3565: pyasn1_modules - pyasn1_modules.rfc3709: pyasn1_modules - pyasn1_modules.rfc3770: pyasn1_modules - pyasn1_modules.rfc3779: pyasn1_modules - pyasn1_modules.rfc3852: pyasn1_modules - pyasn1_modules.rfc4043: pyasn1_modules - pyasn1_modules.rfc4055: pyasn1_modules - pyasn1_modules.rfc4073: pyasn1_modules - pyasn1_modules.rfc4108: pyasn1_modules - pyasn1_modules.rfc4210: pyasn1_modules - pyasn1_modules.rfc4211: pyasn1_modules - pyasn1_modules.rfc4334: pyasn1_modules - pyasn1_modules.rfc4985: pyasn1_modules - pyasn1_modules.rfc5035: pyasn1_modules - pyasn1_modules.rfc5083: pyasn1_modules - pyasn1_modules.rfc5084: pyasn1_modules - pyasn1_modules.rfc5208: pyasn1_modules - pyasn1_modules.rfc5280: pyasn1_modules - pyasn1_modules.rfc5480: pyasn1_modules - pyasn1_modules.rfc5649: pyasn1_modules - pyasn1_modules.rfc5652: pyasn1_modules - pyasn1_modules.rfc5751: pyasn1_modules - pyasn1_modules.rfc5755: pyasn1_modules - pyasn1_modules.rfc5913: pyasn1_modules - pyasn1_modules.rfc5914: pyasn1_modules - pyasn1_modules.rfc5915: pyasn1_modules - pyasn1_modules.rfc5916: pyasn1_modules - pyasn1_modules.rfc5917: pyasn1_modules - pyasn1_modules.rfc5924: pyasn1_modules - pyasn1_modules.rfc5934: pyasn1_modules - pyasn1_modules.rfc5940: pyasn1_modules - pyasn1_modules.rfc5958: pyasn1_modules - pyasn1_modules.rfc5990: pyasn1_modules - pyasn1_modules.rfc6010: pyasn1_modules - pyasn1_modules.rfc6019: pyasn1_modules - pyasn1_modules.rfc6031: pyasn1_modules - pyasn1_modules.rfc6032: pyasn1_modules - pyasn1_modules.rfc6120: pyasn1_modules - pyasn1_modules.rfc6170: pyasn1_modules - pyasn1_modules.rfc6187: pyasn1_modules - pyasn1_modules.rfc6210: pyasn1_modules - pyasn1_modules.rfc6211: pyasn1_modules - pyasn1_modules.rfc6402: pyasn1_modules - pyasn1_modules.rfc6402-1: pyasn1_modules - pyasn1_modules.rfc6482: pyasn1_modules - pyasn1_modules.rfc6486: pyasn1_modules - pyasn1_modules.rfc6487: pyasn1_modules - pyasn1_modules.rfc6664: pyasn1_modules - pyasn1_modules.rfc6955: pyasn1_modules - pyasn1_modules.rfc6960: pyasn1_modules - pyasn1_modules.rfc7030: pyasn1_modules - pyasn1_modules.rfc7191: pyasn1_modules - pyasn1_modules.rfc7229: pyasn1_modules - pyasn1_modules.rfc7292: pyasn1_modules - pyasn1_modules.rfc7296: pyasn1_modules - pyasn1_modules.rfc7508: pyasn1_modules - pyasn1_modules.rfc7585: pyasn1_modules - pyasn1_modules.rfc7633: pyasn1_modules - pyasn1_modules.rfc7773: pyasn1_modules - pyasn1_modules.rfc7894: pyasn1_modules - pyasn1_modules.rfc7894-1: pyasn1_modules - pyasn1_modules.rfc7906: pyasn1_modules - pyasn1_modules.rfc7914: pyasn1_modules - pyasn1_modules.rfc8017: pyasn1_modules - pyasn1_modules.rfc8018: pyasn1_modules - pyasn1_modules.rfc8103: pyasn1_modules - pyasn1_modules.rfc8209: pyasn1_modules - pyasn1_modules.rfc8226: pyasn1_modules - pyasn1_modules.rfc8358: pyasn1_modules - pyasn1_modules.rfc8360: pyasn1_modules - pyasn1_modules.rfc8398: pyasn1_modules - pyasn1_modules.rfc8410: pyasn1_modules - pyasn1_modules.rfc8418: pyasn1_modules - pyasn1_modules.rfc8419: pyasn1_modules - pyasn1_modules.rfc8479: pyasn1_modules - pyasn1_modules.rfc8494: pyasn1_modules - pyasn1_modules.rfc8520: pyasn1_modules - pyasn1_modules.rfc8619: pyasn1_modules - pyasn1_modules.rfc8649: pyasn1_modules - pyparsing: pyparsing - pyparsing.__init__: pyparsing - pyparsing.actions: pyparsing - pyparsing.common: pyparsing - pyparsing.core: pyparsing - pyparsing.diagram: pyparsing - pyparsing.diagram.__init__: pyparsing - pyparsing.exceptions: pyparsing - pyparsing.helpers: pyparsing - pyparsing.results: pyparsing - pyparsing.testing: pyparsing - pyparsing.unicode: pyparsing - pyparsing.util: pyparsing - requests: requests - requests.__init__: requests - requests.__version__: requests - requests._internal_utils: requests - requests.adapters: requests - requests.api: requests - requests.auth: requests - requests.certs: requests - requests.compat: requests - requests.cookies: requests - requests.exceptions: requests - requests.help: requests - requests.hooks: requests - requests.models: requests - requests.packages: requests - requests.sessions: requests - requests.status_codes: requests - requests.structures: requests - requests.utils: requests - rsa: rsa - rsa.__init__: rsa - rsa._compat: rsa - rsa.asn1: rsa - rsa.cli: rsa - rsa.common: rsa - rsa.core: rsa - rsa.key: rsa - rsa.parallel: rsa - rsa.pem: rsa - rsa.pkcs1: rsa - rsa.pkcs1_v2: rsa - rsa.prime: rsa - rsa.randnum: rsa - rsa.transform: rsa - rsa.util: rsa - samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_create_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_delete_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_get_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_list_folders_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_move_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_search_folders_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_set_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_test_iam_permissions_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_undelete_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_folders_update_folder_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_get_organization_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_search_organizations_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_set_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_organizations_test_iam_permissions_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_create_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_delete_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_get_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_list_projects_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_move_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_search_projects_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_set_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_test_iam_permissions_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_undelete_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_projects_update_project_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_create_tag_binding_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_delete_tag_binding_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_bindings_list_tag_bindings_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_create_tag_key_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_delete_tag_key_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_get_tag_key_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_list_tag_keys_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_set_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_test_iam_permissions_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_keys_update_tag_key_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_create_tag_value_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_delete_tag_value_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_get_tag_value_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_list_tag_values_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_set_iam_policy_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_test_iam_permissions_sync: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_async: google_cloud_resource_manager - samples.generated_samples.cloudresourcemanager_v3_generated_tag_values_update_tag_value_sync: google_cloud_resource_manager - scripts.fixup_resourcemanager_v3_keywords: google_cloud_resource_manager - scripts.readme-gen.readme_gen: google_cloud_resource_manager - six: six - tests: google_cloud_resource_manager - tests.__init__: google_cloud_resource_manager - tests.unit: google_cloud_resource_manager - tests.unit.__init__: google_cloud_resource_manager - tests.unit.gapic: google_cloud_resource_manager - tests.unit.gapic.__init__: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.__init__: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_folders: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_organizations: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_projects: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_tag_bindings: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_tag_keys: google_cloud_resource_manager - tests.unit.gapic.resourcemanager_v3.test_tag_values: google_cloud_resource_manager - urllib3: urllib3 - urllib3.__init__: urllib3 - urllib3._collections: urllib3 - urllib3._version: urllib3 - urllib3.connection: urllib3 - urllib3.connectionpool: urllib3 - urllib3.contrib: urllib3 - urllib3.contrib.__init__: urllib3 - urllib3.contrib._appengine_environ: urllib3 - urllib3.contrib._securetransport: urllib3 - urllib3.contrib._securetransport.__init__: urllib3 - urllib3.contrib._securetransport.bindings: urllib3 - urllib3.contrib._securetransport.low_level: urllib3 - urllib3.contrib.appengine: urllib3 - urllib3.contrib.ntlmpool: urllib3 - urllib3.contrib.pyopenssl: urllib3 - urllib3.contrib.securetransport: urllib3 - urllib3.contrib.socks: urllib3 - urllib3.exceptions: urllib3 - urllib3.fields: urllib3 - urllib3.filepost: urllib3 - urllib3.packages: urllib3 - urllib3.packages.__init__: urllib3 - urllib3.packages.backports: urllib3 - urllib3.packages.backports.__init__: urllib3 - urllib3.packages.backports.makefile: urllib3 - urllib3.packages.six: urllib3 - urllib3.poolmanager: urllib3 - urllib3.request: urllib3 - urllib3.response: urllib3 - urllib3.util: urllib3 - urllib3.util.__init__: urllib3 - urllib3.util.connection: urllib3 - urllib3.util.proxy: urllib3 - urllib3.util.queue: urllib3 - urllib3.util.request: urllib3 - urllib3.util.response: urllib3 - urllib3.util.retry: urllib3 - urllib3.util.ssl_: urllib3 - urllib3.util.ssl_match_hostname: urllib3 - urllib3.util.ssltransport: urllib3 - urllib3.util.timeout: urllib3 - urllib3.util.url: urllib3 - urllib3.util.wait: urllib3 - pip_repository: - name: gazelle_python_test - incremental: true -integrity: 32e38932043eca090a64ca741758d8e4a5817c2cd7dc821fc927914c32fb3114 diff --git a/gazelle/testdata/with_third_party_requirements_from_imports/test.yaml b/gazelle/testdata/with_third_party_requirements_from_imports/test.yaml deleted file mode 100644 index ed97d539c0..0000000000 --- a/gazelle/testdata/with_third_party_requirements_from_imports/test.yaml +++ /dev/null @@ -1 +0,0 @@ ---- From cc27e41dc10be18d2896aacc572f2145a236acc3 Mon Sep 17 00:00:00 2001 From: Alex Rudy Date: Fri, 26 May 2023 19:13:26 +0000 Subject: [PATCH 8/8] Revert .bzl sources in gazelle to older version --- gazelle/def.bzl | 18 +-- gazelle/deps.bzl | 79 +++++++----- gazelle/manifest/BUILD.bazel | 10 -- gazelle/manifest/defs.bzl | 112 ++++-------------- gazelle/manifest/generate/BUILD.bazel | 15 +-- gazelle/manifest/generate/generate.go | 68 ++--------- gazelle/manifest/manifest.go | 62 +++++----- gazelle/manifest/manifest_test.go | 37 +----- gazelle/manifest/test/BUILD.bazel | 20 +++- gazelle/manifest/test/run.sh | 8 ++ gazelle/manifest/test/test.go | 73 +++++------- gazelle/manifest/testdata/gazelle_python.yaml | 2 +- gazelle/modules_mapping/BUILD.bazel | 6 - gazelle/modules_mapping/def.bzl | 26 +--- gazelle/modules_mapping/generator.py | 105 ++++++---------- 15 files changed, 217 insertions(+), 424 deletions(-) create mode 100755 gazelle/manifest/test/run.sh diff --git a/gazelle/def.bzl b/gazelle/def.bzl index 80b11576e6..a402fc74c4 100644 --- a/gazelle/def.bzl +++ b/gazelle/def.bzl @@ -1,21 +1,7 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - """This module contains the Gazelle runtime dependencies for the Python extension. """ GAZELLE_PYTHON_RUNTIME_DEPS = [ - "@rules_python_gazelle_plugin//python:parse", - "@rules_python_gazelle_plugin//python:std_modules", + "@rules_python//gazelle:parse", + "@rules_python//gazelle:std_modules", ] diff --git a/gazelle/deps.bzl b/gazelle/deps.bzl index 26f8c66aec..15150c9afb 100644 --- a/gazelle/deps.bzl +++ b/gazelle/deps.bzl @@ -1,18 +1,4 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"This file managed by `bazel run //:gazelle_update_repos`" +"This file managed by `bazel run //:update_go_deps`" load("@bazel_gazelle//:deps.bzl", _go_repository = "go_repository") @@ -28,7 +14,12 @@ def gazelle_deps(): sum = "h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs=", version = "v0.0.0-20190523083050-ea95bdfd59fc", ) - + go_repository( + name = "com_github_bazelbuild_bazel_gazelle", + importpath = "github.com/bazelbuild/bazel-gazelle", + sum = "h1:+/ZhUxlDy4XnyMIGeKkbRZoIGssy1eO51GijwIvvuwE=", + version = "v0.27.0", + ) go_repository( name = "com_github_bazelbuild_buildtools", build_naming_convention = "go_default_library", @@ -36,14 +27,24 @@ def gazelle_deps(): sum = "h1:jhiMzJ+8unnLRtV8rpbWBFE9pFNzIqgUTyZU5aA++w8=", version = "v0.0.0-20221004120235-7186f635531b", ) - + go_repository( + name = "com_github_bazelbuild_rules_go", + importpath = "github.com/bazelbuild/rules_go", + sum = "h1:ViPR65vOrg74JKntAUFY6qZkheBKGB6to7wFd8gCRU4=", + version = "v0.35.0", + ) go_repository( name = "com_github_bmatcuk_doublestar", importpath = "github.com/bmatcuk/doublestar", sum = "h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=", version = "v1.3.4", ) - + go_repository( + name = "com_github_bmatcuk_doublestar_v4", + importpath = "github.com/bmatcuk/doublestar/v4", + sum = "h1:Qu+u9wR3Vd89LnlLMHvnZ5coJMWKQamqdz9/p5GNthA=", + version = "v4.2.0", + ) go_repository( name = "com_github_burntsushi_toml", importpath = "github.com/BurntSushi/toml", @@ -98,7 +99,12 @@ def gazelle_deps(): sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=", version = "v0.1.0", ) - + go_repository( + name = "com_github_fsnotify_fsnotify", + importpath = "github.com/fsnotify/fsnotify", + sum = "h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=", + version = "v1.5.4", + ) go_repository( name = "com_github_ghodss_yaml", importpath = "github.com/ghodss/yaml", @@ -114,14 +120,14 @@ def gazelle_deps(): go_repository( name = "com_github_golang_mock", importpath = "github.com/golang/mock", - sum = "h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=", - version = "v1.1.1", + sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=", + version = "v1.6.0", ) go_repository( name = "com_github_golang_protobuf", importpath = "github.com/golang/protobuf", - sum = "h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=", - version = "v1.4.3", + sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=", + version = "v1.5.2", ) go_repository( name = "com_github_google_go_cmp", @@ -129,7 +135,24 @@ def gazelle_deps(): sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", version = "v0.5.9", ) - + go_repository( + name = "com_github_google_uuid", + importpath = "github.com/google/uuid", + sum = "h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=", + version = "v1.3.0", + ) + go_repository( + name = "com_github_pelletier_go_toml", + importpath = "github.com/pelletier/go-toml", + sum = "h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=", + version = "v1.9.5", + ) + go_repository( + name = "com_github_pmezard_go_difflib", + importpath = "github.com/pmezard/go-difflib", + sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", + version = "v1.0.0", + ) go_repository( name = "com_github_prometheus_client_model", importpath = "github.com/prometheus/client_model", @@ -187,8 +210,8 @@ def gazelle_deps(): go_repository( name = "org_golang_google_protobuf", importpath = "google.golang.org/protobuf", - sum = "h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=", - version = "v1.25.0", + sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=", + version = "v1.28.0", ) go_repository( name = "org_golang_x_crypto", @@ -229,8 +252,8 @@ def gazelle_deps(): go_repository( name = "org_golang_x_sync", importpath = "golang.org/x/sync", - sum = "h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=", - version = "v0.0.0-20220722155255-886fb9371eb4", + sum = "h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=", + version = "v0.0.0-20220907140024-f12130a52804", ) go_repository( name = "org_golang_x_sys", diff --git a/gazelle/manifest/BUILD.bazel b/gazelle/manifest/BUILD.bazel index fc7fa09632..281bcd29cf 100644 --- a/gazelle/manifest/BUILD.bazel +++ b/gazelle/manifest/BUILD.bazel @@ -17,13 +17,3 @@ go_test( data = glob(["testdata/**"]), deps = [":manifest"], ) - -filegroup( - name = "distribution", - srcs = glob(["**"]) + [ - "//manifest/generate:distribution", - "//manifest/hasher:distribution", - "//manifest/test:distribution", - ], - visibility = ["//:__pkg__"], -) diff --git a/gazelle/manifest/defs.bzl b/gazelle/manifest/defs.bzl index 05562a1583..8439319238 100644 --- a/gazelle/manifest/defs.bzl +++ b/gazelle/manifest/defs.bzl @@ -1,39 +1,24 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - """This module provides the gazelle_python_manifest macro that contains targets for updating and testing the Gazelle manifest file. """ -load("@io_bazel_rules_go//go:def.bzl", "GoSource", "go_binary", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_binary") def gazelle_python_manifest( name, requirements, modules_mapping, pip_repository_name = "", + pip_repository_incremental = False, pip_deps_repository_name = "", - manifest = ":gazelle_python.yaml", - use_pip_repository_aliases = False): + manifest = ":gazelle_python.yaml"): """A macro for defining the updating and testing targets for the Gazelle manifest file. Args: name: the name used as a base for the targets. requirements: the target for the requirements.txt file. pip_repository_name: the name of the pip_install or pip_repository target. - use_pip_repository_aliases: boolean flag to enable using user-friendly - python package aliases. + pip_repository_incremental: the incremental property of pip_repository. pip_deps_repository_name: deprecated - the old pip_install target name. modules_mapping: the target for the generated modules_mapping.json file. manifest: the target for the Gazelle manifest file. @@ -53,11 +38,7 @@ def gazelle_python_manifest( update_target = "{}.update".format(name) update_target_label = "//{}:{}".format(native.package_name(), update_target) - manifest_generator_hash = Label("//manifest/generate:generate_lib_sources_hash") - update_args = [ - "--manifest-generator-hash", - "$(rootpath {})".format(manifest_generator_hash), "--requirements", "$(rootpath {})".format(requirements), "--pip-repository-name", @@ -69,43 +50,45 @@ def gazelle_python_manifest( "--update-target", update_target_label, ] - - if use_pip_repository_aliases: - update_args += [ - "--use-pip-repository-aliases", - "true", - ] + if pip_repository_incremental: + update_args.append("--pip-repository-incremental") go_binary( name = update_target, - embed = [Label("//manifest/generate:generate_lib")], + embed = ["@rules_python//gazelle/manifest/generate:generate_lib"], data = [ manifest, modules_mapping, requirements, - manifest_generator_hash, ], args = update_args, visibility = ["//visibility:private"], tags = ["manual"], ) - go_test( + test_binary = "_{}_test_bin".format(name) + + go_binary( + name = test_binary, + embed = ["@rules_python//gazelle/manifest/test:test_lib"], + visibility = ["//visibility:private"], + ) + + native.sh_test( name = "{}.test".format(name), - srcs = [Label("//manifest/test:test.go")], + srcs = ["@rules_python//gazelle/manifest/test:run.sh"], data = [ + ":{}".format(test_binary), manifest, requirements, - manifest_generator_hash, ], env = { + "_TEST_BINARY": "$(rootpath :{})".format(test_binary), "_TEST_MANIFEST": "$(rootpath {})".format(manifest), - "_TEST_MANIFEST_GENERATOR_HASH": "$(rootpath {})".format(manifest_generator_hash), "_TEST_REQUIREMENTS": "$(rootpath {})".format(requirements), }, - rundir = ".", - deps = [Label("//manifest")], - size = "small", + visibility = ["//visibility:private"], + timeout = "short", ) native.filegroup( @@ -114,56 +97,3 @@ def gazelle_python_manifest( tags = ["manual"], visibility = ["//visibility:public"], ) - -# buildifier: disable=provider-params -AllSourcesInfo = provider(fields = {"all_srcs": "All sources collected from the target and dependencies."}) - -_rules_python_workspace = Label("@rules_python//:WORKSPACE") - -def _get_all_sources_impl(target, ctx): - is_rules_python = target.label.workspace_name == _rules_python_workspace.workspace_name - if not is_rules_python: - # Avoid adding third-party dependency files to the checksum of the srcs. - return AllSourcesInfo(all_srcs = depset()) - srcs = depset( - target[GoSource].orig_srcs, - transitive = [dep[AllSourcesInfo].all_srcs for dep in ctx.rule.attr.deps], - ) - return [AllSourcesInfo(all_srcs = srcs)] - -_get_all_sources = aspect( - implementation = _get_all_sources_impl, - attr_aspects = ["deps"], -) - -def _sources_hash_impl(ctx): - all_srcs = ctx.attr.go_library[AllSourcesInfo].all_srcs - hash_file = ctx.actions.declare_file(ctx.attr.name + ".hash") - args = ctx.actions.args() - args.add(hash_file) - args.add_all(all_srcs) - ctx.actions.run( - outputs = [hash_file], - inputs = all_srcs, - arguments = [args], - executable = ctx.executable._hasher, - ) - return [DefaultInfo( - files = depset([hash_file]), - runfiles = ctx.runfiles([hash_file]), - )] - -sources_hash = rule( - _sources_hash_impl, - attrs = { - "go_library": attr.label( - aspects = [_get_all_sources], - providers = [GoSource], - ), - "_hasher": attr.label( - cfg = "exec", - default = Label("//manifest/hasher"), - executable = True, - ), - }, -) diff --git a/gazelle/manifest/generate/BUILD.bazel b/gazelle/manifest/generate/BUILD.bazel index 96248f4e08..29b9f15628 100644 --- a/gazelle/manifest/generate/BUILD.bazel +++ b/gazelle/manifest/generate/BUILD.bazel @@ -1,18 +1,11 @@ load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") -load("//manifest:defs.bzl", "sources_hash") go_library( name = "generate_lib", srcs = ["generate.go"], importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/generate", visibility = ["//visibility:public"], - deps = ["//manifest"], -) - -sources_hash( - name = "generate_lib_sources_hash", - go_library = ":generate_lib", - visibility = ["//visibility:public"], + deps = ["//gazelle/manifest"], ) go_binary( @@ -20,9 +13,3 @@ go_binary( embed = [":generate_lib"], visibility = ["//visibility:public"], ) - -filegroup( - name = "distribution", - srcs = glob(["**"]), - visibility = ["//manifest:__pkg__"], -) diff --git a/gazelle/manifest/generate/generate.go b/gazelle/manifest/generate/generate.go index 1f56e630cc..04d7441fd2 100644 --- a/gazelle/manifest/generate/generate.go +++ b/gazelle/manifest/generate/generate.go @@ -1,17 +1,3 @@ -// Copyright 2023 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - /* generate.go is a program that generates the Gazelle YAML manifest. @@ -38,21 +24,12 @@ func init() { } func main() { - var ( - manifestGeneratorHashPath string - requirementsPath string - pipRepositoryName string - usePipRepositoryAliases bool - modulesMappingPath string - outputPath string - updateTarget string - ) - flag.StringVar( - &manifestGeneratorHashPath, - "manifest-generator-hash", - "", - "The file containing the hash for the source code of the manifest generator."+ - "This is important to force manifest updates when the generator logic changes.") + var requirementsPath string + var pipRepositoryName string + var pipRepositoryIncremental bool + var modulesMappingPath string + var outputPath string + var updateTarget string flag.StringVar( &requirementsPath, "requirements", @@ -64,10 +41,10 @@ func main() { "", "The name of the pip_install or pip_repository target.") flag.BoolVar( - &usePipRepositoryAliases, - "use-pip-repository-aliases", + &pipRepositoryIncremental, + "pip-repository-incremental", false, - "Whether to use the pip-repository aliases, which are generated when passing 'incompatible_generate_aliases = True'.") + "The value for the incremental option in pip_repository.") flag.StringVar( &modulesMappingPath, "modules-mapping", @@ -111,17 +88,11 @@ func main() { manifestFile := manifest.NewFile(&manifest.Manifest{ ModulesMapping: modulesMapping, PipRepository: &manifest.PipRepository{ - Name: pipRepositoryName, - UsePipRepositoryAliases: usePipRepositoryAliases, + Name: pipRepositoryName, + Incremental: pipRepositoryIncremental, }, }) - if err := writeOutput( - outputPath, - header, - manifestFile, - manifestGeneratorHashPath, - requirementsPath, - ); err != nil { + if err := writeOutput(outputPath, header, manifestFile, requirementsPath); err != nil { log.Fatalf("ERROR: %v\n", err) } } @@ -158,7 +129,6 @@ func writeOutput( outputPath string, header string, manifestFile *manifest.File, - manifestGeneratorHashPath string, requirementsPath string, ) error { stat, err := os.Stat(outputPath) @@ -176,19 +146,7 @@ func writeOutput( return fmt.Errorf("failed to write output: %w", err) } - manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath) - if err != nil { - return fmt.Errorf("failed to write output: %w", err) - } - defer manifestGeneratorHash.Close() - - requirements, err := os.Open(requirementsPath) - if err != nil { - return fmt.Errorf("failed to write output: %w", err) - } - defer requirements.Close() - - if err := manifestFile.Encode(outputFile, manifestGeneratorHash, requirements); err != nil { + if err := manifestFile.Encode(outputFile, requirementsPath); err != nil { return fmt.Errorf("failed to write output: %w", err) } diff --git a/gazelle/manifest/manifest.go b/gazelle/manifest/manifest.go index c49951dd3e..e19162bd5d 100644 --- a/gazelle/manifest/manifest.go +++ b/gazelle/manifest/manifest.go @@ -1,17 +1,3 @@ -// Copyright 2023 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package manifest import ( @@ -40,8 +26,12 @@ func NewFile(manifest *Manifest) *File { } // Encode encodes the manifest file to the given writer. -func (f *File) Encode(w io.Writer, manifestGeneratorHashFile, requirements io.Reader) error { - integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements) +func (f *File) Encode(w io.Writer, requirementsPath string) error { + requirementsChecksum, err := sha256File(requirementsPath) + if err != nil { + return fmt.Errorf("failed to encode manifest file: %w", err) + } + integrityBytes, err := f.calculateIntegrity(requirementsChecksum) if err != nil { return fmt.Errorf("failed to encode manifest file: %w", err) } @@ -55,8 +45,12 @@ func (f *File) Encode(w io.Writer, manifestGeneratorHashFile, requirements io.Re } // VerifyIntegrity verifies if the integrity set in the File is valid. -func (f *File) VerifyIntegrity(manifestGeneratorHashFile, requirements io.Reader) (bool, error) { - integrityBytes, err := f.calculateIntegrity(manifestGeneratorHashFile, requirements) +func (f *File) VerifyIntegrity(requirementsPath string) (bool, error) { + requirementsChecksum, err := sha256File(requirementsPath) + if err != nil { + return false, fmt.Errorf("failed to verify integrity: %w", err) + } + integrityBytes, err := f.calculateIntegrity(requirementsChecksum) if err != nil { return false, fmt.Errorf("failed to verify integrity: %w", err) } @@ -68,9 +62,7 @@ func (f *File) VerifyIntegrity(manifestGeneratorHashFile, requirements io.Reader // provided checksum for the requirements.txt file used as input to the modules // mapping, plus the manifest structure in the manifest file. This integrity // calculation ensures the manifest files are kept up-to-date. -func (f *File) calculateIntegrity( - manifestGeneratorHash, requirements io.Reader, -) ([]byte, error) { +func (f *File) calculateIntegrity(requirementsChecksum []byte) ([]byte, error) { hash := sha256.New() // Sum the manifest part of the file. @@ -80,13 +72,8 @@ func (f *File) calculateIntegrity( return nil, fmt.Errorf("failed to calculate integrity: %w", err) } - // Sum the manifest generator checksum bytes. - if _, err := io.Copy(hash, manifestGeneratorHash); err != nil { - return nil, fmt.Errorf("failed to calculate integrity: %w", err) - } - // Sum the requirements.txt checksum bytes. - if _, err := io.Copy(hash, requirements); err != nil { + if _, err := hash.Write(requirementsChecksum); err != nil { return nil, fmt.Errorf("failed to calculate integrity: %w", err) } @@ -144,7 +131,22 @@ type Manifest struct { type PipRepository struct { // The name of the pip_install or pip_repository target. Name string - // UsePipRepositoryAliases allows to use aliases generated pip_repository - // when passing incompatible_generate_aliases = True. - UsePipRepositoryAliases bool `yaml:"use_pip_repository_aliases,omitempty"` + // The incremental property of pip_repository. + Incremental bool +} + +// sha256File calculates the checksum of a given file path. +func sha256File(filePath string) ([]byte, error) { + file, err := os.Open(filePath) + if err != nil { + return nil, fmt.Errorf("failed to calculate sha256 sum for file: %w", err) + } + defer file.Close() + + hash := sha256.New() + if _, err := io.Copy(hash, file); err != nil { + return nil, fmt.Errorf("failed to calculate sha256 sum for file: %w", err) + } + + return hash.Sum(nil), nil } diff --git a/gazelle/manifest/manifest_test.go b/gazelle/manifest/manifest_test.go index 43c4099aa1..3b50fd1b3e 100644 --- a/gazelle/manifest/manifest_test.go +++ b/gazelle/manifest/manifest_test.go @@ -1,25 +1,10 @@ -// Copyright 2023 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package manifest_test import ( "bytes" + "io/ioutil" "log" - "os" "reflect" - "strings" "testing" "github.com/bazelbuild/rules_python/gazelle/manifest" @@ -46,18 +31,11 @@ func TestFile(t *testing.T) { PipDepsRepositoryName: pipDepsRepositoryName, }) var b bytes.Buffer - manifestGeneratorHashFile := strings.NewReader("") - requirements, err := os.Open("testdata/requirements.txt") - if err != nil { - log.Println(err) - t.FailNow() - } - defer requirements.Close() - if err := f.Encode(&b, manifestGeneratorHashFile, requirements); err != nil { + if err := f.Encode(&b, "testdata/requirements.txt"); err != nil { log.Println(err) t.FailNow() } - expected, err := os.ReadFile("testdata/gazelle_python.yaml") + expected, err := ioutil.ReadFile("testdata/gazelle_python.yaml") if err != nil { log.Println(err) t.FailNow() @@ -88,14 +66,7 @@ func TestFile(t *testing.T) { log.Println(err) t.FailNow() } - manifestGeneratorHashFile := strings.NewReader("") - requirements, err := os.Open("testdata/requirements.txt") - if err != nil { - log.Println(err) - t.FailNow() - } - defer requirements.Close() - valid, err := f.VerifyIntegrity(manifestGeneratorHashFile, requirements) + valid, err := f.VerifyIntegrity("testdata/requirements.txt") if err != nil { log.Println(err) t.FailNow() diff --git a/gazelle/manifest/test/BUILD.bazel b/gazelle/manifest/test/BUILD.bazel index 28c6c548d9..f14845f756 100644 --- a/gazelle/manifest/test/BUILD.bazel +++ b/gazelle/manifest/test/BUILD.bazel @@ -1,9 +1,17 @@ -# gazelle:ignore +load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") -exports_files(["test.go"]) +go_library( + name = "test_lib", + srcs = ["test.go"], + importpath = "github.com/bazelbuild/rules_python/gazelle/manifest/test", + visibility = ["//visibility:public"], + deps = ["//gazelle/manifest"], +) -filegroup( - name = "distribution", - srcs = glob(["**"]), - visibility = ["//manifest:__pkg__"], +go_binary( + name = "test", + embed = [":test_lib"], + visibility = ["//visibility:public"], ) + +exports_files(["run.sh"]) diff --git a/gazelle/manifest/test/run.sh b/gazelle/manifest/test/run.sh new file mode 100755 index 0000000000..4b24b51ae4 --- /dev/null +++ b/gazelle/manifest/test/run.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# This file exists to allow passing the runfile paths to the Go program via +# environment variables. + +set -o errexit -o nounset + +"${_TEST_BINARY}" --requirements "${_TEST_REQUIREMENTS}" --manifest "${_TEST_MANIFEST}" \ No newline at end of file diff --git a/gazelle/manifest/test/test.go b/gazelle/manifest/test/test.go index 72cb260d4d..518fe06eb6 100644 --- a/gazelle/manifest/test/test.go +++ b/gazelle/manifest/test/test.go @@ -1,78 +1,63 @@ -// Copyright 2023 The Bazel Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - /* -test.go is a unit test that asserts the Gazelle YAML manifest is up-to-date in +test.go is a program that asserts the Gazelle YAML manifest is up-to-date in regards to the requirements.txt. It re-hashes the requirements.txt and compares it to the recorded one in the existing generated Gazelle manifest. */ -package test +package main import ( - "os" + "flag" + "log" "path/filepath" - "testing" "github.com/bazelbuild/rules_python/gazelle/manifest" ) -func TestGazelleManifestIsUpdated(t *testing.T) { - requirementsPath := os.Getenv("_TEST_REQUIREMENTS") +func main() { + var requirementsPath string + var manifestPath string + flag.StringVar( + &requirementsPath, + "requirements", + "", + "The requirements.txt file.") + flag.StringVar( + &manifestPath, + "manifest", + "", + "The manifest YAML file.") + flag.Parse() + if requirementsPath == "" { - t.Fatalf("_TEST_REQUIREMENTS must be set") + log.Fatalln("ERROR: --requirements must be set") } - manifestPath := os.Getenv("_TEST_MANIFEST") if manifestPath == "" { - t.Fatalf("_TEST_MANIFEST must be set") + log.Fatalln("ERROR: --manifest must be set") } manifestFile := new(manifest.File) if err := manifestFile.Decode(manifestPath); err != nil { - t.Fatalf("decoding manifest file: %v", err) + log.Fatalf("ERROR: %v\n", err) } if manifestFile.Integrity == "" { - t.Fatal("failed to find the Gazelle manifest file integrity") - } - - manifestGeneratorHashPath := os.Getenv("_TEST_MANIFEST_GENERATOR_HASH") - manifestGeneratorHash, err := os.Open(manifestGeneratorHashPath) - if err != nil { - t.Fatalf("opening %q: %v", manifestGeneratorHashPath, err) - } - defer manifestGeneratorHash.Close() - - requirements, err := os.Open(requirementsPath) - if err != nil { - t.Fatalf("opening %q: %v", requirementsPath, err) + log.Fatalln("ERROR: failed to find the Gazelle manifest file integrity") } - defer requirements.Close() - valid, err := manifestFile.VerifyIntegrity(manifestGeneratorHash, requirements) + valid, err := manifestFile.VerifyIntegrity(requirementsPath) if err != nil { - t.Fatalf("verifying integrity: %v", err) + log.Fatalf("ERROR: %v\n", err) } if !valid { manifestRealpath, err := filepath.EvalSymlinks(manifestPath) if err != nil { - t.Fatalf("evaluating symlink %q: %v", manifestPath, err) + log.Fatalf("ERROR: %v\n", err) } - t.Errorf( - "%q is out-of-date. Follow the update instructions in that file to resolve this", + log.Fatalf( + "ERROR: %q is out-of-date, follow the intructions on this file for updating.\n", manifestRealpath) } -} +} \ No newline at end of file diff --git a/gazelle/manifest/testdata/gazelle_python.yaml b/gazelle/manifest/testdata/gazelle_python.yaml index 70f7aff19a..4dc1f2c545 100644 --- a/gazelle/manifest/testdata/gazelle_python.yaml +++ b/gazelle/manifest/testdata/gazelle_python.yaml @@ -10,4 +10,4 @@ manifest: arrow.parser: arrow arrow.util: arrow pip_deps_repository_name: test_repository_name -integrity: eedf187f8b7ec27cdfc682feee4206e063b51d13d78f77c05d3a30ec11bd7411 +integrity: 624f5f6c078eb44b907efd5a64e308354ac3620c568232b815668bcdf3e3366a diff --git a/gazelle/modules_mapping/BUILD.bazel b/gazelle/modules_mapping/BUILD.bazel index 1855551a80..d1cd42e7d9 100644 --- a/gazelle/modules_mapping/BUILD.bazel +++ b/gazelle/modules_mapping/BUILD.bazel @@ -5,9 +5,3 @@ py_binary( srcs = ["generator.py"], visibility = ["//visibility:public"], ) - -filegroup( - name = "distribution", - srcs = glob(["**"]), - visibility = ["//:__pkg__"], -) diff --git a/gazelle/modules_mapping/def.bzl b/gazelle/modules_mapping/def.bzl index 54fc8add80..04ea50facd 100644 --- a/gazelle/modules_mapping/def.bzl +++ b/gazelle/modules_mapping/def.bzl @@ -1,17 +1,3 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - """Definitions for the modules_mapping.json generation. The modules_mapping.json file is a mapping from Python modules to the wheel @@ -26,9 +12,8 @@ module name doesn't match the wheel distribution name. def _modules_mapping_impl(ctx): modules_mapping = ctx.actions.declare_file(ctx.attr.modules_mapping_name) args = ctx.actions.args() - args.add("--output_file", modules_mapping.path) - args.add_all("--exclude_patterns", ctx.attr.exclude_patterns) - args.add_all("--wheels", [whl.path for whl in ctx.files.wheels]) + args.add(modules_mapping.path) + args.add_all([whl.path for whl in ctx.files.wheels]) ctx.actions.run( inputs = ctx.files.wheels, outputs = [modules_mapping], @@ -41,11 +26,6 @@ def _modules_mapping_impl(ctx): modules_mapping = rule( _modules_mapping_impl, attrs = { - "exclude_patterns": attr.string_list( - default = ["^_|(\\._)+"], - doc = "A set of regex patterns to match against each calculated module path. By default, exclude the modules starting with underscores.", - mandatory = False, - ), "modules_mapping_name": attr.string( default = "modules_mapping.json", doc = "The name for the output JSON file.", @@ -58,7 +38,7 @@ modules_mapping = rule( ), "_generator": attr.label( cfg = "exec", - default = "//modules_mapping:generator", + default = "//gazelle/modules_mapping:generator", executable = True, ), }, diff --git a/gazelle/modules_mapping/generator.py b/gazelle/modules_mapping/generator.py index be57eac3bc..ec3133af0e 100644 --- a/gazelle/modules_mapping/generator.py +++ b/gazelle/modules_mapping/generator.py @@ -1,21 +1,5 @@ -# Copyright 2023 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import argparse import json import pathlib -import re import sys import zipfile @@ -24,69 +8,36 @@ class Generator: stderr = None output_file = None - excluded_patterns = None - mapping = {} - def __init__(self, stderr, output_file, excluded_patterns): + def __init__(self, stderr, output_file): self.stderr = stderr self.output_file = output_file - self.excluded_patterns = [re.compile(pattern) for pattern in excluded_patterns] # dig_wheel analyses the wheel .whl file determining the modules it provides # by looking at the directory structure. def dig_wheel(self, whl): + mapping = {} with zipfile.ZipFile(whl, "r") as zip_file: for path in zip_file.namelist(): if is_metadata(path): if data_has_purelib_or_platlib(path): - self.module_for_path(path, whl) + module_for_path(path, whl, mapping) else: continue else: - self.module_for_path(path, whl) - - def module_for_path(self, path, whl): - ext = pathlib.Path(path).suffix - if ext == ".py" or ext == ".so": - if "purelib" in path or "platlib" in path: - root = "/".join(path.split("/")[2:]) - else: - root = path - - wheel_name = get_wheel_name(whl) - - if root.endswith("/__init__.py"): - # Note the '/' here means that the __init__.py is not in the - # root of the wheel, therefore we can index the directory - # where this file is as an importable package. - module = root[: -len("/__init__.py")].replace("/", ".") - if not self.is_excluded(module): - self.mapping[module] = wheel_name - - # Always index the module file. - if ext == ".so": - # Also remove extra metadata that is embeded as part of - # the file name as an extra extension. - ext = "".join(pathlib.Path(root).suffixes) - module = root[: -len(ext)].replace("/", ".") - if not self.is_excluded(module): - self.mapping[module] = wheel_name - - def is_excluded(self, module): - for pattern in self.excluded_patterns: - if pattern.search(module): - return True - return False + module_for_path(path, whl, mapping) + return mapping # run is the entrypoint for the generator. def run(self, wheels): + mapping = {} for whl in wheels: try: - self.dig_wheel(whl) + mapping.update(self.dig_wheel(whl)) except AssertionError as error: print(error, file=self.stderr) return 1 - mapping_json = json.dumps(self.mapping) + mapping_json = json.dumps(mapping) with open(self.output_file, "w") as f: f.write(mapping_json) return 0 @@ -120,14 +71,34 @@ def data_has_purelib_or_platlib(path): return is_metadata(path) and (maybe_lib == "purelib" or maybe_lib == "platlib") +def module_for_path(path, whl, mapping): + ext = pathlib.Path(path).suffix + if ext == ".py" or ext == ".so": + if "purelib" in path or "platlib" in path: + root = "/".join(path.split("/")[2:]) + else: + root = path + + wheel_name = get_wheel_name(whl) + + if root.endswith("/__init__.py"): + # Note the '/' here means that the __init__.py is not in the + # root of the wheel, therefore we can index the directory + # where this file is as an importable package. + module = root[: -len("/__init__.py")].replace("/", ".") + mapping[module] = wheel_name + + # Always index the module file. + if ext == ".so": + # Also remove extra metadata that is embeded as part of + # the file name as an extra extension. + ext = "".join(pathlib.Path(root).suffixes) + module = root[: -len(ext)].replace("/", ".") + mapping[module] = wheel_name + + if __name__ == "__main__": - parser = argparse.ArgumentParser( - prog="generator", - description="Generates the modules mapping used by the Gazelle manifest.", - ) - parser.add_argument("--output_file", type=str) - parser.add_argument("--exclude_patterns", nargs="+", default=[]) - parser.add_argument("--wheels", nargs="+", default=[]) - args = parser.parse_args() - generator = Generator(sys.stderr, args.output_file, args.exclude_patterns) - exit(generator.run(args.wheels)) + output_file = sys.argv[1] + wheels = sys.argv[2:] + generator = Generator(sys.stderr, output_file) + exit(generator.run(wheels))