chore: cleanup bazel flags related to bazel 6 or below (#3282)
Summary:
* refactor: use rules_shell runfiles lib
* refactor: remove watch helpers
* refactor: remove usage of select helper
* refactor: make enable_pystar fixed and cleanup code
* refactor: remove migration tag helper
* refactor: remove is_bazel_6_or_higher
* refactor: remove is_bazel_6_4_or_higher
* refactor: remove is_bazel_7_or_greater
* remove: is_bazel_7_4_or_greater
* fix: pipstar env var is now respected
* chore: drop bazel 5 support code
* chore: add an override for bzlmod example
* chore: remove version specific globs, since the supported versions
support spaces in filenames and the file becomes redundant.
diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel
index b6c48b0..c36ed57 100644
--- a/docs/BUILD.bazel
+++ b/docs/BUILD.bazel
@@ -15,7 +15,6 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@dev_pip//:requirements.bzl", "requirement")
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//python/uv:lock.bzl", "lock") # buildifier: disable=bzl-visibility
load("//sphinxdocs:readthedocs.bzl", "readthedocs_install")
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
@@ -107,6 +106,7 @@
"//python/cc:py_cc_toolchain_bzl",
"//python/cc:py_cc_toolchain_info_bzl",
"//python/entry_points:py_console_script_binary_bzl",
+ "//python/extensions:python_bzl",
"//python/local_toolchains:repos_bzl",
"//python/private:attr_builders_bzl",
"//python/private:builders_util_bzl",
@@ -128,12 +128,9 @@
"//python/uv:uv_toolchain_bzl",
"//python/uv:uv_toolchain_info_bzl",
] + ([
- # Bazel 6 + Stardoc isn't able to parse something about the python bzlmod extension
- "//python/extensions:python_bzl",
- ] if IS_BAZEL_7_OR_HIGHER else []) + ([
# This depends on @pythons_hub, which is only created under bzlmod,
"//python/extensions:pip_bzl",
- ] if IS_BAZEL_7_OR_HIGHER and BZLMOD_ENABLED else []),
+ ] if BZLMOD_ENABLED else []),
prefix = "api/rules_python/",
tags = ["docs"],
target_compatible_with = _TARGET_COMPATIBLE_WITH,
diff --git a/examples/bzlmod/other_module/MODULE.bazel b/examples/bzlmod/other_module/MODULE.bazel
index f9d6706..7b88bd7 100644
--- a/examples/bzlmod/other_module/MODULE.bazel
+++ b/examples/bzlmod/other_module/MODULE.bazel
@@ -5,20 +5,10 @@
# This module is using the same version of rules_python
# that the parent module uses.
bazel_dep(name = "rules_python", version = "")
-
-# The story behind this commented out override:
-# This override is necessary to generate/update the requirements file
-# for this module. This is because running it via the outer
-# module doesn't work -- the `requirements.update` target can't find
-# the correct file to update.
-# Running in the submodule itself works, but submodules using overrides
-# is considered an error until Bazel 6.3, which prevents the outer module
-# from depending on this module.
-# So until 6.3 and higher is the minimum, we leave this commented out.
-# local_path_override(
-# module_name = "rules_python",
-# path = "../../..",
-# )
+local_path_override(
+ module_name = "rules_python",
+ path = "../../..",
+)
PYTHON_NAME_39 = "python_3_9"
diff --git a/python/BUILD.bazel b/python/BUILD.bazel
index 76fa5dd..5fc35f8 100644
--- a/python/BUILD.bazel
+++ b/python/BUILD.bazel
@@ -81,9 +81,6 @@
bzl_library(
name = "features_bzl",
srcs = ["features.bzl"],
- deps = [
- "@rules_python_internal//:rules_python_config_bzl",
- ],
)
bzl_library(
@@ -130,8 +127,6 @@
deps = [
"//python/private:py_binary_macro_bzl",
"//python/private:register_extension_info_bzl",
- "//python/private:util_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -140,7 +135,6 @@
srcs = ["py_cc_link_params_info.bzl"],
deps = [
"//python/private:py_cc_link_params_info_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -173,8 +167,6 @@
srcs = ["py_info.bzl"],
deps = [
"//python/private:py_info_bzl",
- "//python/private:reexports_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -184,8 +176,6 @@
deps = [
"//python/private:py_library_macro_bzl",
"//python/private:register_extension_info_bzl",
- "//python/private:util_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -194,7 +184,6 @@
srcs = ["py_runtime.bzl"],
deps = [
"//python/private:py_runtime_macro_bzl",
- "//python/private:util_bzl",
],
)
@@ -202,9 +191,7 @@
name = "py_runtime_pair_bzl",
srcs = ["py_runtime_pair.bzl"],
deps = [
- "//python/private:bazel_tools_bzl",
"//python/private:py_runtime_pair_macro_bzl",
- "//python/private:util_bzl",
],
)
@@ -213,8 +200,6 @@
srcs = ["py_runtime_info.bzl"],
deps = [
"//python/private:py_runtime_info_bzl",
- "//python/private:reexports_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -224,8 +209,6 @@
deps = [
"//python/private:py_test_macro_bzl",
"//python/private:register_extension_info_bzl",
- "//python/private:util_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
diff --git a/python/features.bzl b/python/features.bzl
index 21ff588..00bc1a7 100644
--- a/python/features.bzl
+++ b/python/features.bzl
@@ -13,8 +13,6 @@
# limitations under the License.
"""Allows detecting of rules_python features that aren't easily detected."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
-
# This is a magic string expanded by `git archive`, as set by `.gitattributes`
# See https://git-scm.com/docs/git-archive/2.29.0#Documentation/git-archive.txt-export-subst
_VERSION_PRIVATE = "$Format:%(describe:tags=true)$"
@@ -73,6 +71,6 @@
headers_abi3 = True,
precompile = True,
py_info_venv_symlinks = True,
- uses_builtin_rules = not config.enable_pystar,
+ uses_builtin_rules = False,
version = _VERSION_PRIVATE if "$Format" not in _VERSION_PRIVATE else "",
)
diff --git a/python/private/BUILD.bazel b/python/private/BUILD.bazel
index 0c8ccde..1bcd0f6 100644
--- a/python/private/BUILD.bazel
+++ b/python/private/BUILD.bazel
@@ -195,12 +195,6 @@
)
bzl_library(
- name = "glob_excludes_bzl",
- srcs = ["glob_excludes.bzl"],
- deps = [":util_bzl"],
-)
-
-bzl_library(
name = "internal_config_repo_bzl",
srcs = ["internal_config_repo.bzl"],
deps = [":bzlmod_enabled_bzl"],
@@ -264,7 +258,6 @@
":pythons_hub_bzl",
":repo_utils_bzl",
":toolchains_repo_bzl",
- ":util_bzl",
":version_bzl",
"@bazel_features//:features",
],
@@ -440,8 +433,6 @@
deps = [
":builders_bzl",
":reexports_bzl",
- ":util_bzl",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -506,7 +497,6 @@
bzl_library(
name = "py_runtime_info_bzl",
srcs = ["py_runtime_info.bzl"],
- deps = [":util_bzl"],
)
bzl_library(
@@ -538,7 +528,6 @@
":py_runtime_info_bzl",
":reexports_bzl",
":rule_builders_bzl",
- ":util_bzl",
"@bazel_skylib//lib:dicts",
"@bazel_skylib//lib:paths",
"@bazel_skylib//rules:common_settings",
@@ -688,7 +677,6 @@
],
deps = [
"@bazel_skylib//lib:types",
- "@rules_python_internal//:rules_python_config_bzl",
],
)
diff --git a/python/private/glob_excludes.bzl b/python/private/glob_excludes.bzl
deleted file mode 100644
index c98afe0..0000000
--- a/python/private/glob_excludes.bzl
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2024 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.
-
-"Utilities for glob exclusions."
-
-load(":util.bzl", "IS_BAZEL_7_4_OR_HIGHER")
-
-def _version_dependent_exclusions():
- """Returns glob exclusions that are sensitive to Bazel version.
-
- Returns:
- a list of glob exclusion patterns
- """
- if IS_BAZEL_7_4_OR_HIGHER:
- return []
- else:
- return ["**/* *"]
-
-glob_excludes = struct(
- version_dependent_exclusions = _version_dependent_exclusions,
-)
diff --git a/python/private/hermetic_runtime_repo_setup.bzl b/python/private/hermetic_runtime_repo_setup.bzl
index a35ce8a..46495e4 100644
--- a/python/private/hermetic_runtime_repo_setup.bzl
+++ b/python/private/hermetic_runtime_repo_setup.bzl
@@ -18,7 +18,6 @@
load("//python:py_runtime.bzl", "py_runtime")
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
load("//python/cc:py_cc_toolchain.bzl", "py_cc_toolchain")
-load(":glob_excludes.bzl", "glob_excludes")
load(":py_exec_tools_toolchain.bzl", "py_exec_tools_toolchain")
load(":version.bzl", "version")
@@ -82,7 +81,7 @@
"lib/python{major}.{minor}*/**/tests/**".format(**version_dict),
# During pyc creation, temp files named *.pyc.NNN are created
"**/__pycache__/*.pyc.*",
- ] + glob_excludes.version_dependent_exclusions() + extra_files_glob_exclude,
+ ] + extra_files_glob_exclude,
),
)
cc_import(
diff --git a/python/private/internal_config_repo.bzl b/python/private/internal_config_repo.bzl
index b57275b..109e68a 100644
--- a/python/private/internal_config_repo.bzl
+++ b/python/private/internal_config_repo.bzl
@@ -23,14 +23,12 @@
_ENABLE_PIPSTAR_ENVVAR_NAME = "RULES_PYTHON_ENABLE_PIPSTAR"
_ENABLE_PIPSTAR_DEFAULT = "0"
-_ENABLE_PYSTAR_ENVVAR_NAME = "RULES_PYTHON_ENABLE_PYSTAR"
-_ENABLE_PYSTAR_DEFAULT = "1"
_ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME = "RULES_PYTHON_DEPRECATION_WARNINGS"
_ENABLE_DEPRECATION_WARNINGS_DEFAULT = "0"
_CONFIG_TEMPLATE = """
config = struct(
- enable_pystar = {enable_pystar},
+ enable_pystar = True,
enable_pipstar = {enable_pipstar},
enable_deprecation_warnings = {enable_deprecation_warnings},
BuiltinPyInfo = getattr(getattr(native, "legacy_globals", None), "PyInfo", {builtin_py_info_symbol}),
@@ -88,15 +86,6 @@
"""
def _internal_config_repo_impl(rctx):
- pystar_requested = _bool_from_environ(rctx, _ENABLE_PYSTAR_ENVVAR_NAME, _ENABLE_PYSTAR_DEFAULT)
-
- # Bazel 7+ (dev and later) has native.starlark_doc_extract, and thus the
- # py_internal global, which are necessary for the pystar implementation.
- if pystar_requested and hasattr(native, "starlark_doc_extract"):
- enable_pystar = pystar_requested
- else:
- enable_pystar = False
-
if not native.bazel_version or int(native.bazel_version.split(".")[0]) >= 8:
builtin_py_info_symbol = "None"
builtin_py_runtime_info_symbol = "None"
@@ -107,7 +96,6 @@
builtin_py_cc_link_params_provider = "PyCcLinkParamsProvider"
rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
- enable_pystar = enable_pystar,
enable_pipstar = _bool_from_environ(rctx, _ENABLE_PIPSTAR_ENVVAR_NAME, _ENABLE_PIPSTAR_DEFAULT),
enable_deprecation_warnings = _bool_from_environ(rctx, _ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME, _ENABLE_DEPRECATION_WARNINGS_DEFAULT),
builtin_py_info_symbol = builtin_py_info_symbol,
@@ -115,23 +103,12 @@
builtin_py_cc_link_params_provider = builtin_py_cc_link_params_provider,
))
- if enable_pystar:
- shim_content = _PY_INTERNAL_SHIM
- py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
- else:
- shim_content = "py_internal_impl = None\n"
- py_internal_dep = ""
-
- # Bazel 5 doesn't support repository visibility, so just use public
- # as a stand-in
- if native.bazel_version.startswith("5."):
- visibility = "//visibility:public"
- else:
- visibility = "@rules_python//:__subpackages__"
+ shim_content = _PY_INTERNAL_SHIM
+ py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
rctx.file("BUILD", ROOT_BUILD_TEMPLATE.format(
py_internal_dep = py_internal_dep,
- visibility = visibility,
+ visibility = "@rules_python//:__subpackages__",
))
rctx.file("py_internal.bzl", shim_content)
@@ -155,7 +132,7 @@
internal_config_repo = repository_rule(
implementation = _internal_config_repo_impl,
configure = True,
- environ = [_ENABLE_PYSTAR_ENVVAR_NAME],
+ environ = [_ENABLE_PIPSTAR_ENVVAR_NAME],
attrs = {
"transition_setting_generators": attr.string_list_dict(),
"transition_settings": attr.string_list(),
diff --git a/python/private/local_runtime_repo.bzl b/python/private/local_runtime_repo.bzl
index c053a03..27c90b1 100644
--- a/python/private/local_runtime_repo.bzl
+++ b/python/private/local_runtime_repo.bzl
@@ -71,7 +71,7 @@
else:
linked = "lib/{}".format(origin.basename)
logger.debug("Symlinking {} to {}".format(origin, linked))
- repo_utils.watch(rctx, origin)
+ rctx.watch(origin)
rctx.symlink(origin, linked)
break
@@ -142,7 +142,7 @@
# path is an error. Silently skip, since includes are only necessary
# if C extensions are built.
if include_path.exists and include_path.is_dir:
- repo_utils.watch_tree(rctx, include_path)
+ rctx.watch_tree(include_path)
else:
pass
@@ -268,7 +268,7 @@
resolved_path = result.binary
describe_failure = result.describe_failure
else:
- repo_utils.watch(rctx, rctx.attr.interpreter_path)
+ rctx.watch(rctx.attr.interpreter_path)
resolved_path = rctx.path(rctx.attr.interpreter_path)
if not resolved_path.exists:
describe_failure = lambda: "Path not found: {}".format(repr(rctx.attr.interpreter_path))
diff --git a/python/private/py_cc_link_params_info.bzl b/python/private/py_cc_link_params_info.bzl
index 35919a0..2fbd255 100644
--- a/python/private/py_cc_link_params_info.bzl
+++ b/python/private/py_cc_link_params_info.bzl
@@ -14,7 +14,6 @@
"""Providers for Python rules."""
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
-load(":util.bzl", "define_bazel_6_provider")
def _PyCcLinkParamsInfo_init(cc_info):
return {
@@ -22,7 +21,7 @@
}
# buildifier: disable=name-conventions
-PyCcLinkParamsInfo, _unused_raw_py_cc_link_params_provider_ctor = define_bazel_6_provider(
+PyCcLinkParamsInfo, _unused_raw_py_cc_link_params_provider_ctor = provider(
doc = ("Python-wrapper to forward {obj}`CcInfo.linking_context`. This is to " +
"allow Python targets to propagate C++ linking information, but " +
"without the Python target appearing to be a valid C++ rule dependency"),
diff --git a/python/private/py_info.bzl b/python/private/py_info.bzl
index f96dec5..4059b30 100644
--- a/python/private/py_info.bzl
+++ b/python/private/py_info.bzl
@@ -13,10 +13,8 @@
# limitations under the License.
"""Implementation of PyInfo provider and PyInfo-specific utilities."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load(":builders.bzl", "builders")
load(":reexports.bzl", "BuiltinPyInfo")
-load(":util.bzl", "define_bazel_6_provider")
def _VenvSymlinkKind_typedef():
"""An enum of types of venv directories.
@@ -160,7 +158,7 @@
"venv_symlinks": venv_symlinks,
}
-PyInfo, _unused_raw_py_info_ctor = define_bazel_6_provider(
+PyInfo, _unused_raw_py_info_ctor = provider(
doc = """Encapsulates information provided by the Python rules.
Instead of creating this object directly, use {obj}`PyInfoBuilder` and
@@ -327,7 +325,7 @@
)
# The "effective" PyInfo is what the canonical //python:py_info.bzl%PyInfo symbol refers to
-_EffectivePyInfo = PyInfo if (config.enable_pystar or BuiltinPyInfo == None) else BuiltinPyInfo
+_EffectivePyInfo = PyInfo
def _PyInfoBuilder_typedef():
"""Builder for PyInfo.
@@ -630,28 +628,21 @@
Returns:
{type}`PyInfo`
"""
- if config.enable_pystar:
- kwargs = dict(
- direct_original_sources = self.direct_original_sources.build(),
- direct_pyc_files = self.direct_pyc_files.build(),
- direct_pyi_files = self.direct_pyi_files.build(),
- transitive_implicit_pyc_files = self.transitive_implicit_pyc_files.build(),
- transitive_implicit_pyc_source_files = self.transitive_implicit_pyc_source_files.build(),
- transitive_original_sources = self.transitive_original_sources.build(),
- transitive_pyc_files = self.transitive_pyc_files.build(),
- transitive_pyi_files = self.transitive_pyi_files.build(),
- venv_symlinks = self.venv_symlinks.build(),
- )
- else:
- kwargs = {}
-
return _EffectivePyInfo(
has_py2_only_sources = self._has_py2_only_sources[0],
has_py3_only_sources = self._has_py3_only_sources[0],
imports = self.imports.build(),
transitive_sources = self.transitive_sources.build(),
uses_shared_libraries = self._uses_shared_libraries[0],
- **kwargs
+ direct_original_sources = self.direct_original_sources.build(),
+ direct_pyc_files = self.direct_pyc_files.build(),
+ direct_pyi_files = self.direct_pyi_files.build(),
+ transitive_implicit_pyc_files = self.transitive_implicit_pyc_files.build(),
+ transitive_implicit_pyc_source_files = self.transitive_implicit_pyc_source_files.build(),
+ transitive_original_sources = self.transitive_original_sources.build(),
+ transitive_pyc_files = self.transitive_pyc_files.build(),
+ transitive_pyi_files = self.transitive_pyi_files.build(),
+ venv_symlinks = self.venv_symlinks.build(),
)
def _PyInfoBuilder_build_builtin_py_info(self):
diff --git a/python/private/py_package.bzl b/python/private/py_package.bzl
index adf2b6d..d23276a 100644
--- a/python/private/py_package.bzl
+++ b/python/private/py_package.bzl
@@ -41,13 +41,8 @@
py_info.merge_target(dep)
py_info = py_info.build()
inputs.add(py_info.transitive_sources)
-
- # Remove conditional once Bazel 6 support dropped.
- if hasattr(py_info, "transitive_pyc_files"):
- inputs.add(py_info.transitive_pyc_files)
-
- if hasattr(py_info, "transitive_pyi_files"):
- inputs.add(py_info.transitive_pyi_files)
+ inputs.add(py_info.transitive_pyc_files)
+ inputs.add(py_info.transitive_pyi_files)
inputs = inputs.build()
diff --git a/python/private/py_runtime_info.bzl b/python/private/py_runtime_info.bzl
index efe14b2..af4e7f0 100644
--- a/python/private/py_runtime_info.bzl
+++ b/python/private/py_runtime_info.bzl
@@ -13,8 +13,6 @@
# limitations under the License.
"""Providers for Python rules."""
-load(":util.bzl", "define_bazel_6_provider")
-
DEFAULT_STUB_SHEBANG = "#!/usr/bin/env python3"
_PYTHON_VERSION_VALUES = ["PY2", "PY3"]
@@ -124,7 +122,7 @@
"zip_main_template": zip_main_template,
}
-PyRuntimeInfo, _unused_raw_py_runtime_info_ctor = define_bazel_6_provider(
+PyRuntimeInfo, _unused_raw_py_runtime_info_ctor = provider(
doc = """Contains information about a Python runtime, as returned by the `py_runtime`
rule.
diff --git a/python/private/py_runtime_pair_rule.bzl b/python/private/py_runtime_pair_rule.bzl
index 61cbdcd..203e5d4 100644
--- a/python/private/py_runtime_pair_rule.bzl
+++ b/python/private/py_runtime_pair_rule.bzl
@@ -19,7 +19,6 @@
load(":common_labels.bzl", "labels")
load(":flags.bzl", "read_possibly_native_flag")
load(":reexports.bzl", "BuiltinPyRuntimeInfo")
-load(":util.bzl", "IS_BAZEL_7_OR_HIGHER")
def _py_runtime_pair_impl(ctx):
if ctx.attr.py2_runtime != None:
@@ -58,7 +57,7 @@
# py_binary (implemented in Java) performs a type check on the provider
# value to verify it is an instance of the Java-implemented PyRuntimeInfo
# class.
- if (IS_BAZEL_7_OR_HIGHER and PyRuntimeInfo in target) or BuiltinPyRuntimeInfo == None:
+ if (PyRuntimeInfo in target) or BuiltinPyRuntimeInfo == None:
return target[PyRuntimeInfo]
else:
return target[BuiltinPyRuntimeInfo]
diff --git a/python/private/py_runtime_rule.bzl b/python/private/py_runtime_rule.bzl
index ba1a390..5020d7a 100644
--- a/python/private/py_runtime_rule.bzl
+++ b/python/private/py_runtime_rule.bzl
@@ -21,7 +21,6 @@
load(":py_internal.bzl", "py_internal")
load(":py_runtime_info.bzl", "DEFAULT_STUB_SHEBANG", "PyRuntimeInfo")
load(":reexports.bzl", "BuiltinPyRuntimeInfo")
-load(":util.bzl", "IS_BAZEL_7_OR_HIGHER")
_py_builtins = py_internal
@@ -133,9 +132,6 @@
supports_build_time_venv = ctx.attr.supports_build_time_venv,
))
- if not IS_BAZEL_7_OR_HIGHER:
- builtin_py_runtime_info_kwargs.pop("bootstrap_template")
-
providers = [
PyRuntimeInfo(**py_runtime_info_kwargs),
DefaultInfo(
@@ -388,11 +384,7 @@
)
def _is_singleton_depset(files):
- # Bazel 6 doesn't have this helper to optimize detecting singleton depsets.
- if _py_builtins:
- return _py_builtins.is_singleton_depset(files)
- else:
- return len(files.to_list()) == 1
+ return _py_builtins.is_singleton_depset(files)
def _interpreter_version_info_from_version_str(version_str):
parts = version_str.split(".")
diff --git a/python/private/pypi/BUILD.bazel b/python/private/pypi/BUILD.bazel
index 0d2f73f..b9650c8 100644
--- a/python/private/pypi/BUILD.bazel
+++ b/python/private/pypi/BUILD.bazel
@@ -74,7 +74,6 @@
srcs = ["deps.bzl"],
deps = [
"//python/private:bazel_tools_bzl",
- "//python/private:glob_excludes_bzl",
],
)
@@ -126,6 +125,7 @@
"@bazel_features//:features",
"@pythons_hub//:interpreters_bzl",
"@pythons_hub//:versions_bzl",
+ "@rules_python_internal//:rules_python_config_bzl",
],
)
@@ -439,6 +439,7 @@
"//python/private:envsubst_bzl",
"//python/private:is_standalone_interpreter_bzl",
"//python/private:repo_utils_bzl",
+ "@rules_python_internal//:rules_python_config_bzl",
],
)
diff --git a/python/private/pypi/deps.bzl b/python/private/pypi/deps.bzl
index 73b30c6..5379343 100644
--- a/python/private/pypi/deps.bzl
+++ b/python/private/pypi/deps.bzl
@@ -101,7 +101,6 @@
package(default_visibility = ["//visibility:public"])
load("@rules_python//python:py_library.bzl", "py_library")
-load("@rules_python//python/private:glob_excludes.bzl", "glob_excludes")
py_library(
name = "lib",
@@ -115,7 +114,7 @@
"**/*.dist-info/RECORD",
"BUILD",
"WORKSPACE",
- ] + glob_excludes.version_dependent_exclusions()),
+ ]),
# This makes this directory a top-level in the python import
# search path for anything that depends on this.
imports = ["."],
diff --git a/python/private/pypi/pypi_repo_utils.bzl b/python/private/pypi/pypi_repo_utils.bzl
index bb2acc8..04c9b5d 100644
--- a/python/private/pypi/pypi_repo_utils.bzl
+++ b/python/private/pypi/pypi_repo_utils.bzl
@@ -107,9 +107,8 @@
def _execute_prep(mrctx, *, python, srcs, **kwargs):
for src in srcs:
# This will ensure that we will re-evaluate the bzlmod extension or
- # refetch the repository_rule when the srcs change. This should work on
- # Bazel versions without `mrctx.watch` as well.
- repo_utils.watch(mrctx, mrctx.path(src))
+ # refetch the repository_rule when the srcs change.
+ mrctx.watch(mrctx.path(src))
environment = kwargs.pop("environment", {})
pythonpath = environment.get("PYTHONPATH", "")
diff --git a/python/private/pypi/whl_library_targets.bzl b/python/private/pypi/whl_library_targets.bzl
index aed5bc7..89c1d34 100644
--- a/python/private/pypi/whl_library_targets.bzl
+++ b/python/private/pypi/whl_library_targets.bzl
@@ -17,7 +17,6 @@
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("//python:py_binary.bzl", "py_binary")
load("//python:py_library.bzl", "py_library")
-load("//python/private:glob_excludes.bzl", "glob_excludes")
load("//python/private:normalize_name.bzl", "normalize_name")
load(":env_marker_setting.bzl", "env_marker_setting")
load(
@@ -315,13 +314,6 @@
deps_by_platform = dependencies_by_platform,
deps_conditional = deps_conditional,
tmpl = dep_template.format(name = "{}", target = WHEEL_FILE_PUBLIC_LABEL),
- # NOTE @aignas 2024-10-28: Actually, `select` is not part of
- # `native`, but in order to support bazel 6.4 in unit tests, I
- # have to somehow pass the `select` implementation in the unit
- # tests and I chose this to be routed through the `native`
- # struct. So, tests` will be successful in `getattr` and the
- # real code will use the fallback provided here.
- select = getattr(native, "select", select),
),
visibility = impl_vis,
)
@@ -346,7 +338,7 @@
# of generated files produced when wheels are installed. The file is ignored to avoid
# Bazel caching issues.
"**/*.dist-info/RECORD",
- ] + glob_excludes.version_dependent_exclusions()
+ ]
for item in data_exclude:
if item not in _data_exclude:
_data_exclude.append(item)
@@ -362,7 +354,7 @@
)
if not enable_implicit_namespace_pkgs:
- srcs = srcs + getattr(native, "select", select)({
+ srcs = srcs + select({
Label("//python/config_settings:is_venvs_site_packages"): [],
"//conditions:default": rules.create_inits(
srcs = srcs + data + pyi_srcs,
@@ -384,7 +376,6 @@
deps_by_platform = dependencies_by_platform,
deps_conditional = deps_conditional,
tmpl = dep_template.format(name = "{}", target = PY_LIBRARY_PUBLIC_LABEL),
- select = getattr(native, "select", select),
),
tags = tags,
visibility = impl_vis,
@@ -455,7 +446,7 @@
else:
return ":is_" + plat.replace("cp3", "python_3.")
-def _deps(deps, deps_by_platform, deps_conditional, tmpl, select = select):
+def _deps(deps, deps_by_platform, deps_conditional, tmpl):
deps = [tmpl.format(d) for d in sorted(deps)]
for dep, setting in deps_conditional.items():
diff --git a/python/private/python.bzl b/python/private/python.bzl
index 6eb8a37..faad53f 100644
--- a/python/private/python.bzl
+++ b/python/private/python.bzl
@@ -29,7 +29,6 @@
"sorted_host_platform_names",
"sorted_host_platforms",
)
-load(":util.bzl", "IS_BAZEL_6_4_OR_HIGHER")
load(":version.bzl", "version")
def parse_modules(*, module_ctx, logger, _fail = fail):
@@ -932,14 +931,6 @@
ignore_root_user_error = getattr(tag, "ignore_root_user_error", True),
)
-def _get_bazel_version_specific_kwargs():
- kwargs = {}
-
- if IS_BAZEL_6_4_OR_HIGHER:
- kwargs["environ"] = ["RULES_PYTHON_BZLMOD_DEBUG"]
-
- return kwargs
-
_defaults = tag_class(
doc = """Tag class to specify the default Python version.""",
attrs = {
@@ -1356,7 +1347,7 @@
"single_version_platform_override": _single_version_platform_override,
"toolchain": _toolchain,
},
- **_get_bazel_version_specific_kwargs()
+ environ = ["RULES_PYTHON_BZLMOD_DEBUG"],
)
_DEBUG_BUILD_CONTENT = """
diff --git a/python/private/python_register_toolchains.bzl b/python/private/python_register_toolchains.bzl
index 2e0748d..9e75c41 100644
--- a/python/private/python_register_toolchains.bzl
+++ b/python/private/python_register_toolchains.bzl
@@ -97,21 +97,6 @@
toolchain_repo_name = "{name}_toolchains".format(name = name)
- # When using unreleased Bazel versions, the version is an empty string
- if native.bazel_version:
- bazel_major = int(native.bazel_version.split(".")[0])
- if bazel_major < 6:
- if register_coverage_tool:
- # buildifier: disable=print
- print((
- "WARNING: ignoring register_coverage_tool=True when " +
- "registering @{name}: Bazel 6+ required, got {version}"
- ).format(
- name = name,
- version = native.bazel_version,
- ))
- register_coverage_tool = False
-
# list[str] of the platform names that were used
loaded_platforms = []
diff --git a/python/private/repo_utils.bzl b/python/private/repo_utils.bzl
index 32a5b70..77eac55 100644
--- a/python/private/repo_utils.bzl
+++ b/python/private/repo_utils.bzl
@@ -291,7 +291,7 @@
"""
binary = mrctx.which(binary_name)
if binary:
- _watch(mrctx, binary)
+ mrctx.watch(binary)
describe_failure = None
else:
path = _getenv(mrctx, "PATH", "")
@@ -429,24 +429,6 @@
return "riscv64"
return arch
-# TODO: Remove after Bazel 6 support dropped
-def _watch(mrctx, *args, **kwargs):
- """Calls mrctx.watch, if available."""
- if not args and not kwargs:
- fail("'watch' needs at least a single argument.")
-
- if hasattr(mrctx, "watch"):
- mrctx.watch(*args, **kwargs)
-
-# TODO: Remove after Bazel 6 support dropped
-def _watch_tree(mrctx, *args, **kwargs):
- """Calls mrctx.watch_tree, if available."""
- if not args and not kwargs:
- fail("'watch_tree' needs at least a single argument.")
-
- if hasattr(mrctx, "watch_tree"):
- mrctx.watch_tree(*args, **kwargs)
-
repo_utils = struct(
# keep sorted
execute_checked = _execute_checked,
@@ -457,8 +439,6 @@
getenv = _getenv,
is_repo_debug_enabled = _is_repo_debug_enabled,
logger = _logger,
- watch = _watch,
- watch_tree = _watch_tree,
which_checked = _which_checked,
which_unchecked = _which_unchecked,
)
diff --git a/python/private/util.bzl b/python/private/util.bzl
index 4d2da57..d3053fe 100644
--- a/python/private/util.bzl
+++ b/python/private/util.bzl
@@ -15,7 +15,6 @@
"""Functionality shared by multiple pieces of code."""
load("@bazel_skylib//lib:types.bzl", "types")
-load("@rules_python_internal//:rules_python_config.bzl", "config")
def copy_propagating_kwargs(from_kwargs, into_kwargs = None):
"""Copies args that must be compatible between two targets with a dependency relationship.
@@ -50,21 +49,6 @@
# The implementation of the macros and tagging mechanism follows the example
# set by rules_cc and rules_java.
-_MIGRATION_TAG = "__PYTHON_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__"
-
-def add_migration_tag(attrs):
- """Add a special tag to `attrs` to aid migration off native rles.
-
- Args:
- attrs: dict of keyword args. The `tags` key will be modified in-place.
-
- Returns:
- The same `attrs` object, but modified.
- """
- if not config.enable_pystar:
- add_tag(attrs, _MIGRATION_TAG)
- return attrs
-
def add_tag(attrs, tag):
"""Adds `tag` to `attrs["tags"]`.
@@ -85,37 +69,3 @@
attrs["tags"] = tags + [tag]
else:
attrs["tags"] = [tag]
-
-# Helper to make the provider definitions not crash under Bazel 5.4:
-# Bazel 5.4 doesn't support the `init` arg of `provider()`, so we have to
-# not pass that when using Bazel 5.4. But, not passing the `init` arg
-# changes the return value from a two-tuple to a single value, which then
-# breaks Bazel 6+ code.
-# This isn't actually used under Bazel 5.4, so just stub out the values
-# to get past the loading phase.
-def define_bazel_6_provider(doc, fields, **kwargs):
- """Define a provider, or a stub for pre-Bazel 7."""
- if not IS_BAZEL_6_OR_HIGHER:
- return provider("Stub, not used", fields = []), None
- return provider(doc = doc, fields = fields, **kwargs)
-
-IS_BAZEL_7_4_OR_HIGHER = hasattr(native, "legacy_globals")
-
-IS_BAZEL_7_OR_HIGHER = hasattr(native, "starlark_doc_extract")
-
-# Bazel 5.4 has a bug where every access of testing.ExecutionInfo is a
-# different object that isn't equal to any other. This is fixed in bazel 6+.
-IS_BAZEL_6_OR_HIGHER = testing.ExecutionInfo == testing.ExecutionInfo
-
-_marker_rule_to_detect_bazel_6_4_or_higher = rule(implementation = lambda ctx: None)
-
-# Bazel 6.4 and higher have a bug fix where rule names show up in the str()
-# of a rule. See
-# https://github.com/bazelbuild/bazel/commit/002490b9a2376f0b2ea4a37102c5e94fc50a65ba
-# https://github.com/bazelbuild/bazel/commit/443cbcb641e17f7337ccfdecdfa5e69bc16cae55
-# This technique is done instead of using native.bazel_version because,
-# under stardoc, the native.bazel_version attribute is entirely missing, which
-# prevents doc generation from being able to correctly generate docs.
-IS_BAZEL_6_4_OR_HIGHER = "_marker_rule_to_detect_bazel_6_4_or_higher" in str(
- _marker_rule_to_detect_bazel_6_4_or_higher,
-)
diff --git a/python/py_binary.bzl b/python/py_binary.bzl
index 48ea768..4e26a29 100644
--- a/python/py_binary.bzl
+++ b/python/py_binary.bzl
@@ -14,13 +14,11 @@
"""Public entry point for py_binary."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_binary_macro.bzl", _starlark_py_binary = "py_binary")
load("//python/private:register_extension_info.bzl", "register_extension_info")
-load("//python/private:util.bzl", "add_migration_tag")
# buildifier: disable=native-python
-_py_binary_impl = _starlark_py_binary if config.enable_pystar else native.py_binary
+_py_binary_impl = _starlark_py_binary
def py_binary(**attrs):
"""Creates an executable Python program.
@@ -42,7 +40,7 @@
if attrs.get("srcs_version") in ("PY2", "PY2ONLY"):
fail("Python 2 is no longer supported: https://github.com/bazel-contrib/rules_python/issues/886")
- _py_binary_impl(**add_migration_tag(attrs))
+ _py_binary_impl(**attrs)
register_extension_info(
extension = py_binary,
diff --git a/python/py_cc_link_params_info.bzl b/python/py_cc_link_params_info.bzl
index 02eff71..6c510d6 100644
--- a/python/py_cc_link_params_info.bzl
+++ b/python/py_cc_link_params_info.bzl
@@ -1,10 +1,5 @@
"""Public entry point for PyCcLinkParamsInfo."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_cc_link_params_info.bzl", _starlark_PyCcLinkParamsInfo = "PyCcLinkParamsInfo")
-PyCcLinkParamsInfo = (
- _starlark_PyCcLinkParamsInfo if (
- config.enable_pystar or config.BuiltinPyCcLinkParamsProvider == None
- ) else config.BuiltinPyCcLinkParamsProvider
-)
+PyCcLinkParamsInfo = _starlark_PyCcLinkParamsInfo
diff --git a/python/py_info.bzl b/python/py_info.bzl
index 5697f58..5582d3b 100644
--- a/python/py_info.bzl
+++ b/python/py_info.bzl
@@ -14,8 +14,6 @@
"""Public entry point for PyInfo."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_info.bzl", _starlark_PyInfo = "PyInfo")
-load("//python/private:reexports.bzl", "BuiltinPyInfo")
-PyInfo = _starlark_PyInfo if config.enable_pystar or BuiltinPyInfo == None else BuiltinPyInfo
+PyInfo = _starlark_PyInfo
diff --git a/python/py_library.bzl b/python/py_library.bzl
index 8b8d468..4b79d8f 100644
--- a/python/py_library.bzl
+++ b/python/py_library.bzl
@@ -14,13 +14,11 @@
"""Public entry point for py_library."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_library_macro.bzl", _starlark_py_library = "py_library")
load("//python/private:register_extension_info.bzl", "register_extension_info")
-load("//python/private:util.bzl", "add_migration_tag")
# buildifier: disable=native-python
-_py_library_impl = _starlark_py_library if config.enable_pystar else native.py_library
+_py_library_impl = _starlark_py_library
def py_library(**attrs):
"""Creates an executable Python program.
@@ -39,7 +37,7 @@
if attrs.get("srcs_version") in ("PY2", "PY2ONLY"):
fail("Python 2 is no longer supported: https://github.com/bazel-contrib/rules_python/issues/886")
- _py_library_impl(**add_migration_tag(attrs))
+ _py_library_impl(**attrs)
register_extension_info(
extension = py_library,
diff --git a/python/py_runtime.bzl b/python/py_runtime.bzl
index dad2965..8c3cee2 100644
--- a/python/py_runtime.bzl
+++ b/python/py_runtime.bzl
@@ -15,10 +15,9 @@
"""Public entry point for py_runtime."""
load("//python/private:py_runtime_macro.bzl", _starlark_py_runtime = "py_runtime")
-load("//python/private:util.bzl", "IS_BAZEL_6_OR_HIGHER", "add_migration_tag")
# buildifier: disable=native-python
-_py_runtime_impl = _starlark_py_runtime if IS_BAZEL_6_OR_HIGHER else native.py_runtime
+_py_runtime_impl = _starlark_py_runtime
def py_runtime(**attrs):
"""Creates an executable Python program.
@@ -39,4 +38,4 @@
if attrs.get("python_version") == "PY2":
fail("Python 2 is no longer supported: see https://github.com/bazel-contrib/rules_python/issues/886")
- _py_runtime_impl(**add_migration_tag(attrs))
+ _py_runtime_impl(**attrs)
diff --git a/python/py_runtime_info.bzl b/python/py_runtime_info.bzl
index 3a31c0f..082a9b0 100644
--- a/python/py_runtime_info.bzl
+++ b/python/py_runtime_info.bzl
@@ -14,8 +14,6 @@
"""Public entry point for PyRuntimeInfo."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_runtime_info.bzl", _starlark_PyRuntimeInfo = "PyRuntimeInfo")
-load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo")
-PyRuntimeInfo = _starlark_PyRuntimeInfo if config.enable_pystar else BuiltinPyRuntimeInfo
+PyRuntimeInfo = _starlark_PyRuntimeInfo
diff --git a/python/py_runtime_pair.bzl b/python/py_runtime_pair.bzl
index 26d378f..97cc4f5 100644
--- a/python/py_runtime_pair.bzl
+++ b/python/py_runtime_pair.bzl
@@ -14,11 +14,9 @@
"""Public entry point for py_runtime_pair."""
-load("@bazel_tools//tools/python:toolchain.bzl", _bazel_tools_impl = "py_runtime_pair")
load("//python/private:py_runtime_pair_macro.bzl", _starlark_impl = "py_runtime_pair")
-load("//python/private:util.bzl", "IS_BAZEL_6_OR_HIGHER")
-_py_runtime_pair = _starlark_impl if IS_BAZEL_6_OR_HIGHER else _bazel_tools_impl
+_py_runtime_pair = _starlark_impl
# NOTE: This doc is copy/pasted from the builtin py_runtime_pair rule so our
# doc generator gives useful API docs.
diff --git a/python/py_test.bzl b/python/py_test.bzl
index b565773..5b8ad31 100644
--- a/python/py_test.bzl
+++ b/python/py_test.bzl
@@ -14,13 +14,11 @@
"""Public entry point for py_test."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("//python/private:py_test_macro.bzl", _starlark_py_test = "py_test")
load("//python/private:register_extension_info.bzl", "register_extension_info")
-load("//python/private:util.bzl", "add_migration_tag")
# buildifier: disable=native-python
-_py_test_impl = _starlark_py_test if config.enable_pystar else native.py_test
+_py_test_impl = _starlark_py_test
def py_test(**attrs):
"""Creates an executable Python program.
@@ -43,7 +41,7 @@
fail("Python 2 is no longer supported: https://github.com/bazel-contrib/rules_python/issues/886")
# buildifier: disable=native-python
- _py_test_impl(**add_migration_tag(attrs))
+ _py_test_impl(**attrs)
register_extension_info(
extension = py_test,
diff --git a/sphinxdocs/tests/proto_to_markdown/BUILD.bazel b/sphinxdocs/tests/proto_to_markdown/BUILD.bazel
index 09f5374..2964785 100644
--- a/sphinxdocs/tests/proto_to_markdown/BUILD.bazel
+++ b/sphinxdocs/tests/proto_to_markdown/BUILD.bazel
@@ -13,12 +13,10 @@
# limitations under the License.
load("//python:py_test.bzl", "py_test")
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
py_test(
name = "proto_to_markdown_test",
srcs = ["proto_to_markdown_test.py"],
- target_compatible_with = [] if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"],
deps = [
"//sphinxdocs/private:proto_to_markdown_lib",
"@dev_pip//absl_py",
diff --git a/sphinxdocs/tests/sphinx_docs/BUILD.bazel b/sphinxdocs/tests/sphinx_docs/BUILD.bazel
index f9c8296..33b98ec 100644
--- a/sphinxdocs/tests/sphinx_docs/BUILD.bazel
+++ b/sphinxdocs/tests/sphinx_docs/BUILD.bazel
@@ -1,5 +1,4 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load(":defs.bzl", "gen_directory")
@@ -13,7 +12,7 @@
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
-}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
+})
sphinx_docs(
name = "docs",
diff --git a/sphinxdocs/tests/sphinx_stardoc/BUILD.bazel b/sphinxdocs/tests/sphinx_stardoc/BUILD.bazel
index e3a68ea..af9af30 100644
--- a/sphinxdocs/tests/sphinx_stardoc/BUILD.bazel
+++ b/sphinxdocs/tests/sphinx_stardoc/BUILD.bazel
@@ -1,7 +1,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("//python:py_test.bzl", "py_test")
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//sphinxdocs:sphinx.bzl", "sphinx_build_binary", "sphinx_docs")
load("//sphinxdocs:sphinx_stardoc.bzl", "sphinx_stardoc", "sphinx_stardocs")
@@ -15,7 +14,7 @@
"@platforms//os:linux": [],
"@platforms//os:macos": [],
"//conditions:default": ["@platforms//:incompatible"],
-}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
+})
sphinx_docs(
name = "docs",
diff --git a/tests/api/py_common/py_common_tests.bzl b/tests/api/py_common/py_common_tests.bzl
index 572028b..028da6c 100644
--- a/tests/api/py_common/py_common_tests.bzl
+++ b/tests/api/py_common/py_common_tests.bzl
@@ -13,7 +13,6 @@
# limitations under the License.
"""py_common tests."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("@rules_testing//lib:util.bzl", rt_util = "util")
@@ -41,13 +40,11 @@
py_common = _py_common.get(env.ctx)
py1 = py_common.PyInfoBuilder()
- if config.enable_pystar:
- py1.direct_pyc_files.add(f1_pyc)
+ py1.direct_pyc_files.add(f1_pyc)
py1.transitive_sources.add(f1_py)
py2 = py_common.PyInfoBuilder()
- if config.enable_pystar:
- py1.direct_pyc_files.add(f2_pyc)
+ py1.direct_pyc_files.add(f2_pyc)
py2.transitive_sources.add(f2_py)
actual = py_info_subject(
@@ -56,8 +53,7 @@
)
actual.transitive_sources().contains_exactly([f1_py.path, f2_py.path])
- if config.enable_pystar:
- actual.direct_pyc_files().contains_exactly([f1_pyc.path, f2_pyc.path])
+ actual.direct_pyc_files().contains_exactly([f1_pyc.path, f2_pyc.path])
_tests.append(_test_merge_py_infos)
diff --git a/tests/base_rules/precompile/precompile_tests.bzl b/tests/base_rules/precompile/precompile_tests.bzl
index fe5c165..bff994a 100644
--- a/tests/base_rules/precompile/precompile_tests.bzl
+++ b/tests/base_rules/precompile/precompile_tests.bzl
@@ -14,7 +14,6 @@
"""Tests for precompiling behavior."""
-load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("@rules_testing//lib:truth.bzl", "matching")
@@ -42,9 +41,6 @@
_tests = []
def _test_executable_precompile_attr_enabled_setup(name, py_rule, **kwargs):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_rule,
name = name + "_subject",
@@ -112,9 +108,6 @@
_tests.append(_test_precompile_enabled_py_test)
def _test_precompile_enabled_py_library_setup(name, impl, config_settings):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_library,
name = name + "_subject",
@@ -178,9 +171,6 @@
_tests.append(_test_precompile_enabled_py_library_add_to_runfiles_enabled)
def _test_pyc_only(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_binary,
name = name + "_subject",
@@ -231,9 +221,6 @@
)
def _test_precompiler_action(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_binary,
name = name + "_subject",
@@ -325,9 +312,6 @@
return _verify_runfiles_impl
def _test_precompile_flag_enabled_pyc_collection_attr_include_pyc(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
_setup_precompile_flag_pyc_collection_attr_interaction(
name = name,
precompile_flag = "enabled",
@@ -351,9 +335,6 @@
"""Verify that a binary can opt-out of using implicit pycs even when
precompiling is enabled by default.
"""
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
_setup_precompile_flag_pyc_collection_attr_interaction(
name = name,
precompile_flag = "enabled",
@@ -376,9 +357,6 @@
def _test_precompile_flag_disabled_pyc_collection_attr_include_pyc(name):
"""Verify that a binary can opt-in to using pycs even when precompiling is
disabled by default."""
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
_setup_precompile_flag_pyc_collection_attr_interaction(
name = name,
precompile_flag = "disabled",
@@ -398,9 +376,6 @@
_tests.append(_test_precompile_flag_disabled_pyc_collection_attr_include_pyc)
def _test_precompile_flag_disabled_pyc_collection_attr_disabled(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
_setup_precompile_flag_pyc_collection_attr_interaction(
name = name,
precompile_flag = "disabled",
@@ -424,9 +399,6 @@
"""Verify that, when a binary doesn't include implicit pyc files, libraries
that set omit_source still have the py source file included.
"""
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_binary,
name = name + "_subject",
@@ -469,9 +441,6 @@
_tests.append(_test_pyc_collection_disabled_library_omit_source)
def _test_pyc_collection_include_dep_omit_source(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_binary,
name = name + "_subject",
@@ -513,9 +482,6 @@
_tests.append(_test_pyc_collection_include_dep_omit_source)
def _test_precompile_attr_inherit_pyc_collection_disabled_precompile_flag_enabled(name):
- if not rp_config.enable_pystar:
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
py_binary,
name = name + "_subject",
diff --git a/tests/base_rules/py_executable_base_tests.bzl b/tests/base_rules/py_executable_base_tests.bzl
index 4e45128..c7723be 100644
--- a/tests/base_rules/py_executable_base_tests.bzl
+++ b/tests/base_rules/py_executable_base_tests.bzl
@@ -14,14 +14,12 @@
"""Tests common to py_binary and py_test (executable rules)."""
load("@rules_python//python:py_runtime_info.bzl", RulesPythonPyRuntimeInfo = "PyRuntimeInfo")
-load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:truth.bzl", "matching")
load("@rules_testing//lib:util.bzl", rt_util = "util")
load("//python:py_executable_info.bzl", "PyExecutableInfo")
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
load("//python/private:reexports.bzl", "BuiltinPyRuntimeInfo") # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//tests/base_rules:base_tests.bzl", "create_base_tests")
load("//tests/base_rules:util.bzl", "WINDOWS_ATTR", pt_util = "util")
load("//tests/support:py_executable_info_subject.bzl", "PyExecutableInfoSubject")
@@ -30,10 +28,6 @@
_tests = []
def _test_basic_windows(name, config):
- if rp_config.enable_pystar:
- target_compatible_with = []
- else:
- target_compatible_with = ["@platforms//:incompatible"]
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -56,7 +50,7 @@
"//command_line_option:extra_toolchains": [CC_TOOLCHAIN],
"//command_line_option:platforms": [WINDOWS_X86_64],
},
- attr_values = {"target_compatible_with": target_compatible_with},
+ attr_values = {},
)
def _test_basic_windows_impl(env, target):
@@ -72,14 +66,11 @@
_tests.append(_test_basic_windows)
def _test_basic_zip(name, config):
- if rp_config.enable_pystar:
- target_compatible_with = select({
- # Disable the new test on windows because we have _test_basic_windows.
- "@platforms//os:windows": ["@platforms//:incompatible"],
- "//conditions:default": [],
- })
- else:
- target_compatible_with = ["@platforms//:incompatible"]
+ target_compatible_with = select({
+ # Disable the new test on windows because we have _test_basic_windows.
+ "@platforms//os:windows": ["@platforms//:incompatible"],
+ "//conditions:default": [],
+ })
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -140,14 +131,13 @@
"{workspace}/{package}/{test_name}_subject" + exe,
])
- if rp_config.enable_pystar:
- py_exec_info = env.expect.that_target(target).provider(PyExecutableInfo, factory = PyExecutableInfoSubject.new)
- py_exec_info.main().path().contains("_subject.py")
- py_exec_info.interpreter_path().contains("python")
- py_exec_info.runfiles_without_exe().contains_none_of([
- "{workspace}/{package}/{test_name}_subject" + exe,
- "{workspace}/{package}/{test_name}_subject",
- ])
+ py_exec_info = env.expect.that_target(target).provider(PyExecutableInfo, factory = PyExecutableInfoSubject.new)
+ py_exec_info.main().path().contains("_subject.py")
+ py_exec_info.interpreter_path().contains("python")
+ py_exec_info.runfiles_without_exe().contains_none_of([
+ "{workspace}/{package}/{test_name}_subject" + exe,
+ "{workspace}/{package}/{test_name}_subject",
+ ])
def _test_default_main_can_be_generated(name, config):
rt_util.helper_target(
@@ -188,11 +178,6 @@
)
def _test_default_main_must_be_in_srcs(name, config):
- # Bazel 5 will crash with a Java stacktrace when the native Python
- # rules have an error.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -213,11 +198,6 @@
)
def _test_default_main_cannot_be_ambiguous(name, config):
- # Bazel 5 will crash with a Java stacktrace when the native Python
- # rules have an error.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -260,11 +240,6 @@
)
def _test_explicit_main_cannot_be_ambiguous(name, config):
- # Bazel 5 will crash with a Java stacktrace when the native Python
- # rules have an error.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -310,22 +285,16 @@
"{package}/{test_name}_subject.py",
])
- if IS_BAZEL_7_OR_HIGHER:
- # As of Bazel 7, the first default output is the executable, so
- # verify that is the case. rules_testing
- # DepsetFileSubject.contains_exactly doesn't provide an in_order()
- # call, nor access to the underlying depset, so we have to do things
- # manually.
- first_default_output = target[DefaultInfo].files.to_list()[0]
- executable = target[DefaultInfo].files_to_run.executable
- env.expect.that_file(first_default_output).equals(executable)
+ # As of Bazel 7, the first default output is the executable, so
+ # verify that is the case. rules_testing
+ # DepsetFileSubject.contains_exactly doesn't provide an in_order()
+ # call, nor access to the underlying depset, so we have to do things
+ # manually.
+ first_default_output = target[DefaultInfo].files.to_list()[0]
+ executable = target[DefaultInfo].files_to_run.executable
+ env.expect.that_file(first_default_output).equals(executable)
def _test_name_cannot_end_in_py(name, config):
- # Bazel 5 will crash with a Java stacktrace when the native Python
- # rules have an error.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
config.rule,
name = name + "_subject.py",
diff --git a/tests/base_rules/py_info/py_info_tests.bzl b/tests/base_rules/py_info/py_info_tests.bzl
index aa252a2..6235948 100644
--- a/tests/base_rules/py_info/py_info_tests.bzl
+++ b/tests/base_rules/py_info/py_info_tests.bzl
@@ -13,7 +13,6 @@
# limitations under the License.
"""Tests for py_info."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("@rules_testing//lib:util.bzl", rt_util = "util")
@@ -39,11 +38,10 @@
kwargs["has_py2_only_sources"] = bool(ctx.attr.has_py2_only_sources)
providers = []
- if config.enable_pystar:
- providers.append(PyInfo(**kwargs))
+ providers.append(PyInfo(**kwargs))
# Handle Bazel 6 or if Bazel autoloading is enabled
- if not config.enable_pystar or (BuiltinPyInfo and PyInfo != BuiltinPyInfo):
+ if BuiltinPyInfo and PyInfo != BuiltinPyInfo:
providers.append(BuiltinPyInfo(**{
k: kwargs[k]
for k in (
@@ -95,10 +93,8 @@
imports = depset(["import-path"]),
transitive_sources = depset([trans_py]),
uses_shared_libraries = True,
- **(dict(
- direct_pyc_files = depset([direct_pyc]),
- transitive_pyc_files = depset([trans_pyc]),
- ) if config.enable_pystar else {})
+ direct_pyc_files = depset([direct_pyc]),
+ transitive_pyc_files = depset([trans_pyc]),
)
subject = py_info_subject(actual, meta = env.expect.meta)
@@ -107,9 +103,8 @@
subject.has_py3_only_sources().equals(True)
subject.transitive_sources().contains_exactly(["tests/base_rules/py_info/trans.py"])
subject.imports().contains_exactly(["import-path"])
- if config.enable_pystar:
- subject.direct_pyc_files().contains_exactly(["tests/base_rules/py_info/direct.pyc"])
- subject.transitive_pyc_files().contains_exactly(["tests/base_rules/py_info/trans.pyc"])
+ subject.direct_pyc_files().contains_exactly(["tests/base_rules/py_info/direct.pyc"])
+ subject.transitive_pyc_files().contains_exactly(["tests/base_rules/py_info/trans.pyc"])
_tests.append(_test_py_info_create)
diff --git a/tests/base_rules/py_test/py_test_tests.bzl b/tests/base_rules/py_test/py_test_tests.bzl
index 1ec1dc4..c28eec4 100644
--- a/tests/base_rules/py_test/py_test_tests.bzl
+++ b/tests/base_rules/py_test/py_test_tests.bzl
@@ -39,14 +39,6 @@
_tests = []
def _test_mac_requires_darwin_for_execution(name, config):
- # Bazel 5.4 has a bug where every access of testing.ExecutionInfo is
- # a different object that isn't equal to any other, which prevents
- # rules_testing from detecting it properly and fails with an error.
- # This is fixed in Bazel 6+.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
-
rt_util.helper_target(
config.rule,
name = name + "_subject",
@@ -74,13 +66,6 @@
_tests.append(_test_mac_requires_darwin_for_execution)
def _test_non_mac_doesnt_require_darwin_for_execution(name, config):
- # Bazel 5.4 has a bug where every access of testing.ExecutionInfo is
- # a different object that isn't equal to any other, which prevents
- # rules_testing from detecting it properly and fails with an error.
- # This is fixed in Bazel 6+.
- if not pt_util.is_bazel_6_or_higher():
- rt_util.skip_test(name = name)
- return
rt_util.helper_target(
config.rule,
name = name + "_subject",
diff --git a/tests/base_rules/util.bzl b/tests/base_rules/util.bzl
index a02cafa..9fb66d7 100644
--- a/tests/base_rules/util.bzl
+++ b/tests/base_rules/util.bzl
@@ -14,7 +14,6 @@
"""Helpers and utilities multiple tests re-use."""
load("@bazel_skylib//lib:structs.bzl", "structs")
-load("//python/private:util.bzl", "IS_BAZEL_6_OR_HIGHER") # buildifier: disable=bzl-visibility
# Use this with is_windows()
WINDOWS_ATTR = {"windows": attr.label(default = "@platforms//os:windows")}
@@ -53,9 +52,6 @@
struct_dict.update(kwargs)
return struct(**struct_dict)
-def _is_bazel_6_or_higher():
- return IS_BAZEL_6_OR_HIGHER
-
def _is_windows(env):
"""Tell if the target platform is windows.
@@ -72,6 +68,5 @@
util = struct(
create_tests = _create_tests,
struct_with = _struct_with,
- is_bazel_6_or_higher = _is_bazel_6_or_higher,
is_windows = _is_windows,
)
diff --git a/tests/bootstrap_impls/a/b/c/BUILD.bazel b/tests/bootstrap_impls/a/b/c/BUILD.bazel
index 1659ef2..1c4b1e7 100644
--- a/tests/bootstrap_impls/a/b/c/BUILD.bazel
+++ b/tests/bootstrap_impls/a/b/c/BUILD.bazel
@@ -1,10 +1,9 @@
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//tests/support:py_reconfig.bzl", "py_reconfig_test")
_SUPPORTS_BOOTSTRAP_SCRIPT = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
-}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
+})
py_reconfig_test(
name = "nested_dir_test",
diff --git a/tests/config_settings/transition/multi_version_tests.bzl b/tests/config_settings/transition/multi_version_tests.bzl
index 93f6efd..b2564a3 100644
--- a/tests/config_settings/transition/multi_version_tests.bzl
+++ b/tests/config_settings/transition/multi_version_tests.bzl
@@ -16,12 +16,11 @@
load("@pythons_hub//:versions.bzl", "DEFAULT_PYTHON_VERSION")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
-load("@rules_testing//lib:util.bzl", "TestingAspectInfo", rt_util = "util")
+load("@rules_testing//lib:util.bzl", rt_util = "util")
load("//python:py_binary.bzl", "py_binary")
load("//python:py_info.bzl", "PyInfo")
load("//python:py_test.bzl", "py_test")
load("//python/private:reexports.bzl", "BuiltinPyInfo") # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//tests/support:support.bzl", "CC_TOOLCHAIN")
# NOTE @aignas 2024-06-04: we are using here something that is registered in the MODULE.Bazel
@@ -106,20 +105,15 @@
def _test_py_binary_windows_build_python_zip_false_impl(env, target):
default_outputs = env.expect.that_target(target).default_outputs()
- if IS_BAZEL_7_OR_HIGHER:
- # TODO: These outputs aren't correct. The outputs shouldn't
- # have the "_" prefix on them (those are coming from the underlying
- # wrapped binary).
- env.expect.that_target(target).default_outputs().contains_exactly([
- "{package}/{test_name}_subject.exe",
- "{package}/{test_name}_subject",
- "{package}/{test_name}_subject.py",
- ])
- else:
- inner_exe = target[TestingAspectInfo].attrs.target[DefaultInfo].files_to_run.executable
- default_outputs.contains_at_least([
- inner_exe.short_path,
- ])
+
+ # TODO: These outputs aren't correct. The outputs shouldn't
+ # have the "_" prefix on them (those are coming from the underlying
+ # wrapped binary).
+ default_outputs.contains_exactly([
+ "{package}/{test_name}_subject.exe",
+ "{package}/{test_name}_subject",
+ "{package}/{test_name}_subject.py",
+ ])
_tests.append(_test_py_binary_windows_build_python_zip_false)
@@ -132,21 +126,15 @@
def _test_py_binary_windows_build_python_zip_true_impl(env, target):
default_outputs = env.expect.that_target(target).default_outputs()
- if IS_BAZEL_7_OR_HIGHER:
- # TODO: These outputs aren't correct. The outputs shouldn't
- # have the "_" prefix on them (those are coming from the underlying
- # wrapped binary).
- default_outputs.contains_exactly([
- "{package}/{test_name}_subject.exe",
- "{package}/{test_name}_subject.py",
- "{package}/{test_name}_subject.zip",
- ])
- else:
- inner_exe = target[TestingAspectInfo].attrs.target[DefaultInfo].files_to_run.executable
- default_outputs.contains_at_least([
- "{package}/{test_name}_subject.zip",
- inner_exe.short_path,
- ])
+
+ # TODO: These outputs aren't correct. The outputs shouldn't
+ # have the "_" prefix on them (those are coming from the underlying
+ # wrapped binary).
+ default_outputs.contains_exactly([
+ "{package}/{test_name}_subject.exe",
+ "{package}/{test_name}_subject.py",
+ "{package}/{test_name}_subject.zip",
+ ])
_tests.append(_test_py_binary_windows_build_python_zip_true)
diff --git a/tests/exec_toolchain_matching/exec_toolchain_matching_tests.bzl b/tests/exec_toolchain_matching/exec_toolchain_matching_tests.bzl
index 43a9717..b3ff294 100644
--- a/tests/exec_toolchain_matching/exec_toolchain_matching_tests.bzl
+++ b/tests/exec_toolchain_matching/exec_toolchain_matching_tests.bzl
@@ -20,7 +20,6 @@
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
load("//python/private:toolchain_types.bzl", "EXEC_TOOLS_TOOLCHAIN_TYPE", "TARGET_TOOLCHAIN_TYPE") # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//tests/support:support.bzl", "LINUX", "MAC")
_LookupInfo = provider() # buildifier: disable=provider-params
@@ -143,11 +142,10 @@
env.expect.that_str(target_runtime.interpreter_path).equals("/linux/python3.12")
env.expect.that_str(exec_runtime.interpreter_path).equals("/mac/python3.12")
- if IS_BAZEL_7_OR_HIGHER:
- target_version = target_runtime.interpreter_version_info
- exec_version = exec_runtime.interpreter_version_info
+ target_version = target_runtime.interpreter_version_info
+ exec_version = exec_runtime.interpreter_version_info
- env.expect.that_bool(target_version == exec_version)
+ env.expect.that_bool(target_version == exec_version)
def exec_toolchain_matching_test_suite(name):
test_suite(name = name, tests = _tests)
diff --git a/tests/integration/integration_test.bzl b/tests/integration/integration_test.bzl
index c437953..90cc4a3 100644
--- a/tests/integration/integration_test.bzl
+++ b/tests/integration/integration_test.bzl
@@ -35,12 +35,6 @@
)
return test_runner
- if bazel_version.startswith("6") and not bzlmod:
- if gazelle_plugin:
- return "//tests/integration:bazel_6_4_workspace_test_runner_gazelle_plugin"
- else:
- return "//tests/integration:bazel_6_4_workspace_test_runner"
-
if bzlmod and gazelle_plugin:
return "//tests/integration:test_runner_gazelle_plugin"
elif bzlmod:
diff --git a/tests/py_runtime/py_runtime_tests.bzl b/tests/py_runtime/py_runtime_tests.bzl
index 4ec7590..b8aa1f3 100644
--- a/tests/py_runtime/py_runtime_tests.bzl
+++ b/tests/py_runtime/py_runtime_tests.bzl
@@ -13,7 +13,6 @@
# limitations under the License.
"""Starlark tests for py_runtime rule."""
-load("@rules_python_internal//:rules_python_config.bzl", "config")
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("@rules_testing//lib:truth.bzl", "matching")
@@ -21,15 +20,10 @@
load("//python:py_runtime.bzl", "py_runtime")
load("//python:py_runtime_info.bzl", "PyRuntimeInfo")
load("//python/private:common_labels.bzl", "labels") # buildifier: disable=bzl-visibility
-load("//tests/base_rules:util.bzl", br_util = "util")
load("//tests/support:py_runtime_info_subject.bzl", "py_runtime_info_subject")
_tests = []
-_SKIP_TEST = {
- "target_compatible_with": ["@platforms//:incompatible"],
-}
-
def _simple_binary_impl(ctx):
executable = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(executable, "", is_executable = True)
@@ -49,27 +43,18 @@
)
def _test_bootstrap_template(name):
- # The bootstrap_template arg isn't present in older Bazel versions, so
- # we have to conditionally pass the arg and mark the test incompatible.
- if config.enable_pystar:
- py_runtime_kwargs = {"bootstrap_template": "bootstrap.txt"}
- attr_values = {}
- else:
- py_runtime_kwargs = {}
- attr_values = _SKIP_TEST
-
rt_util.helper_target(
py_runtime,
name = name + "_subject",
interpreter_path = "/py",
python_version = "PY3",
- **py_runtime_kwargs
+ bootstrap_template = "bootstrap.txt",
)
analysis_test(
name = name,
target = name + "_subject",
impl = _test_bootstrap_template_impl,
- attr_values = attr_values,
+ attr_values = {},
)
def _test_bootstrap_template_impl(env, target):
@@ -81,29 +66,19 @@
_tests.append(_test_bootstrap_template)
def _test_cannot_have_both_inbuild_and_system_interpreter(name):
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {
- "interpreter": "fake_interpreter",
- "interpreter_path": "/some/path",
- }
- attr_values = {}
- else:
- py_runtime_kwargs = {
- "interpreter_path": "/some/path",
- }
- attr_values = _SKIP_TEST
rt_util.helper_target(
py_runtime,
name = name + "_subject",
python_version = "PY3",
- **py_runtime_kwargs
+ interpreter = "fake_interpreter",
+ interpreter_path = "/some/path",
)
analysis_test(
name = name,
target = name + "_subject",
impl = _test_cannot_have_both_inbuild_and_system_interpreter_impl,
expect_failure = True,
- attr_values = attr_values,
+ attr_values = {},
)
def _test_cannot_have_both_inbuild_and_system_interpreter_impl(env, target):
@@ -114,25 +89,19 @@
_tests.append(_test_cannot_have_both_inbuild_and_system_interpreter)
def _test_cannot_specify_files_for_system_interpreter(name):
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {"files": ["foo.txt"]}
- attr_values = {}
- else:
- py_runtime_kwargs = {}
- attr_values = _SKIP_TEST
rt_util.helper_target(
py_runtime,
name = name + "_subject",
interpreter_path = "/foo",
python_version = "PY3",
- **py_runtime_kwargs
+ files = ["foo.txt"],
)
analysis_test(
name = name,
target = name + "_subject",
impl = _test_cannot_specify_files_for_system_interpreter_impl,
expect_failure = True,
- attr_values = attr_values,
+ attr_values = {},
)
def _test_cannot_specify_files_for_system_interpreter_impl(env, target):
@@ -143,21 +112,12 @@
_tests.append(_test_cannot_specify_files_for_system_interpreter)
def _test_coverage_tool_executable(name):
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {
- "coverage_tool": name + "_coverage_tool",
- }
- attr_values = {}
- else:
- py_runtime_kwargs = {}
- attr_values = _SKIP_TEST
-
rt_util.helper_target(
py_runtime,
name = name + "_subject",
python_version = "PY3",
interpreter_path = "/bogus",
- **py_runtime_kwargs
+ coverage_tool = name + "_coverage_tool",
)
rt_util.helper_target(
_simple_binary,
@@ -168,7 +128,7 @@
name = name,
target = name + "_subject",
impl = _test_coverage_tool_executable_impl,
- attr_values = attr_values,
+ attr_values = {},
)
def _test_coverage_tool_executable_impl(env, target):
@@ -183,14 +143,10 @@
_tests.append(_test_coverage_tool_executable)
def _test_coverage_tool_plain_files(name):
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {
- "coverage_tool": name + "_coverage_tool",
- }
- attr_values = {}
- else:
- py_runtime_kwargs = {}
- attr_values = _SKIP_TEST
+ py_runtime_kwargs = {
+ "coverage_tool": name + "_coverage_tool",
+ }
+ attr_values = {}
rt_util.helper_target(
py_runtime,
name = name + "_subject",
@@ -334,14 +290,8 @@
_tests.append(_test_interpreter_binary_with_single_output_and_runfiles)
def _test_must_have_either_inbuild_or_system_interpreter(name):
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {}
- attr_values = {}
- else:
- py_runtime_kwargs = {
- "interpreter_path": "/some/path",
- }
- attr_values = _SKIP_TEST
+ py_runtime_kwargs = {}
+ attr_values = {}
rt_util.helper_target(
py_runtime,
name = name + "_subject",
@@ -385,14 +335,8 @@
_tests.append(_test_system_interpreter)
def _test_system_interpreter_must_be_absolute(name):
- # Bazel 5.4 will entirely crash when an invalid interpreter_path
- # is given.
- if br_util.is_bazel_6_or_higher():
- py_runtime_kwargs = {"interpreter_path": "relative/path"}
- attr_values = {}
- else:
- py_runtime_kwargs = {"interpreter_path": "/junk/value/for/bazel5.4"}
- attr_values = _SKIP_TEST
+ py_runtime_kwargs = {"interpreter_path": "relative/path"}
+ attr_values = {}
rt_util.helper_target(
py_runtime,
name = name + "_subject",
@@ -415,28 +359,19 @@
_tests.append(_test_system_interpreter_must_be_absolute)
def _interpreter_version_info_test(name, interpreter_version_info, impl, expect_failure = True):
- if config.enable_pystar:
- py_runtime_kwargs = {
- "interpreter_version_info": interpreter_version_info,
- }
- attr_values = {}
- else:
- py_runtime_kwargs = {}
- attr_values = _SKIP_TEST
-
rt_util.helper_target(
py_runtime,
name = name + "_subject",
python_version = "PY3",
interpreter_path = "/py",
- **py_runtime_kwargs
+ interpreter_version_info = interpreter_version_info,
)
analysis_test(
name = name,
target = name + "_subject",
impl = impl,
expect_failure = expect_failure,
- attr_values = attr_values,
+ attr_values = {},
)
def _test_interpreter_version_info_must_define_major_and_minor_only_major(name):
@@ -530,9 +465,6 @@
_tests.append(_test_interpreter_version_info_parses_values_to_struct)
def _test_version_info_from_flag(name):
- if not config.enable_pystar:
- rt_util.skip_test(name)
- return
py_runtime(
name = name + "_subject",
interpreter_version_info = None,
diff --git a/tests/py_runtime_info/py_runtime_info_tests.bzl b/tests/py_runtime_info/py_runtime_info_tests.bzl
index 9acf541..a44fb60 100644
--- a/tests/py_runtime_info/py_runtime_info_tests.bzl
+++ b/tests/py_runtime_info/py_runtime_info_tests.bzl
@@ -16,18 +16,13 @@
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
load("@rules_testing//lib:test_suite.bzl", "test_suite")
load("//python:py_runtime_info.bzl", "PyRuntimeInfo")
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
def _create_py_runtime_info_without_interpreter_version_info_impl(ctx):
- kwargs = {}
- if IS_BAZEL_7_OR_HIGHER:
- kwargs["bootstrap_template"] = ctx.attr.bootstrap_template
-
return [PyRuntimeInfo(
interpreter = ctx.file.interpreter,
files = depset(ctx.files.files),
python_version = "PY3",
- **kwargs
+ bootstrap_template = ctx.attr.bootstrap_template,
)]
_create_py_runtime_info_without_interpreter_version_info = rule(
diff --git a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
index ec7ca63..615358f 100644
--- a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
+++ b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
@@ -15,7 +15,6 @@
""
load("@rules_testing//lib:test_suite.bzl", "test_suite")
-load("//python/private:glob_excludes.bzl", "glob_excludes") # buildifier: disable=bzl-visibility
load(
"//python/private/pypi:whl_library_targets.bzl",
"whl_library_targets",
@@ -217,7 +216,6 @@
filegroup = lambda **kwargs: filegroup_calls.append(kwargs),
config_setting = lambda **_: None,
glob = mock_glob.glob,
- select = _select,
),
rules = struct(
py_library = lambda **kwargs: py_library_calls.append(kwargs),
@@ -230,7 +228,7 @@
{
"name": "whl",
"srcs": ["foo-0-py3-none-any.whl"],
- "data": ["@pypi//bar:whl"] + _select({
+ "data": ["@pypi//bar:whl"] + select({
":is_include_bar_baz_true": ["@pypi//bar_baz:whl"],
"//conditions:default": [],
}),
@@ -245,14 +243,14 @@
env.expect.that_dict(py_library_call).contains_exactly({
"name": "pkg",
- "srcs": ["site-packages/foo/SRCS.py"] + _select({
+ "srcs": ["site-packages/foo/SRCS.py"] + select({
Label("//python/config_settings:is_venvs_site_packages"): [],
"//conditions:default": ["_create_inits_target"],
}),
"pyi_srcs": ["site-packages/foo/PYI.pyi"],
"data": ["site-packages/foo/DATA.txt"],
"imports": ["site-packages"],
- "deps": ["@pypi//bar:pkg"] + _select({
+ "deps": ["@pypi//bar:pkg"] + select({
":is_include_bar_baz_true": ["@pypi//bar_baz:pkg"],
"//conditions:default": [],
}),
@@ -276,7 +274,7 @@
"**/*.pyc",
"**/*.pyc.*",
"**/*.dist-info/RECORD",
- ] + glob_excludes.version_dependent_exclusions(),
+ ],
),
# pyi call
_glob_call(["site-packages/**/*.pyi"], allow_empty = True),
@@ -321,7 +319,6 @@
filegroup = lambda **kwargs: filegroup_calls.append(kwargs),
config_setting = lambda **_: None,
glob = mock_glob.glob,
- select = _select,
),
rules = struct(
py_library = lambda **kwargs: py_library_calls.append(kwargs),
@@ -336,7 +333,7 @@
"data": [
"@pypi_bar_baz//:whl",
"@pypi_foo//:whl",
- ] + _select(
+ ] + select(
{
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:whl"],
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:whl"],
@@ -357,7 +354,7 @@
return
env.expect.that_dict(py_library_calls[0]).contains_exactly({
"name": "pkg",
- "srcs": ["site-packages/foo/SRCS.py"] + _select({
+ "srcs": ["site-packages/foo/SRCS.py"] + select({
Label("//python/config_settings:is_venvs_site_packages"): [],
"//conditions:default": ["_create_inits_target"],
}),
@@ -367,7 +364,7 @@
"deps": [
"@pypi_bar_baz//:pkg",
"@pypi_foo//:pkg",
- ] + _select(
+ ] + select(
{
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:pkg"],
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:pkg"],
@@ -415,7 +412,6 @@
config_setting = lambda **_: None,
glob = mock_glob.glob,
alias = lambda **kwargs: alias_calls.append(kwargs),
- select = _select,
),
rules = struct(
py_library = lambda **kwargs: py_library_calls.append(kwargs),
@@ -437,14 +433,14 @@
py_library_call,
).contains_exactly({
"name": "_pkg",
- "srcs": ["site-packages/foo/srcs.py"] + _select({
+ "srcs": ["site-packages/foo/srcs.py"] + select({
Label("//python/config_settings:is_venvs_site_packages"): [],
"//conditions:default": ["_create_inits_target"],
}),
"pyi_srcs": ["site-packages/foo/pyi.pyi"],
"data": ["site-packages/foo/data.txt"],
"imports": ["site-packages"],
- "deps": ["@pypi_bar_baz//:pkg"] + _select({
+ "deps": ["@pypi_bar_baz//:pkg"] + select({
"@platforms//os:linux": ["@pypi_box//:pkg"],
":is_linux_x86_64": ["@pypi_box//:pkg", "@pypi_box_amd64//:pkg"],
"//conditions:default": [],
@@ -491,13 +487,6 @@
)
return mock
-def _select(*args, **kwargs):
- """We need to have this mock select because we still need to support bazel 6."""
- return [struct(
- select = args,
- kwargs = kwargs,
- )]
-
def whl_library_targets_test_suite(name):
"""create the test suite.
diff --git a/tests/runtime_env_toolchain/runtime_env_toolchain_tests.bzl b/tests/runtime_env_toolchain/runtime_env_toolchain_tests.bzl
index aa4d1c7..527448e 100644
--- a/tests/runtime_env_toolchain/runtime_env_toolchain_tests.bzl
+++ b/tests/runtime_env_toolchain/runtime_env_toolchain_tests.bzl
@@ -24,7 +24,6 @@
"PY_CC_TOOLCHAIN_TYPE",
"TARGET_TOOLCHAIN_TYPE",
) # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
load("//tests/support:support.bzl", "CC_TOOLCHAIN")
_LookupInfo = provider() # buildifier: disable=provider-params
@@ -55,25 +54,14 @@
name = name + "_subject",
)
extra_toolchains = [
+ # We have to add a cc toolchain because py_cc toolchain depends on it.
+ # However, that package also defines a different fake py_cc toolchain we
+ # don't want to use, so we need to ensure the runtime_env toolchain has
+ # higher precendence.
+ CC_TOOLCHAIN,
str(Label("//python/runtime_env_toolchains:all")),
]
- # We have to add a cc toolchain because py_cc toolchain depends on it.
- # However, that package also defines a different fake py_cc toolchain we
- # don't want to use, so we need to ensure the runtime_env toolchain has
- # higher precendence.
- # However, Bazel 6 and Bazel 7 process --extra_toolchains in different
- # orders:
- # * Bazel 6 goes left to right
- # * Bazel 7 goes right to left
- # We could just put our preferred toolchain before *and* after
- # the undesired toolchain...
- # However, Bazel 7 has a bug where *duplicate* entries are ignored,
- # and only the *first* entry is respected.
- if IS_BAZEL_7_OR_HIGHER:
- extra_toolchains.insert(0, CC_TOOLCHAIN)
- else:
- extra_toolchains.append(CC_TOOLCHAIN)
analysis_test(
name = name,
impl = _test_runtime_env_toolchain_matches_impl,
diff --git a/tests/support/support.bzl b/tests/support/support.bzl
index 37d3488..96c6ad9 100644
--- a/tests/support/support.bzl
+++ b/tests/support/support.bzl
@@ -20,7 +20,6 @@
# places.
load("//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") # buildifier: disable=bzl-visibility
-load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable=bzl-visibility
MAC = Label("//tests/support:mac")
MAC_X86_64 = Label("//tests/support:mac_x86_64")
@@ -40,7 +39,7 @@
SUPPORTS_BOOTSTRAP_SCRIPT = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
-}) if IS_BAZEL_7_OR_HIGHER else ["@platforms//:incompatible"]
+})
SUPPORTS_BZLMOD_UNIXY = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
diff --git a/tests/support/whl_from_dir/whl_from_dir_repo.bzl b/tests/support/whl_from_dir/whl_from_dir_repo.bzl
index 1765256..4e16e8e 100644
--- a/tests/support/whl_from_dir/whl_from_dir_repo.bzl
+++ b/tests/support/whl_from_dir/whl_from_dir_repo.bzl
@@ -8,7 +8,7 @@
def _whl_from_dir_repo(rctx):
root = rctx.path(rctx.attr.root).dirname
- repo_utils.watch_tree(rctx, root)
+ rctx.watch_tree(root)
output = rctx.path(rctx.attr.output)
repo_utils.execute_checked(