Skip to content

Commit f5ae2b4

Browse files
committed
use internal config repo instead
1 parent f919b80 commit f5ae2b4

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

python/config_settings/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
22
load("@pythons_hub//:versions.bzl", "DEFAULT_PYTHON_VERSION", "MINOR_MAPPING", "PYTHON_VERSIONS")
3+
load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
34
load(
45
"//python/private:flags.bzl",
56
"AddSrcsToRunfilesFlag",
@@ -13,7 +14,6 @@ load(
1314
"VenvsUseDeclareSymlinkFlag",
1415
rp_string_flag = "string_flag",
1516
)
16-
load("//python/private:util.bzl", "IS_BAZEL_8_OR_HIGHER")
1717
load(
1818
"//python/private/pypi:flags.bzl",
1919
"UniversalWhlFlag",
@@ -91,7 +91,7 @@ string_flag(
9191

9292
rp_string_flag(
9393
name = "bootstrap_impl",
94-
build_setting_default = BootstrapImplFlag.SCRIPT if IS_BAZEL_8_OR_HIGHER else BootstrapImplFlag.SYSTEM_PYTHON,
94+
build_setting_default = rp_config.bootstrap_impl_default,
9595
override = select({
9696
# Windows doesn't yet support bootstrap=script, so force disable it
9797
":_is_windows": BootstrapImplFlag.SYSTEM_PYTHON,

python/private/internal_config_repo.bzl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ such as globals available to Bazel versions, or propagating user environment
1818
settings for rules to later use.
1919
"""
2020

21+
load("//python/private:flags.bzl", "BootstrapImplFlag")
2122
load("//python/private:text_util.bzl", "render")
2223
load(":repo_utils.bzl", "repo_utils")
2324

@@ -30,6 +31,7 @@ _CONFIG_TEMPLATE = """
3031
config = struct(
3132
enable_pystar = True,
3233
enable_pipstar = {enable_pipstar},
34+
bootstrap_impl_default = "{bootstrap_impl_default}",
3335
enable_deprecation_warnings = {enable_deprecation_warnings},
3436
BuiltinPyInfo = getattr(getattr(native, "legacy_globals", None), "PyInfo", {builtin_py_info_symbol}),
3537
BuiltinPyRuntimeInfo = getattr(getattr(native, "legacy_globals", None), "PyRuntimeInfo", {builtin_py_runtime_info_symbol}),
@@ -86,32 +88,32 @@ _TRANSITION_SETTINGS_DEBUG_TEMPLATE = """
8688
"""
8789

8890
def _internal_config_repo_impl(rctx):
91+
# TODO: remove the conditional once bazel 7 is no longer supported
8992
if not native.bazel_version or int(native.bazel_version.split(".")[0]) >= 8:
9093
builtin_py_info_symbol = "None"
9194
builtin_py_runtime_info_symbol = "None"
9295
builtin_py_cc_link_params_provider = "None"
96+
bootstrap_impl_default = BootstrapImplFlag.SCRIPT
9397
else:
9498
builtin_py_info_symbol = "PyInfo"
9599
builtin_py_runtime_info_symbol = "PyRuntimeInfo"
96100
builtin_py_cc_link_params_provider = "PyCcLinkParamsProvider"
101+
bootstrap_impl_default = BootstrapImplFlag.SYSTEM_PYTHON
97102

98103
rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
99104
enable_pipstar = _bool_from_environ(rctx, _ENABLE_PIPSTAR_ENVVAR_NAME, _ENABLE_PIPSTAR_DEFAULT),
105+
bootstrap_impl_default = bootstrap_impl_default,
100106
enable_deprecation_warnings = _bool_from_environ(rctx, _ENABLE_DEPRECATION_WARNINGS_ENVVAR_NAME, _ENABLE_DEPRECATION_WARNINGS_DEFAULT),
101107
builtin_py_info_symbol = builtin_py_info_symbol,
102108
builtin_py_runtime_info_symbol = builtin_py_runtime_info_symbol,
103109
builtin_py_cc_link_params_provider = builtin_py_cc_link_params_provider,
104110
))
105111

106-
shim_content = _PY_INTERNAL_SHIM
107-
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"'
108-
109112
rctx.file("BUILD", ROOT_BUILD_TEMPLATE.format(
110-
py_internal_dep = py_internal_dep,
113+
py_internal_dep = '"@rules_python//tools/build_defs/python/private:py_internal_renamed_bzl"',
111114
visibility = "@rules_python//:__subpackages__",
112115
))
113-
rctx.file("py_internal.bzl", shim_content)
114-
116+
rctx.file("py_internal.bzl", _PY_INTERNAL_SHIM)
115117
rctx.file(
116118
"extra_transition_settings.bzl",
117119
_EXTRA_TRANSITIONS_TEMPLATE.format(

python/private/util.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,3 @@ def add_tag(attrs, tag):
6969
attrs["tags"] = tags + [tag]
7070
else:
7171
attrs["tags"] = [tag]
72-
73-
# `config.none` was introduced in Bazel 8
74-
IS_BAZEL_8_OR_HIGHER = hasattr(config, "none")

0 commit comments

Comments
 (0)