Skip to content
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
6 changes: 3 additions & 3 deletions command_line_option/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# treated as aliases for `//command_line_option:XXX` psuedo-targets. They
# are not actual flags or have any value.

load("//python/private:distribution_filegroup.bzl", "distribution_filegroup") # buildifier: disable=bzl-visibility

package(
default_visibility = ["//visibility:public"],
)
Expand All @@ -23,8 +25,6 @@ alias(
actual = "//python:none",
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//:__subpackages__"],
)
20 changes: 2 additions & 18 deletions python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,15 @@ that @rules_python//python is only concerned with the core rules.
# gazelle:resolve starlark //python:current_py_toolchain.bzl //python:current_py_toolchain_bzl

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")
load(":current_py_toolchain.bzl", "current_py_toolchain")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//python/api:distribution",
"//python/bin:distribution",
"//python/cc:distribution",
"//python/config_settings:distribution",
"//python/constraints:distribution",
"//python/entry_points:distribution",
"//python/extensions:distribution",
"//python/local_toolchains:distribution",
"//python/pip_install:distribution",
"//python/private:distribution",
"//python/runfiles:distribution",
"//python/runtime_env_toolchains:distribution",
"//python/uv:distribution",
"//python/zipapp:distribution",
],
visibility = ["//:__pkg__"],
)

# ========= bzl_library targets end =========
Expand Down
4 changes: 2 additions & 2 deletions python/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(
default_visibility = ["//:__subpackages__"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
)

bzl_library(
Expand Down
7 changes: 4 additions & 3 deletions python/bin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")
load("//python/private:interpreter.bzl", _interpreter_binary = "interpreter_binary")
load("//python/private:repl.bzl", "py_repl_binary")

filegroup(
package(default_visibility = ["//:__subpackages__"])

distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//:__subpackages__"],
)

_interpreter_binary(
Expand Down
4 changes: 2 additions & 2 deletions python/cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED")
load("//python/private:current_py_cc_headers.bzl", "current_py_cc_headers", "current_py_cc_headers_abi3")
load("//python/private:current_py_cc_libs.bzl", "current_py_cc_libs")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(
default_visibility = ["//:__subpackages__"],
Expand Down Expand Up @@ -47,9 +48,8 @@ toolchain_type(
visibility = ["//visibility:public"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
)

bzl_library(
Expand Down
7 changes: 4 additions & 3 deletions python/config_settings/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@pythons_hub//:versions.bzl", "DEFAULT_PYTHON_VERSION", "MINOR_MAPPING", "PYTHON_VERSIONS")
load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")
load(
"//python/private:flags.bzl",
"AddSrcsToRunfilesFlag",
Expand All @@ -19,15 +20,15 @@ load("//python/private:visibility.bzl", "NOT_ACTUALLY_PUBLIC") # buildifier: di
load("//python/private/pypi:flags.bzl", "define_pypi_internal_flags")
load(":config_settings.bzl", "construct_config_settings")

package(default_visibility = ["//:__subpackages__"])

# We don't generate bzl_library for these because they aren't public targets
# and should be moved
# gazelle:exclude config_settings.bzl
# gazelle:exclude transition.bzl

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

construct_config_settings(
Expand Down
6 changes: 3 additions & 3 deletions python/constraints/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

# A constraint_setting to use for constraints related to the location of the
Expand Down
7 changes: 4 additions & 3 deletions python/entry_points/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

exports_files(
[
Expand All @@ -21,10 +24,8 @@ exports_files(
visibility = ["//docs:__subpackages__"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__subpackages__"],
)

bzl_library(
Expand Down
5 changes: 2 additions & 3 deletions python/extensions/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

bzl_library(
Expand Down
4 changes: 2 additions & 2 deletions python/local_toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
)

bzl_library(
Expand Down
5 changes: 2 additions & 3 deletions python/pip_install/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(
default_visibility = ["//:__subpackages__"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python:__pkg__"],
)

filegroup(
Expand Down
17 changes: 7 additions & 10 deletions python/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("//python:py_binary.bzl", "py_binary")
load("//python:py_library.bzl", "py_library")
load(":bazel_config_mode.bzl", "bazel_config_mode")
load(":distribution_filegroup.bzl", "distribution_filegroup")
load(":py_exec_tools_toolchain.bzl", "current_interpreter_executable")
load(":py_interpreter_program.bzl", "py_interpreter_program")
load(":sentinel_impl.bzl", "sentinel")
Expand All @@ -38,17 +39,8 @@ exports_files([
"runtimes_manifest_workspace.bzl",
])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]) + [
"//python/private/api:distribution",
"//python/private/cc:distribution",
"//python/private/pypi:distribution",
"//python/private/whl_filegroup:distribution",
"//python/private/zipapp:distribution",
"//tools/build_defs/python/private:distribution",
],
visibility = ["//python:__pkg__"],
)

filegroup(
Expand Down Expand Up @@ -942,6 +934,11 @@ bzl_library(
srcs = ["common_labels.bzl"],
)

bzl_library(
name = "distribution_filegroup",
srcs = ["distribution_filegroup.bzl"],
)

bzl_library(
name = "enum",
srcs = ["enum.bzl"],
Expand Down
4 changes: 2 additions & 2 deletions python/private/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")
load("//python/private:visibility.bzl", "NOT_ACTUALLY_PUBLIC")
load(":py_common_api.bzl", "py_common_api")

package(
default_visibility = ["//:__subpackages__"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
)

py_common_api(
Expand Down
4 changes: 2 additions & 2 deletions python/private/cc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")
load("//python/private:visibility.bzl", "NOT_ACTUALLY_PUBLIC")

package(
Expand All @@ -8,9 +9,8 @@ package(

licenses(["notice"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
)

# An empty cc target for use when a cc target is needed to satisfy
Expand Down
26 changes: 26 additions & 0 deletions python/private/distribution_filegroup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""Helper for defining distribution filegroups."""

def distribution_filegroup(name, exclude = None):
"""Defines a filegroup target for repository distribution.

Args:
name: The name of the filegroup target.
exclude: Optional list of subpackage patterns to exclude from automatic
subpackage discovery.
"""
exclude = exclude or []
pkg = native.package_name()
prefix = ("//" + pkg + "/") if pkg else "//"

srcs = native.glob(["**"])
for subpkg in native.subpackages(
include = ["*"],
exclude = exclude,
allow_empty = True,
):
srcs.append(prefix + subpkg + ":distribution")

native.filegroup(
name = name,
srcs = srcs,
)
11 changes: 2 additions & 9 deletions python/private/pypi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("//python:py_binary.bzl", "py_binary")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

Expand Down Expand Up @@ -70,16 +71,8 @@ exports_files(
visibility = ["//:__subpackages__"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(
["**"],
exclude = ["requirements.txt"],
) + [
"//python/private/pypi/dependency_resolver:distribution",
"//python/private/pypi/whl_installer:distribution",
],
visibility = ["//python/private:__pkg__"],
)

# Filegroup of bzl files that can be used by downstream rules for documentation generation
Expand Down
8 changes: 5 additions & 3 deletions python/private/pypi/dependency_resolver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

exports_files(["dependency_resolver.py"])

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["**"]),
visibility = ["//python/private/pypi:__subpackages__"],
)
7 changes: 7 additions & 0 deletions python/private/pypi/requirements_parser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

distribution_filegroup(
name = "distribution",
)
7 changes: 4 additions & 3 deletions python/private/pypi/whl_installer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
load("//python:py_binary.bzl", "py_binary")
load("//python:py_library.bzl", "py_library")
load("//python/private:distribution_filegroup.bzl", "distribution_filegroup")

package(default_visibility = ["//:__subpackages__"])

py_library(
name = "lib",
Expand All @@ -26,8 +29,6 @@ py_binary(
deps = [":lib"],
)

filegroup(
distribution_filegroup(
name = "distribution",
srcs = glob(["*"]),
visibility = ["//:__subpackages__"],
)
Loading