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
14 changes: 6 additions & 8 deletions python/private/common/attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ load(":py_internal.bzl", "py_internal")
load(
":semantics.bzl",
"DEPS_ATTR_ALLOW_RULES",
"PLATFORMS_LOCATION",
"SRCS_ATTR_ALLOW_FILES",
"TOOLS_REPO",
)

# TODO: Load CcInfo from rules_cc
Expand Down Expand Up @@ -72,7 +70,7 @@ def copy_common_test_kwargs(kwargs):
CC_TOOLCHAIN = {
# NOTE: The `cc_helper.find_cpp_toolchain()` function expects the attribute
# name to be this name.
"_cc_toolchain": attr.label(default = "@" + TOOLS_REPO + "//tools/cpp:current_cc_toolchain"),
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"),
}

# The common "data" attribute definition.
Expand Down Expand Up @@ -188,11 +186,11 @@ environment when the test is executed by bazel test.
# TODO(b/176993122): Remove when Bazel automatically knows to run on darwin.
"_apple_constraints": attr.label_list(
default = [
PLATFORMS_LOCATION + "/os:ios",
PLATFORMS_LOCATION + "/os:macos",
PLATFORMS_LOCATION + "/os:tvos",
PLATFORMS_LOCATION + "/os:visionos",
PLATFORMS_LOCATION + "/os:watchos",
"@platforms//os:ios",
"@platforms//os:macos",
"@platforms//os:tvos",
"@platforms//os:visionos",
"@platforms//os:watchos",
],
),
},
Expand Down
3 changes: 1 addition & 2 deletions python/private/common/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ load(
":semantics.bzl",
"NATIVE_RULES_MIGRATION_FIX_CMD",
"NATIVE_RULES_MIGRATION_HELP_URL",
"TOOLS_REPO",
)

_testing = testing
Expand All @@ -29,7 +28,7 @@ _coverage_common = coverage_common
_py_builtins = py_internal
PackageSpecificationInfo = getattr(py_internal, "PackageSpecificationInfo", None)

TOOLCHAIN_TYPE = "@" + TOOLS_REPO + "//tools/python:toolchain_type"
TOOLCHAIN_TYPE = "@bazel_tools//tools/python:toolchain_type"

# Extensions without the dot
_PYTHON_SOURCE_EXTENSIONS = ["py"]
Expand Down
3 changes: 1 addition & 2 deletions python/private/common/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
"""Providers for Python rules."""

load("@rules_python_internal//:rules_python_config.bzl", "config")
load(":semantics.bzl", "TOOLS_REPO")

# TODO: load CcInfo from rules_cc
_CcInfo = CcInfo

DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3"

DEFAULT_BOOTSTRAP_TEMPLATE = "@" + TOOLS_REPO + "//tools/python:python_bootstrap_template.txt"
DEFAULT_BOOTSTRAP_TEMPLATE = "@bazel_tools//tools/python:python_bootstrap_template.txt"
_PYTHON_VERSION_VALUES = ["PY2", "PY3"]

# Helper to make the provider definitions not crash under Bazel 5.4:
Expand Down
3 changes: 1 addition & 2 deletions python/private/common/py_binary_rule_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ load(
"create_executable_rule",
"py_executable_bazel_impl",
)
load(":semantics.bzl", "TOOLS_REPO")

_PY_TEST_ATTRS = {
"_collect_cc_coverage": attr.label(
default = "@" + TOOLS_REPO + "//tools/test:collect_cc_coverage",
default = "@bazel_tools//tools/test:collect_cc_coverage",
executable = True,
cfg = "exec",
),
Expand Down
6 changes: 2 additions & 4 deletions python/private/common/py_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ load(
"ALLOWED_MAIN_EXTENSIONS",
"BUILD_DATA_SYMLINK_PATH",
"IS_BAZEL",
"PLATFORMS_LOCATION",
"PY_RUNTIME_ATTR_NAME",
"TOOLS_REPO",
)

# TODO: Load cc_common from rules_cc
Expand All @@ -61,7 +59,7 @@ _py_builtins = py_internal

# Bazel 5.4 doesn't have config_common.toolchain_type
_CC_TOOLCHAINS = [config_common.toolchain_type(
"@" + TOOLS_REPO + "//tools/cpp:toolchain_type",
"@bazel_tools//tools/cpp:toolchain_type",
mandatory = False,
)] if hasattr(config_common, "toolchain_type") else []

Expand Down Expand Up @@ -97,7 +95,7 @@ filename in `srcs`, `main` must be specified.
),
"_windows_constraints": attr.label_list(
default = [
PLATFORMS_LOCATION + "/os:windows",
"@platforms//os:windows",
],
),
},
Expand Down
11 changes: 5 additions & 6 deletions python/private/common/py_executable_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ load(
"py_executable_base_impl",
)
load(":py_internal.bzl", "py_internal")
load(":semantics.bzl", "TOOLS_REPO")

_py_builtins = py_internal
_EXTERNAL_PATH_PREFIX = "external"
Expand All @@ -56,11 +55,11 @@ the `srcs` of Python targets as required.
),
"_bootstrap_template": attr.label(
allow_single_file = True,
default = "@" + TOOLS_REPO + "//tools/python:python_bootstrap_template.txt",
default = "@bazel_tools//tools/python:python_bootstrap_template.txt",
),
"_launcher": attr.label(
cfg = "target",
default = "@" + TOOLS_REPO + "//tools/launcher:launcher",
default = "@bazel_tools//tools/launcher:launcher",
executable = True,
),
"_py_interpreter": attr.label(
Expand All @@ -76,17 +75,17 @@ the `srcs` of Python targets as required.
# GraphlessQueryTest.testLabelsOperator relies on it to test for
# query behavior of implicit dependencies.
"_py_toolchain_type": attr.label(
default = "@" + TOOLS_REPO + "//tools/python:toolchain_type",
default = "@bazel_tools//tools/python:toolchain_type",
),
"_windows_launcher_maker": attr.label(
default = "@" + TOOLS_REPO + "//tools/launcher:launcher_maker",
default = "@bazel_tools//tools/launcher:launcher_maker",
cfg = "exec",
executable = True,
),
"_zipper": attr.label(
cfg = "exec",
executable = True,
default = "@" + TOOLS_REPO + "//tools/zip:zipper",
default = "@bazel_tools//tools/zip:zipper",
),
},
)
Expand Down
3 changes: 1 addition & 2 deletions python/private/common/py_test_rule_bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ load(
"create_executable_rule",
"py_executable_bazel_impl",
)
load(":semantics.bzl", "TOOLS_REPO")

_BAZEL_PY_TEST_ATTRS = {
# This *might* be a magic attribute to help C++ coverage work. There's no
# docs about this; see TestActionBuilder.java
"_collect_cc_coverage": attr.label(
default = "@" + TOOLS_REPO + "//tools/test:collect_cc_coverage",
default = "@bazel_tools//tools/test:collect_cc_coverage",
executable = True,
cfg = "exec",
),
Expand Down
3 changes: 0 additions & 3 deletions python/private/common/semantics.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@

IMPORTS_ATTR_SUPPORTED = True

TOOLS_REPO = "bazel_tools"
PLATFORMS_LOCATION = "@platforms/"

SRCS_ATTR_ALLOW_FILES = [".py", ".py3"]

DEPS_ATTR_ALLOW_RULES = None
Expand Down