Skip to content

Commit fc4b246

Browse files
committed
chore: remove bazel 5 and bazel 6 support code
1 parent 05735c8 commit fc4b246

43 files changed

Lines changed: 99 additions & 404 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/BUILD.bazel

Lines changed: 3 additions & 8 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,8 @@ 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:pip_bzl",
110+
"//python/extensions:python_bzl",
110111
"//python/local_toolchains:repos_bzl",
111112
"//python/private:attr_builders_bzl",
112113
"//python/private:builders_util_bzl",
@@ -127,13 +128,7 @@ sphinx_stardocs(
127128
"//python/uv:uv_bzl",
128129
"//python/uv:uv_toolchain_bzl",
129130
"//python/uv:uv_toolchain_info_bzl",
130-
] + ([
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 []) + ([
134-
# This depends on @pythons_hub, which is only created under bzlmod,
135-
"//python/extensions:pip_bzl",
136-
] if IS_BAZEL_7_OR_HIGHER and BZLMOD_ENABLED else []),
131+
],
137132
prefix = "api/rules_python/",
138133
tags = ["docs"],
139134
target_compatible_with = _TARGET_COMPATIBLE_WITH,

examples/bzlmod/other_module/MODULE.bazel

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,10 @@ module(
55
# This module is using the same version of rules_python
66
# that the parent module uses.
77
bazel_dep(name = "rules_python", version = "")
8-
9-
# The story behind this commented out override:
10-
# This override is necessary to generate/update the requirements file
11-
# for this module. This is because running it via the outer
12-
# module doesn't work -- the `requirements.update` target can't find
13-
# the correct file to update.
14-
# Running in the submodule itself works, but submodules using overrides
15-
# is considered an error until Bazel 6.3, which prevents the outer module
16-
# from depending on this module.
17-
# So until 6.3 and higher is the minimum, we leave this commented out.
18-
# local_path_override(
19-
# module_name = "rules_python",
20-
# path = "../../..",
21-
# )
8+
local_path_override(
9+
module_name = "rules_python",
10+
path = "../../..",
11+
)
2212

2313
PYTHON_NAME_39 = "python_3_9"
2414

python/BUILD.bazel

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,7 @@ bzl_library(
201201
bzl_library(
202202
name = "py_runtime_pair_bzl",
203203
srcs = ["py_runtime_pair.bzl"],
204-
deps = [
205-
"//python/private:bazel_tools_bzl",
206-
"//python/private:py_runtime_pair_macro_bzl",
207-
"//python/private:util_bzl",
208-
],
204+
deps = ["//python/private:py_runtime_pair_macro_bzl"],
209205
)
210206

211207
bzl_library(

python/private/BUILD.bazel

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ bzl_library(
7171
":enum_bzl",
7272
":flags_bzl",
7373
":py_info_bzl",
74-
":py_internal_bzl",
7574
":reexports_bzl",
7675
":rules_cc_srcs_bzl",
7776
"@bazel_skylib//rules:common_settings",
@@ -342,7 +341,6 @@ bzl_library(
342341
srcs = ["py_cc_link_params_info.bzl"],
343342
deps = [
344343
":rules_cc_srcs_bzl",
345-
":util_bzl",
346344
],
347345
)
348346

@@ -440,7 +438,6 @@ bzl_library(
440438
deps = [
441439
":builders_bzl",
442440
":reexports_bzl",
443-
":util_bzl",
444441
"@rules_python_internal//:rules_python_config_bzl",
445442
],
446443
)
@@ -506,7 +503,6 @@ bzl_library(
506503
bzl_library(
507504
name = "py_runtime_info_bzl",
508505
srcs = ["py_runtime_info.bzl"],
509-
deps = [":util_bzl"],
510506
)
511507

512508
bzl_library(

python/private/envsubst.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def envsubst(template_string, varnames, getenv):
2222
listed in the `varnames` list in the environment defined by the
2323
`getenv` function. Typically called with `getenv = rctx.getenv`
2424
(if it is available) or `getenv = rctx.os.environ.get` (on e.g.
25-
Bazel 6 or Bazel 7, which don't have `rctx.getenv` yet).
25+
Bazel 7, which don't have `rctx.getenv` yet).
2626
2727
Limitations: Unlike the shell, we don't support `${VARNAME}` and
2828
`${VARNAME:-default}` in the default expression for a different

python/private/internal_config_repo.bzl

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ load(":repo_utils.bzl", "repo_utils")
2323

2424
_ENABLE_PIPSTAR_ENVVAR_NAME = "RULES_PYTHON_ENABLE_PIPSTAR"
2525
_ENABLE_PIPSTAR_DEFAULT = "0"
26-
_ENABLE_PYSTAR_ENVVAR_NAME = "RULES_PYTHON_ENABLE_PYSTAR"
27-
_ENABLE_PYSTAR_DEFAULT = "1"
2826
_ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME = "RULES_PYTHON_DEPRECATION_WARNINGS"
2927
_ENABLE_DEPRECATION_WARNINGS_DEFAULT = "0"
3028

@@ -88,15 +86,6 @@ _TRANSITION_SETTINGS_DEBUG_TEMPLATE = """
8886
"""
8987

9088
def _internal_config_repo_impl(rctx):
91-
pystar_requested = _bool_from_environ(rctx, _ENABLE_PYSTAR_ENVVAR_NAME, _ENABLE_PYSTAR_DEFAULT)
92-
93-
# Bazel 7+ (dev and later) has native.starlark_doc_extract, and thus the
94-
# py_internal global, which are necessary for the pystar implementation.
95-
if pystar_requested and hasattr(native, "starlark_doc_extract"):
96-
enable_pystar = pystar_requested
97-
else:
98-
enable_pystar = False
99-
10089
if not native.bazel_version or int(native.bazel_version.split(".")[0]) >= 8:
10190
builtin_py_info_symbol = "None"
10291
builtin_py_runtime_info_symbol = "None"
@@ -107,33 +96,19 @@ def _internal_config_repo_impl(rctx):
10796
builtin_py_cc_link_params_provider = "PyCcLinkParamsProvider"
10897

10998
rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
110-
enable_pystar = enable_pystar,
99+
enable_pystar = True,
111100
enable_pipstar = _bool_from_environ(rctx, _ENABLE_PIPSTAR_ENVVAR_NAME, _ENABLE_PIPSTAR_DEFAULT),
112101
enable_deprecation_warnings = _bool_from_environ(rctx, _ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME, _ENABLE_DEPRECATION_WARNINGS_DEFAULT),
113102
builtin_py_info_symbol = builtin_py_info_symbol,
114103
builtin_py_runtime_info_symbol = builtin_py_runtime_info_symbol,
115104
builtin_py_cc_link_params_provider = builtin_py_cc_link_params_provider,
116105
))
117106

118-
if enable_pystar:
119-
shim_content = _PY_INTERNAL_SHIM
120-
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
121-
else:
122-
shim_content = "py_internal_impl = None\n"
123-
py_internal_dep = ""
124-
125-
# Bazel 5 doesn't support repository visibility, so just use public
126-
# as a stand-in
127-
if native.bazel_version.startswith("5."):
128-
visibility = "//visibility:public"
129-
else:
130-
visibility = "@rules_python//:__subpackages__"
131-
132107
rctx.file("BUILD", ROOT_BUILD_TEMPLATE.format(
133-
py_internal_dep = py_internal_dep,
134-
visibility = visibility,
108+
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"',
109+
visibility = "@rules_python//:__subpackages__",
135110
))
136-
rctx.file("py_internal.bzl", shim_content)
111+
rctx.file("py_internal.bzl", _PY_INTERNAL_SHIM)
137112

138113
rctx.file(
139114
"extra_transition_settings.bzl",
@@ -155,7 +130,7 @@ def _internal_config_repo_impl(rctx):
155130
internal_config_repo = repository_rule(
156131
implementation = _internal_config_repo_impl,
157132
configure = True,
158-
environ = [_ENABLE_PYSTAR_ENVVAR_NAME],
133+
environ = [_ENABLE_PIPSTAR_ENVVAR_NAME],
159134
attrs = {
160135
"transition_setting_generators": attr.string_list_dict(),
161136
"transition_settings": attr.string_list(),

python/private/interpreter.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ interpreter_binary = rule(
7272
mandatory = True,
7373
),
7474
"_bash_runfiles": attr.label(
75-
default = "@bazel_tools//tools/bash/runfiles",
75+
default = "@rules_shell//shell/runfiles",
7676
),
7777
"_template": attr.label(
7878
default = "//python/private:interpreter_tmpl.sh",

python/private/local_runtime_repo.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _symlink_first_library(rctx, logger, libraries):
7171
else:
7272
linked = "lib/{}".format(origin.basename)
7373
logger.debug("Symlinking {} to {}".format(origin, linked))
74-
repo_utils.watch(rctx, origin)
74+
rctx.watch(origin)
7575
rctx.symlink(origin, linked)
7676
break
7777

@@ -142,7 +142,7 @@ def _local_runtime_repo_impl(rctx):
142142
# path is an error. Silently skip, since includes are only necessary
143143
# if C extensions are built.
144144
if include_path.exists and include_path.is_dir:
145-
repo_utils.watch_tree(rctx, include_path)
145+
rctx.watch_tree(include_path)
146146
else:
147147
pass
148148

@@ -268,7 +268,7 @@ def _resolve_interpreter_path(rctx):
268268
resolved_path = result.binary
269269
describe_failure = result.describe_failure
270270
else:
271-
repo_utils.watch(rctx, rctx.attr.interpreter_path)
271+
rctx.watch(rctx.attr.interpreter_path)
272272
resolved_path = rctx.path(rctx.attr.interpreter_path)
273273
if not resolved_path.exists:
274274
describe_failure = lambda: "Path not found: {}".format(repr(rctx.attr.interpreter_path))

python/private/py_cc_link_params_info.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
"""Providers for Python rules."""
1515

1616
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
17-
load(":util.bzl", "define_bazel_6_provider")
1817

1918
def _PyCcLinkParamsInfo_init(cc_info):
2019
return {
2120
"cc_info": CcInfo(linking_context = cc_info.linking_context),
2221
}
2322

2423
# buildifier: disable=name-conventions
25-
PyCcLinkParamsInfo, _unused_raw_py_cc_link_params_provider_ctor = define_bazel_6_provider(
24+
PyCcLinkParamsInfo, _unused_raw_py_cc_link_params_provider_ctor = provider(
2625
doc = ("Python-wrapper to forward {obj}`CcInfo.linking_context`. This is to " +
2726
"allow Python targets to propagate C++ linking information, but " +
2827
"without the Python target appearing to be a valid C++ rule dependency"),

python/private/py_info.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
load("@rules_python_internal//:rules_python_config.bzl", "config")
1717
load(":builders.bzl", "builders")
1818
load(":reexports.bzl", "BuiltinPyInfo")
19-
load(":util.bzl", "define_bazel_6_provider")
2019

2120
def _VenvSymlinkKind_typedef():
2221
"""An enum of types of venv directories.
@@ -160,7 +159,7 @@ def _PyInfo_init(
160159
"venv_symlinks": venv_symlinks,
161160
}
162161

163-
PyInfo, _unused_raw_py_info_ctor = define_bazel_6_provider(
162+
PyInfo, _unused_raw_py_info_ctor = provider(
164163
doc = """Encapsulates information provided by the Python rules.
165164
166165
Instead of creating this object directly, use {obj}`PyInfoBuilder` and

0 commit comments

Comments
 (0)