Skip to content

Commit eb60863

Browse files
committed
refactor: remove is_bazel_7_or_greater
1 parent 587469a commit eb60863

15 files changed

Lines changed: 43 additions & 93 deletions

File tree

docs/BUILD.bazel

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
load("@bazel_skylib//rules:build_test.bzl", "build_test")
1616
load("@dev_pip//:requirements.bzl", "requirement")
1717
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
18-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
1918
load("//python/uv:lock.bzl", "lock") # buildifier: disable=bzl-visibility
2019
load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
2120
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
@@ -107,6 +106,7 @@ sphinx_stardocs(
107106
"//python/cc:py_cc_toolchain_bzl",
108107
"//python/cc:py_cc_toolchain_info_bzl",
109108
"//python/entry_points:py_console_script_binary_bzl",
109+
"//python/extensions:python_bzl",
110110
"//python/local_toolchains:repos_bzl",
111111
"//python/private:attr_builders_bzl",
112112
"//python/private:builders_util_bzl",
@@ -128,12 +128,9 @@ sphinx_stardocs(
128128
"//python/uv:uv_toolchain_bzl",
129129
"//python/uv:uv_toolchain_info_bzl",
130130
] + ([
131-
# Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
132-
"//python/extensions:python_bzl",
133-
] if IS_BAZEL_7_OR_HIGHER else []) + ([
134131
# This depends on @pythons_hub, which is only created under bzlmod,
135132
"//python/extensions:pip_bzl",
136-
] if IS_BAZEL_7_OR_HIGHER and BZLMOD_ENABLED else []),
133+
] if BZLMOD_ENABLED else []),
137134
prefix = "api/rules_python/",
138135
tags = ["docs"],
139136
target_compatible_with = _TARGET_COMPATIBLE_WITH,

python/private/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,6 @@ bzl_library(
534534
":py_runtime_info_bzl",
535535
":reexports_bzl",
536536
":rule_builders_bzl",
537-
":util_bzl",
538537
"@bazel_skylib//lib:dicts",
539538
"@bazel_skylib//lib:paths",
540539
"@bazel_skylib//rules:common_settings",

python/private/py_runtime_pair_rule.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ load("//python:py_runtime_info.bzl", "PyRuntimeInfo")
1919
load(":common_labels.bzl", "labels")
2020
load(":flags.bzl", "read_possibly_native_flag")
2121
load(":reexports.bzl", "BuiltinPyRuntimeInfo")
22-
load(":util.bzl", "IS_BAZEL_7_OR_HIGHER")
2322

2423
def _py_runtime_pair_impl(ctx):
2524
if ctx.attr.py2_runtime != None:
@@ -58,7 +57,7 @@ def _get_py_runtime_info(target):
5857
# py_binary (implemented in Java) performs a type check on the provider
5958
# value to verify it is an instance of the Java-implemented PyRuntimeInfo
6059
# class.
61-
if (IS_BAZEL_7_OR_HIGHER and PyRuntimeInfo in target) or BuiltinPyRuntimeInfo == None:
60+
if (PyRuntimeInfo in target) or BuiltinPyRuntimeInfo == None:
6261
return target[PyRuntimeInfo]
6362
else:
6463
return target[BuiltinPyRuntimeInfo]

python/private/py_runtime_rule.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ load(":flags.bzl", "FreeThreadedFlag")
2121
load(":py_internal.bzl", "py_internal")
2222
load(":py_runtime_info.bzl", "DEFAULT_STUB_SHEBANG", "PyRuntimeInfo")
2323
load(":reexports.bzl", "BuiltinPyRuntimeInfo")
24-
load(":util.bzl", "IS_BAZEL_7_OR_HIGHER")
2524

2625
_py_builtins = py_internal
2726

@@ -133,9 +132,6 @@ def _py_runtime_impl(ctx):
133132
supports_build_time_venv = ctx.attr.supports_build_time_venv,
134133
))
135134

136-
if not IS_BAZEL_7_OR_HIGHER:
137-
builtin_py_runtime_info_kwargs.pop("bootstrap_template")
138-
139135
providers = [
140136
PyRuntimeInfo(**py_runtime_info_kwargs),
141137
DefaultInfo(

python/private/util.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,3 @@ def add_tag(attrs, tag):
7171
attrs["tags"] = [tag]
7272

7373
IS_BAZEL_7_4_OR_HIGHER = hasattr(native, "legacy_globals")
74-
75-
IS_BAZEL_7_OR_HIGHER = hasattr(native, "starlark_doc_extract")

sphinxdocs/tests/proto_to_markdown/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
# limitations under the License.
1414

1515
load("//python:py_test.bzl", "py_test")
16-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
1716

1817
py_test(
1918
name = "proto_to_markdown_test",
2019
srcs = ["proto_to_markdown_test.py"],
21-
target_compatible_with = [] if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"],
2220
deps = [
2321
"//sphinxdocs/private:proto_to_markdown_lib",
2422
"@dev_pip//absl_py",

sphinxdocs/tests/sphinx_docs/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
32
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
43
load(":defs.bzl", "gen_directory")
54

@@ -13,7 +12,7 @@ _TARGET_COMPATIBLE_WITH = select({
1312
"@platforms//os:linux": [],
1413
"@platforms//os:macos": [],
1514
"//conditions:default": ["@platforms//:incompatible"],
16-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
15+
})
1716

1817
sphinx_docs(
1918
name = "docs",

sphinxdocs/tests/sphinx_stardoc/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
22
load("@bazel_skylib//rules:build_test.bzl", "build_test")
33
load("//python:py_test.bzl", "py_test")
4-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
54
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
65
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
76

@@ -15,7 +14,7 @@ _TARGET_COMPATIBLE_WITH = select({
1514
"@platforms//os:linux": [],
1615
"@platforms//os:macos": [],
1716
"//conditions:default": ["@platforms//:incompatible"],
18-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
17+
})
1918

2019
sphinx_docs(
2120
name = "docs",

tests/base_rules/py_executable_base_tests.bzl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ load("@rules_testing//lib:util.bzl", rt_util = "util")
2020
load("//python:py_executable_info.bzl", "PyExecutableInfo")
2121
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
2222
load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo") # buildifier: disable=bzl-visibility
23-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
2423
load("//tests/base_rules:base_tests.bzl", "create_base_tests")
2524
load("//tests/base_rules:util.bzl", "WINDOWS_ATTR", pt_util = "util")
2625
load("//tests/support:py_executable_info_subject.bzl", "PyExecutableInfoSubject")
@@ -286,15 +285,14 @@ def _test_files_to_build_impl(env, target):
286285
"{package}/{test_name}_subject.py",
287286
])
288287

289-
if IS_BAZEL_7_OR_HIGHER:
290-
# As of Bazel 7, the first default output is the executable, so
291-
# verify that is the case. rules_testing
292-
# DepsetFileSubject.contains_exactly doesn't provide an in_order()
293-
# call, nor access to the underlying depset, so we have to do things
294-
# manually.
295-
first_default_output = target[DefaultInfo].files.to_list()[0]
296-
executable = target[DefaultInfo].files_to_run.executable
297-
env.expect.that_file(first_default_output).equals(executable)
288+
# As of Bazel 7, the first default output is the executable, so
289+
# verify that is the case. rules_testing
290+
# DepsetFileSubject.contains_exactly doesn't provide an in_order()
291+
# call, nor access to the underlying depset, so we have to do things
292+
# manually.
293+
first_default_output = target[DefaultInfo].files.to_list()[0]
294+
executable = target[DefaultInfo].files_to_run.executable
295+
env.expect.that_file(first_default_output).equals(executable)
298296

299297
def _test_name_cannot_end_in_py(name, config):
300298
rt_util.helper_target(

tests/bootstrap_impls/a/b/c/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
21
load("//tests/support:py_reconfig.bzl", "py_reconfig_test")
32

43
_SUPPORTS_BOOTSTRAP_SCRIPT = select({
54
"@platforms//os:windows": ["@platforms//:incompatible"],
65
"//conditions:default": [],
7-
}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
6+
})
87

98
py_reconfig_test(
109
name = "nested_dir_test",

0 commit comments

Comments
 (0)