Skip to content

feat: add bzl_library for defs.bzl and its dependencies #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 19 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,30 @@ 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:srcs_version.bzl",
"@bazel_tools//tools/python:toolchain.bzl",
"@bazel_tools//tools/python:utils.bzl",
],
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