Skip to content

Commit 7ffe2f7

Browse files
authored
feat: add bzl_library for defs.bzl and its dependencies (bazel-contrib#1115)
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 bazel-contrib#1069
1 parent 0ba98a6 commit 7ffe2f7

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

python/BUILD.bazel

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ In an ideal renaming, we'd move the packaging rules to a different package so
2323
that @rules_python//python is only concerned with the core rules.
2424
"""
2525

26+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2627
load(":defs.bzl", "current_py_toolchain")
2728

2829
package(default_visibility = ["//visibility:public"])
@@ -40,8 +41,19 @@ filegroup(
4041
visibility = ["//:__pkg__"],
4142
)
4243

44+
bzl_library(
45+
name = "defs_bzl",
46+
srcs = [
47+
"defs.bzl",
48+
],
49+
visibility = ["//visibility:public"],
50+
deps = [
51+
"//python/private:bazel_tools_bzl",
52+
"//python/private:reexports_bzl",
53+
],
54+
)
55+
4356
# Filegroup of bzl files that can be used by downstream rules for documentation generation
44-
# Using a filegroup rather than bzl_library to not give a transitive dependency on Skylib
4557
filegroup(
4658
name = "bzl",
4759
srcs = [

python/private/BUILD.bazel

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
1516
load("//python:versions.bzl", "print_toolchains_checksums")
1617
load(":stamp.bzl", "stamp_build_setting")
1718

@@ -24,13 +25,30 @@ filegroup(
2425
)
2526

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

34+
bzl_library(
35+
name = "reexports_bzl",
36+
srcs = ["reexports.bzl"],
37+
visibility = ["//python:__pkg__"],
38+
deps = [":bazel_tools_bzl"],
39+
)
40+
41+
# @bazel_tools can't define bzl_library itself, so we just put a wrapper around it.
42+
bzl_library(
43+
name = "bazel_tools_bzl",
44+
srcs = [
45+
"@bazel_tools//tools/python:srcs_version.bzl",
46+
"@bazel_tools//tools/python:toolchain.bzl",
47+
"@bazel_tools//tools/python:utils.bzl",
48+
],
49+
visibility = ["//python:__pkg__"],
50+
)
51+
3452
# Needed to define bzl_library targets for docgen. (We don't define the
3553
# bzl_library target here because it'd give our users a transitive dependency
3654
# on Skylib.)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy