| load("@bazel_gazelle//:def.bzl", "gazelle_binary") |
| load("@io_bazel_rules_go//go:def.bzl", "go_library") |
| load("@rules_python//python:defs.bzl", "py_binary", "py_test") |
| load(":gazelle_test.bzl", "gazelle_test") |
| |
| go_library( |
| name = "python", |
| srcs = [ |
| "configure.go", |
| "fix.go", |
| "generate.go", |
| "kinds.go", |
| "language.go", |
| "lifecycle.go", |
| "parser.go", |
| "resolve.go", |
| "std_modules.go", |
| "target.go", |
| ], |
| # NOTE @aignas 2023-12-03: currently gazelle does not support embedding |
| # generated files, but helper.zip is generated by a build rule. |
| # |
| # You will get a benign error like when running gazelle locally: |
| # > 8 gazelle: .../rules_python/gazelle/python/lifecycle.go:26:3: pattern helper.zip: matched no files |
| # |
| # See following for more info: |
| # https://github.com/bazelbuild/bazel-gazelle/issues/1513 |
| embedsrcs = [":helper.zip"], # keep |
| 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_v4//:doublestar", |
| "@com_github_emirpasic_gods//lists/singlylinkedlist", |
| "@com_github_emirpasic_gods//sets/treeset", |
| "@com_github_emirpasic_gods//utils", |
| ], |
| ) |
| |
| py_binary( |
| name = "helper", |
| srcs = [ |
| "__main__.py", |
| "parse.py", |
| "std_modules.py", |
| ], |
| # This is to make sure that the current directory is added to PYTHONPATH |
| imports = ["."], |
| main = "__main__.py", |
| visibility = ["//visibility:public"], |
| ) |
| |
| py_test( |
| name = "parse_test", |
| srcs = [ |
| "parse.py", |
| "parse_test.py", |
| ], |
| imports = ["."], |
| ) |
| |
| filegroup( |
| name = "helper.zip", |
| srcs = [":helper"], |
| output_group = "python_zip_file", |
| ) |
| |
| # gazelle:exclude testdata/ |
| |
| gazelle_test( |
| name = "python_test", |
| srcs = ["python_test.go"], |
| data = [ |
| ":gazelle_binary", |
| ":helper", |
| ], |
| test_dirs = glob( |
| # Use this so that we don't need to manually maintain the list. |
| ["testdata/*"], |
| exclude = ["testdata/*.md"], |
| # The directories aren't inputs themselves; we just want their |
| # names. |
| exclude_directories = 0, |
| ), |
| deps = [ |
| "@bazel_gazelle//testtools:go_default_library", |
| "@com_github_ghodss_yaml//:yaml", |
| "@io_bazel_rules_go//go/runfiles:go_default_library", |
| "@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__"], |
| ) |