Skip to content

Commit 93dff6a

Browse files
committed
Switch to rp_config
1 parent 5f580c9 commit 93dff6a

6 files changed

Lines changed: 14 additions & 16 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module(
44
compatibility_level = 1,
55
)
66

7-
bazel_dep(name = "bazel_features", version = "1.30.0")
7+
bazel_dep(name = "bazel_features", version = "1.21.0")
88
bazel_dep(name = "bazel_skylib", version = "1.8.2")
99
bazel_dep(name = "rules_cc", version = "0.1.5")
1010
bazel_dep(name = "platforms", version = "0.0.11")

internal_dev_deps.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ def rules_python_internal_deps():
231231

232232
http_archive(
233233
name = "bazel_features",
234-
sha256 = "a660027f5a87f13224ab54b8dc6e191693c554f2692fcca46e8e29ee7dabc43b",
235-
strip_prefix = "bazel_features-1.30.0",
236-
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.30.0/bazel_features-v1.30.0.tar.gz",
234+
sha256 = "d7787da289a7fb497352211ad200ec9f698822a9e0757a4976fd9f713ff372b3",
235+
strip_prefix = "bazel_features-1.9.1",
236+
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.9.1/bazel_features-v1.9.1.tar.gz",
237237
)
238238

239239
http_archive(

python/private/internal_config_repo.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ config = struct(
3232
enable_pystar = True,
3333
enable_pipstar = {enable_pipstar},
3434
enable_deprecation_warnings = {enable_deprecation_warnings},
35+
bazel_9_or_later = {bazel_9_or_later},
3536
BuiltinPyInfo = getattr(getattr(native, "legacy_globals", None), "PyInfo", {builtin_py_info_symbol}),
3637
BuiltinPyRuntimeInfo = getattr(getattr(native, "legacy_globals", None), "PyRuntimeInfo", {builtin_py_runtime_info_symbol}),
3738
BuiltinPyCcLinkParamsProvider = getattr(getattr(native, "legacy_globals", None), "PyCcLinkParamsProvider", {builtin_py_cc_link_params_provider}),
@@ -91,10 +92,12 @@ def _internal_config_repo_impl(rctx):
9192
builtin_py_info_symbol = "None"
9293
builtin_py_runtime_info_symbol = "None"
9394
builtin_py_cc_link_params_provider = "None"
95+
bazel_9_or_later = "True"
9496
else:
9597
builtin_py_info_symbol = "PyInfo"
9698
builtin_py_runtime_info_symbol = "PyRuntimeInfo"
9799
builtin_py_cc_link_params_provider = "PyCcLinkParamsProvider"
100+
bazel_9_or_later = "False"
98101

99102
rctx.file("rules_python_config.bzl", _CONFIG_TEMPLATE.format(
100103
build_python_zip_default = repo_utils.get_platforms_os_name(rctx) == "windows",
@@ -103,6 +106,7 @@ def _internal_config_repo_impl(rctx):
103106
builtin_py_info_symbol = builtin_py_info_symbol,
104107
builtin_py_runtime_info_symbol = builtin_py_runtime_info_symbol,
105108
builtin_py_cc_link_params_provider = builtin_py_cc_link_params_provider,
109+
bazel_9_or_later = bazel_9_or_later,
106110
))
107111

108112
shim_content = _PY_INTERNAL_SHIM

python/private/py_executable.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# limitations under the License.
1414
"""Common functionality between test/binary executables."""
1515

16-
load("@bazel_features//:features.bzl", "bazel_features")
1716
load("@bazel_skylib//lib:dicts.bzl", "dicts")
1817
load("@bazel_skylib//lib:paths.bzl", "paths")
1918
load("@bazel_skylib//lib:structs.bzl", "structs")
2019
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
2120
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
21+
load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
2222
load(":attr_builders.bzl", "attrb")
2323
load(
2424
":attributes.bzl",
@@ -242,7 +242,7 @@ accepting arbitrary Python versions.
242242
cfg = "exec",
243243
executable = True,
244244
),
245-
} if not bazel_features.rules._has_launcher_maker_toolchain else {},
245+
} if not rp_config.bazel_9_or_later else {},
246246
)
247247

248248
def convert_legacy_create_init_to_int(kwargs):
@@ -782,7 +782,7 @@ def _create_stage1_bootstrap(
782782
)
783783

784784
def _find_launcher_maker(ctx):
785-
if bazel_features.rules._has_launcher_maker_toolchain:
785+
if rp_config.bazel_9_or_later:
786786
return ctx.toolchains[_LAUNCHER_MAKER_TOOLCHAIN_TYPE].binary
787787
return ctx.executable._windows_launcher_maker
788788

@@ -1847,7 +1847,7 @@ def create_executable_rule_builder(implementation, **kwargs):
18471847
ruleb.ToolchainType(TOOLCHAIN_TYPE),
18481848
ruleb.ToolchainType(EXEC_TOOLS_TOOLCHAIN_TYPE, mandatory = False),
18491849
ruleb.ToolchainType("@bazel_tools//tools/cpp:toolchain_type", mandatory = False),
1850-
] + ([ruleb.ToolchainType(_LAUNCHER_MAKER_TOOLCHAIN_TYPE)] if bazel_features.rules._has_launcher_maker_toolchain else []),
1850+
] + ([ruleb.ToolchainType(_LAUNCHER_MAKER_TOOLCHAIN_TYPE)] if rp_config.bazel_9_or_later else []),
18511851
cfg = dict(
18521852
implementation = _transition_executable_impl,
18531853
inputs = TRANSITION_LABELS + [labels.PYTHON_VERSION],

python/private/py_repositories.bzl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ def py_repositories(transition_settings = []):
7272
strip_prefix = "rules_cc-0.1.5",
7373
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.5/rules_cc-0.1.5.tar.gz"],
7474
)
75-
http_archive(
76-
name = "bazel_features",
77-
sha256 = "a660027f5a87f13224ab54b8dc6e191693c554f2692fcca46e8e29ee7dabc43b",
78-
strip_prefix = "bazel_features-1.30.0",
79-
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.30.0/bazel_features-v1.30.0.tar.gz",
80-
)
8175

8276
# Needed by rules_cc, triggered by @rules_java_prebuilt in Bazel by using @rules_cc//cc:defs.bzl
8377
# NOTE: This name must be com_google_protobuf until Bazel drops WORKSPACE

tests/base_rules/py_executable_base_tests.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# limitations under the License.
1414
"""Tests common to py_binary and py_test (executable rules)."""
1515

16-
load("@bazel_features//:features.bzl", "bazel_features")
1716
load("@rules_python//python:py_runtime_info.bzl", RulesPythonPyRuntimeInfo = "PyRuntimeInfo")
17+
load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config")
1818
load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
1919
load("@rules_testing//lib:truth.bzl", "matching")
2020
load("@rules_testing//lib:util.bzl", rt_util = "util")
@@ -116,7 +116,7 @@ def _test_basic_zip_impl(env, target):
116116
_tests.append(_test_basic_zip)
117117

118118
def _test_cross_compile_to_unix(name, config):
119-
if not bazel_features.rules._has_launcher_maker_toolchain or "py_test" in str(config.rule):
119+
if not rp_config.bazel_9_or_later or "py_test" in str(config.rule):
120120
# The default test toolchain prevents cross-compiling py_test to
121121
# a non-exec platform.
122122
return

0 commit comments

Comments
 (0)