Skip to content

Commit

Permalink
fix: use 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 02159a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 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 @@ -41,8 +42,7 @@ 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(
bzl_library(
name = "bzl",
srcs = [
"defs.bzl",
Expand All @@ -54,6 +54,10 @@ filegroup(
"//python/private:bzl",
],
visibility = ["//visibility:public"],
deps = [
"//python/private:bazel_tools_bzl",
"//python/private:reexports_bzl",
],
)

# ========= Core rules =========
Expand Down
17 changes: 17 additions & 0 deletions 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 @@ -31,6 +32,22 @@ filegroup(
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 02159a0

Please sign in to comment.