Skip to content

Commit

Permalink
fix: add bzl_library for defs.bzl and its dependencies
Browse files Browse the repository at this point in the history
This is so that the transitive dependencies of defs.bzl can be easily
found and validated; some Google internal tooling does this validation.

The old comment indicated bzl_library wasn't used to avoid a dependency
on skylib, however, we've since added a dependency on skylib.

Work towards bazelbuild#1069
  • Loading branch information
rickeylev committed Mar 8, 2023
1 parent 0ba98a6 commit 5bc6e82
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
14 changes: 13 additions & 1 deletion python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ In an ideal renaming, we'd move the packaging rules to a different package so
that @rules_python//python is only concerned with the core rules.
"""

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":defs.bzl", "current_py_toolchain")

package(default_visibility = ["//visibility:public"])
Expand All @@ -40,8 +41,19 @@ filegroup(
visibility = ["//:__pkg__"],
)

bzl_library(
name = "defs_bzl",
srcs = [
"defs.bzl",
],
visibility = ["//visibility:public"],
deps = [
"//python/private:bazel_tools_bzl",
"//python/private:reexports_bzl",
],
)

# Filegroup of bzl files that can be used by downstream rules for documentation generation
# Using a filegroup rather than bzl_library to not give a transitive dependency on Skylib
filegroup(
name = "bzl",
srcs = [
Expand Down
18 changes: 17 additions & 1 deletion python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python:versions.bzl", "print_toolchains_checksums")
load(":stamp.bzl", "stamp_build_setting")

Expand All @@ -24,13 +25,28 @@ filegroup(
)

# Filegroup of bzl files that can be used by downstream rules for documentation generation
# Using a filegroup rather than bzl_library to not give a transitive dependency on Skylib
filegroup(
name = "bzl",
srcs = glob(["**/*.bzl"]),
visibility = ["//python:__pkg__"],
)

bzl_library(
name = "reexports_bzl",
srcs = ["reexports.bzl"],
visibility = ["//python:__pkg__"],
deps = [":bazel_tools_bzl"],
)

# @bazel_tools can't define bzl_library itself, so we just put a wrapper around it.
bzl_library(
name = "bazel_tools_bzl",
srcs = [
"@bazel_tools//tools/python:bzl_srcs",
],
visibility = ["//python:__pkg__"],
)

# Needed to define bzl_library targets for docgen. (We don't define the
# bzl_library target here because it'd give our users a transitive dependency
# on Skylib.)
Expand Down

0 comments on commit 5bc6e82

Please sign in to comment.