blob: a5f4d2da3e18582999ee2890e9a686b40f68265e [file]
# Copyright 2021 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
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(":py_exec_tools_toolchain.bzl", "current_interpreter_executable")
load(":py_interpreter_program.bzl", "py_interpreter_program")
load(":sentinel_impl.bzl", "sentinel")
load(":stamp_impl.bzl", "stamp_build_setting")
load(":uncachable_version_file.bzl", "define_uncachable_version_file")
load(":visibility.bzl", "NOT_ACTUALLY_PUBLIC")
package(
default_visibility = [
"//:__subpackages__",
],
)
licenses(["notice"])
exports_files([
"runtime_env_toolchain_interpreter.sh",
"runtimes_manifest.txt",
"runtimes_manifest_workspace.bzl",
])
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(
name = "coverage_deps_filegroup",
srcs = ["coverage_deps.bzl"],
visibility = ["//tools/private/update_deps:__pkg__"],
)
# Filegroup of bzl files that can be used by downstream rules for documentation generation
filegroup(
name = "bzl",
srcs = glob(["**/*.bzl"]),
visibility = ["//python:__pkg__"],
)
alias(
name = "build_data_writer",
actual = select({
"@platforms//os:windows": ":build_data_writer.ps1",
"//conditions:default": ":build_data_writer.sh",
}),
# Not actually public. Only public because it's an implicit dependency of
# rules built via py_binary_rule_builder() / py_test_rule_builder().
visibility = ["//visibility:public"],
)
define_uncachable_version_file(
name = "uncachable_version_file",
# Not actually public. Only public because it's an implicit dependency of
# rules built via py_binary_rule_builder() / py_test_rule_builder().
visibility = ["//visibility:public"],
)
# 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.)
exports_files(
[
"coverage.patch",
"py_package.bzl",
"py_wheel.bzl",
"version.bzl",
"reexports.bzl",
"stamp_impl.bzl",
"util.bzl",
],
visibility = ["//:__subpackages__"],
)
exports_files(
["python_bootstrap_template.txt"],
# Not actually public. Only public because it's an implicit dependency of
# py_runtime.
visibility = NOT_ACTUALLY_PUBLIC,
)
filegroup(
name = "stage1_bootstrap_template",
srcs = ["stage1_bootstrap_template.sh"],
# Not actually public. Only public because it's an implicit dependency of
# py_runtime.
visibility = NOT_ACTUALLY_PUBLIC,
)
filegroup(
name = "stage2_bootstrap_template",
srcs = ["stage2_bootstrap_template.py"],
# Not actually public. Only public because it's an implicit dependency of
# py_runtime.
visibility = NOT_ACTUALLY_PUBLIC,
)
filegroup(
name = "site_init_template",
srcs = ["site_init_template.py"],
# Not actually public. Only public because it's an implicit dependency of
# py_runtime.
visibility = NOT_ACTUALLY_PUBLIC,
)
# NOTE: Windows builds don't use this bootstrap. Instead, a native Windows
# program locates some Python exe and runs `python.exe foo.zip` which
# runs the __main__.py in the zip file.
alias(
name = "bootstrap_template",
actual = select({
":is_script_bootstrap_enabled": "stage1_bootstrap_template.sh",
"//conditions:default": "python_bootstrap_template.txt",
}),
# Not actually public. Only public because it's an implicit dependency of
# py_runtime.
visibility = NOT_ACTUALLY_PUBLIC,
)
# Used to determine the use of `--stamp` in Starlark rules
stamp_build_setting(name = "stamp")
config_setting(
name = "is_script_bootstrap_enabled",
flag_values = {
"//python/config_settings:bootstrap_impl": "script",
},
)
config_setting(
name = "is_bazel_config_mode_target",
flag_values = {
"//python/private:bazel_config_mode": "target",
},
)
alias(
name = "debugger_if_target_config",
actual = select({
":is_bazel_config_mode_target": "//python/config_settings:debugger",
"//conditions:default": "//python/private:empty",
}),
# Not actually public. Only public because it's an implicit dependency of
# rules built via py_binary_rule_builder() / py_test_rule_builder().
visibility = ["//visibility:public"],
)
bazel_config_mode(name = "bazel_config_mode")
# This should only be set by analysis tests to expose additional metadata to
# aid testing, so a setting instead of a flag.
bool_flag(
name = "visible_for_testing",
build_setting_default = False,
# This is only because it is an implicit dependency by the toolchains.
visibility = NOT_ACTUALLY_PUBLIC,
)
# Used for py_console_script_gen rule
py_binary(
name = "py_console_script_gen_py",
srcs = ["py_console_script_gen.py"],
main = "py_console_script_gen.py",
visibility = [
"//visibility:public",
],
)
py_binary(
name = "py_wheel_dist",
srcs = ["py_wheel_dist.py"],
visibility = ["//visibility:public"],
)
py_library(
name = "py_console_script_gen_lib",
srcs = ["py_console_script_gen.py"],
imports = ["../.."],
visibility = [
"//tests/entry_points:__pkg__",
],
)
# The current toolchain's interpreter as an excutable, usable with
# executable=True attributes.
current_interpreter_executable(
name = "current_interpreter_executable",
# Not actually public. Only public because it's an implicit dependency of
# py_exec_tools_toolchain.
visibility = NOT_ACTUALLY_PUBLIC,
)
py_library(
name = "empty",
# Not actually public. Only public because it's the resolved default of
# debugger_if_target_config, an implicit dependency of rules built via
# py_binary_rule_builder() / py_test_rule_builder().
visibility = ["//visibility:public"],
)
sentinel(
name = "sentinel",
# Not actually public. Only public because it's the resolved default of
# uncachable_version_file, an implicit dependency of rules built via
# py_binary_rule_builder() / py_test_rule_builder().
visibility = ["//visibility:public"],
)
py_binary(
name = "sync_runtimes_manifest_workspace",
srcs = ["tools/sync_runtimes_manifest_workspace.py"],
visibility = ["//:__subpackages__"],
)
# Tool used by py_test's validation action to statically check that the main
# module actually runs tests. See the validate_test_main config setting.
py_interpreter_program(
name = "py_test_main_validator",
main = "py_test_main_validator.py",
# Not actually public. Only public because it's an implicit dependency of
# the py_test rule.
visibility = NOT_ACTUALLY_PUBLIC,
)
py_library(
name = "py_test_main_validator_lib",
srcs = ["py_test_main_validator.py"],
imports = ["../.."],
visibility = [
"//tests/validate_test_main:__pkg__",
],
)
bzl_library(
name = "attr_builders",
srcs = ["attr_builders.bzl"],
deps = [
":builders_util",
"@bazel_skylib//lib:types",
],
)
bzl_library(
name = "attributes",
srcs = ["attributes.bzl"],
deps = [
":attr_builders",
":common_labels",
":enum",
":flags",
":py_info",
":reexports",
":rule_builders",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//rules:common_settings",
"@rules_cc//cc/common",
],
)
bzl_library(
name = "auth",
srcs = ["auth.bzl"],
deps = ["//python/private:bazel_tools"],
)
# @bazel_tools can't define bzl_library itself, so we just put a wrapper around it.
# Keep this target because Gazelle does not automatically generate
# bzl_library targets for external repositories like @bazel_tools.
# keep
bzl_library(
name = "bazel_tools",
srcs = [
# This set of sources is overly broad, but it's the only public
# target available across Bazel versions that has all the necessary
# sources.
"@bazel_tools//tools:bzl_srcs",
],
)
bzl_library(
name = "builders",
srcs = ["builders.bzl"],
deps = ["@bazel_skylib//lib:types"],
)
bzl_library(
name = "builders_util",
srcs = ["builders_util.bzl"],
deps = [
":bzlmod_enabled",
"@bazel_skylib//lib:types",
],
)
bzl_library(
name = "cc_helper",
srcs = ["cc_helper.bzl"],
deps = [":py_internal"],
)
bzl_library(
name = "common",
srcs = ["common.bzl"],
deps = [
":builders",
":cc_helper",
":py_cc_link_params_info",
":py_info",
":py_internal",
":py_interpreter_program",
":reexports",
":toolchain_types",
"@bazel_skylib//lib:paths",
"@rules_cc//cc/common",
"@rules_python_internal//:rules_python_config",
],
)
bzl_library(
name = "config_settings",
srcs = ["config_settings.bzl"],
deps = [
":text_util",
":version",
":visibility",
"@bazel_skylib//lib:selects",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "coverage_deps",
srcs = ["coverage_deps.bzl"],
deps = [
":version_label",
"//python/private:bazel_tools",
],
)
bzl_library(
name = "current_py_cc_headers",
srcs = ["current_py_cc_headers.bzl"],
deps = [
":toolchain_types",
"@rules_cc//cc/common",
],
)
bzl_library(
name = "current_py_cc_libs",
srcs = ["current_py_cc_libs.bzl"],
deps = ["@rules_cc//cc/common"],
)
bzl_library(
name = "deprecation",
srcs = ["deprecation.bzl"],
deps = ["@rules_python_internal//:rules_python_config"],
)
bzl_library(
name = "flags",
srcs = ["flags.bzl"],
deps = [
":enum",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "hermetic_runtime_repo_setup",
srcs = ["hermetic_runtime_repo_setup.bzl"],
deps = [
":py_exec_tools_toolchain",
":version",
"//python:py_runtime",
"//python:py_runtime_pair",
"//python/cc:py_cc_toolchain",
"@rules_cc//cc:core_rules",
],
)
bzl_library(
name = "internal_config_repo",
srcs = ["internal_config_repo.bzl"],
deps = [
":repo_utils",
":text_util",
],
)
bzl_library(
name = "interpreter",
srcs = ["interpreter.bzl"],
deps = [
":common",
":sentinel_impl",
":toolchain_types",
"//python:py_runtime_info",
"@bazel_skylib//lib:paths",
],
)
bzl_library(
name = "is_standalone_interpreter",
srcs = ["is_standalone_interpreter.bzl"],
deps = [":repo_utils"],
)
bzl_library(
name = "local_runtime_repo",
srcs = ["local_runtime_repo.bzl"],
deps = [
":enum",
":repo_utils",
],
)
bzl_library(
name = "local_runtime_repo_setup",
srcs = ["local_runtime_repo_setup.bzl"],
deps = [
"@bazel_skylib//lib:selects",
"@rules_cc//cc:core_rules",
"@rules_python//python:py_runtime",
"@rules_python//python:py_runtime_pair",
"@rules_python//python/cc:py_cc_toolchain",
"@rules_python//python/private:py_exec_tools_toolchain",
],
)
bzl_library(
name = "local_runtime_toolchains_repo",
srcs = ["local_runtime_toolchains_repo.bzl"],
deps = [
":repo_utils",
":text_util",
],
)
bzl_library(
name = "precompile",
srcs = ["precompile.bzl"],
deps = [
":attributes",
":flags",
":py_interpreter_program",
":toolchain_types",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_binary_macro",
srcs = ["py_binary_macro.bzl"],
deps = [
":py_binary_rule",
":py_executable",
],
)
bzl_library(
name = "py_binary_rule",
srcs = ["py_binary_rule.bzl"],
deps = [
":attributes",
":py_executable",
],
)
bzl_library(
name = "py_cc_link_params_info",
srcs = ["py_cc_link_params_info.bzl"],
deps = ["@rules_cc//cc/common"],
)
bzl_library(
name = "py_cc_toolchain_macro",
srcs = ["py_cc_toolchain_macro.bzl"],
deps = [
":py_cc_toolchain_rule",
":util",
],
)
bzl_library(
name = "py_cc_toolchain_rule",
srcs = ["py_cc_toolchain_rule.bzl"],
deps = [
":common_labels",
":py_cc_toolchain_info",
":sentinel_impl",
"@bazel_skylib//rules:common_settings",
"@rules_cc//cc/common",
],
)
bzl_library(
name = "py_console_script_binary",
srcs = ["py_console_script_binary.bzl"],
deps = [
":py_console_script_gen",
"//python:py_binary",
],
)
bzl_library(
name = "py_exec_tools_toolchain",
srcs = ["py_exec_tools_toolchain.bzl"],
deps = [
":common_labels",
":py_exec_tools_info",
":sentinel_impl",
":toolchain_types",
"@bazel_skylib//lib:paths",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_executable",
srcs = ["py_executable.bzl"],
deps = [
":attr_builders",
":attributes",
":builders",
":cc_helper",
":common",
":common_labels",
":flags",
":precompile",
":py_cc_link_params_info",
":py_executable_info",
":py_info",
":py_internal",
":py_runtime_info",
":reexports",
":rule_builders",
":toolchain_types",
":transition_labels",
":venv_runfiles",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//lib:paths",
"@bazel_skylib//lib:structs",
"@bazel_skylib//rules:common_settings",
"@rules_cc//cc/common",
"@rules_python_internal//:rules_python_config",
],
)
bzl_library(
name = "py_info",
srcs = ["py_info.bzl"],
deps = [
":builders",
":reexports",
],
)
bzl_library(
name = "py_internal",
srcs = ["py_internal.bzl"],
deps = ["//tools/build_defs/python/private:py_internal_renamed"],
)
bzl_library(
name = "py_interpreter_program",
srcs = ["py_interpreter_program.bzl"],
deps = [
":sentinel_impl",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_library",
srcs = ["py_library.bzl"],
deps = [
":attr_builders",
":attributes",
":builders",
":common",
":common_labels",
":flags",
":normalize_name",
":precompile",
":py_cc_link_params_info",
":py_info",
":reexports",
":rule_builders",
":toolchain_types",
":venv_runfiles",
":version",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//lib:paths",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_library_macro",
srcs = ["py_library_macro.bzl"],
deps = [":py_library_rule"],
)
bzl_library(
name = "py_library_rule",
srcs = ["py_library_rule.bzl"],
deps = [":py_library"],
)
bzl_library(
name = "py_package",
srcs = ["py_package.bzl"],
deps = [
":builders",
":py_info",
],
)
bzl_library(
name = "py_repositories",
srcs = ["py_repositories.bzl"],
deps = [
":internal_config_repo",
":pythons_hub",
"//python:versions",
"//python/private:bazel_tools",
"//python/private/pypi:deps",
],
)
bzl_library(
name = "py_runtime_macro",
srcs = ["py_runtime_macro.bzl"],
deps = [":py_runtime_rule"],
)
bzl_library(
name = "py_runtime_pair_macro",
srcs = ["py_runtime_pair_macro.bzl"],
deps = [":py_runtime_pair_rule"],
)
bzl_library(
name = "py_runtime_pair_rule",
srcs = ["py_runtime_pair_rule.bzl"],
deps = [
":common_labels",
":reexports",
"//python:py_runtime_info",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_runtime_rule",
srcs = ["py_runtime_rule.bzl"],
deps = [
":common_labels",
":flags",
":py_internal",
":py_runtime_info",
":reexports",
":version",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//lib:paths",
"@bazel_skylib//rules:common_settings",
],
)
bzl_library(
name = "py_test_macro",
srcs = ["py_test_macro.bzl"],
deps = [
":py_executable",
":py_test_rule",
],
)
bzl_library(
name = "py_test_rule",
srcs = ["py_test_rule.bzl"],
deps = [
":attributes",
":common",
":py_executable",
],
)
bzl_library(
name = "py_toolchain_suite",
srcs = ["py_toolchain_suite.bzl"],
deps = [
":text_util",
":toolchain_types",
"@bazel_skylib//lib:selects",
"@platforms//host:constraints_lib",
],
)
bzl_library(
name = "py_wheel",
srcs = ["py_wheel.bzl"],
deps = [
":attributes",
":py_info",
":py_package",
":rule_builders",
":stamp_impl",
":transition_labels",
":version",
],
)
bzl_library(
name = "python",
srcs = ["python.bzl"],
deps = [
":auth",
":full_version",
":pbs_manifest",
":platform_info",
":pyproject_utils",
":python_register_toolchains",
":pythons_hub",
":repo_utils",
":toolchains_repo",
":version",
"//python:versions",
"@bazel_features//:features",
],
)
bzl_library(
name = "python_register_multi_toolchains",
srcs = ["python_register_multi_toolchains.bzl"],
deps = [
":python_register_toolchains",
":toolchains_repo",
"//python:versions",
],
)
bzl_library(
name = "python_register_toolchains",
srcs = ["python_register_toolchains.bzl"],
deps = [
":coverage_deps",
":full_version",
":python_repository",
":toolchains_repo",
"//python:versions",
],
)
bzl_library(
name = "python_repository",
srcs = ["python_repository.bzl"],
deps = [
":auth",
":repo_utils",
":text_util",
"//python:versions",
],
)
bzl_library(
name = "pythons_hub",
srcs = ["pythons_hub.bzl"],
deps = [
":pbs_manifest",
":text_util",
":toolchains_repo",
"//python:versions",
],
)
bzl_library(
name = "reexports",
srcs = ["reexports.bzl"],
deps = ["@rules_python_internal//:rules_python_config"],
)
bzl_library(
name = "repl",
srcs = ["repl.bzl"],
deps = ["//python:py_binary"],
)
bzl_library(
name = "rule_builders",
srcs = ["rule_builders.bzl"],
deps = [
":builders_util",
"@bazel_skylib//lib:types",
],
)
# Keep this target because Gazelle does not automatically generate or
# maintain composite bzl_library targets. We need this to group external
# dependency sources.
# keep
bzl_library(
name = "rules_cc_srcs",
srcs = [
# rules_cc 0.0.13 and earlier load cc_proto_libary (and thus protobuf@),
# but their bzl srcs targets don't transitively refer to protobuf.
"@com_google_protobuf//:bzl_srcs",
# NOTE: As of rules_cc 0.10, cc:bzl_srcs no longer contains
# everything and sub-targets must be used instead
"@rules_cc//cc:bzl_srcs",
"@rules_cc//cc/common",
"@rules_cc//cc/toolchains:toolchain_rules",
],
deps = [
":bazel_tools",
"@rules_cc//cc/common",
],
)
bzl_library(
name = "runtime_env_repo",
srcs = ["runtime_env_repo.bzl"],
deps = [":repo_utils"],
)
bzl_library(
name = "runtime_env_toolchain",
srcs = ["runtime_env_toolchain.bzl"],
deps = [
":config_settings",
":py_exec_tools_toolchain",
":toolchain_types",
"//python:py_runtime",
"//python:py_runtime_pair",
"//python/cc:py_cc_toolchain",
"@rules_cc//cc:core_rules",
],
)
bzl_library(
name = "toolchain_aliases",
srcs = ["toolchain_aliases.bzl"],
deps = [
"//python:versions",
"@bazel_skylib//lib:selects",
],
)
bzl_library(
name = "toolchains_repo",
srcs = ["toolchains_repo.bzl"],
deps = [
":repo_utils",
":text_util",
"//python:versions",
],
)
bzl_library(
name = "transition_labels",
srcs = ["transition_labels.bzl"],
deps = [
":common_labels",
"@bazel_skylib//lib:collections",
"@rules_python_internal//:extra_transition_settings",
],
)
bzl_library(
name = "util",
srcs = ["util.bzl"],
deps = [
":py_internal",
"@bazel_skylib//lib:types",
],
)
bzl_library(
name = "venv_runfiles",
srcs = ["venv_runfiles.bzl"],
deps = [
":common",
":py_info",
":util",
"@bazel_skylib//lib:paths",
],
)
bzl_library(
name = "pyproject_utils",
srcs = ["pyproject_utils.bzl"],
deps = [
":version",
"@toml.bzl//:toml",
],
)
bzl_library(
name = "stamp_impl",
srcs = ["stamp_impl.bzl"],
deps = [":visibility"],
)
bzl_library(
name = "bzlmod_enabled",
srcs = ["bzlmod_enabled.bzl"],
)
bzl_library(
name = "common_labels",
srcs = ["common_labels.bzl"],
)
bzl_library(
name = "enum",
srcs = ["enum.bzl"],
)
bzl_library(
name = "envsubst",
srcs = ["envsubst.bzl"],
)
bzl_library(
name = "full_version",
srcs = ["full_version.bzl"],
)
bzl_library(
name = "normalize_name",
srcs = ["normalize_name.bzl"],
)
bzl_library(
name = "pbs_manifest",
srcs = ["pbs_manifest.bzl"],
)
bzl_library(
name = "platform_info",
srcs = ["platform_info.bzl"],
)
bzl_library(
name = "py_cc_toolchain_info",
srcs = ["py_cc_toolchain_info.bzl"],
)
bzl_library(
name = "py_console_script_gen",
srcs = ["py_console_script_gen.bzl"],
)
bzl_library(
name = "py_exec_tools_info",
srcs = ["py_exec_tools_info.bzl"],
)
bzl_library(
name = "py_executable_info",
srcs = ["py_executable_info.bzl"],
)
bzl_library(
name = "py_runtime_info",
srcs = ["py_runtime_info.bzl"],
)
bzl_library(
name = "repo_utils",
srcs = ["repo_utils.bzl"],
)
bzl_library(
name = "runtimes_manifest_workspace",
srcs = ["runtimes_manifest_workspace.bzl"],
)
bzl_library(
name = "sentinel_impl",
srcs = ["sentinel_impl.bzl"],
)
bzl_library(
name = "text_util",
srcs = ["text_util.bzl"],
)
bzl_library(
name = "toolchain_types",
srcs = ["toolchain_types.bzl"],
)
bzl_library(
name = "version",
srcs = ["version.bzl"],
)
bzl_library(
name = "version_label",
srcs = ["version_label.bzl"],
)
bzl_library(
name = "visibility",
srcs = ["visibility.bzl"],
)