Skip to content

Commit 35cbc55

Browse files
committed
Revert "fix(toolchain): do not force users to depend on optional toolchains"
This reverts commit 7db60b1.
1 parent 8c5503c commit 35cbc55

File tree

7 files changed

+4
-63
lines changed

7 files changed

+4
-63
lines changed

CHANGELOG.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ A brief description of the categories of changes:
2828
* `protobuf`/`com_google_protobuf` dependency bumped to `v24.4`
2929

3030
### Fixed
31-
* The targets would depend on the `exec_tools_toolchain_type` toolchain if it
32-
was registered even though the pre-compilation was not enabled. This has been
33-
fixed to not be the case anymore. Fixes
34-
[#1967](https://github.com/bazelbuild/rules_python/issues/1967). Users
35-
wanting to use the `precompile` feature may have to set the config setting to
36-
always do the precompilation and per-target pre-compilation is for now
37-
disabled.
31+
* Nothing yet
3832

3933
### Removed
4034
* Nothing yet

python/config_settings/BUILD.bazel

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
load("@bazel_skylib//lib:selects.bzl", "selects")
21
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
32
load(
43
"//python/private:flags.bzl",
@@ -129,45 +128,3 @@ string_flag(
129128
)
130129
for flag in INTERNAL_FLAGS
131130
]
132-
133-
config_setting(
134-
name = "_precompile_enabled",
135-
flag_values = {
136-
":precompile": PrecompileFlag.ENABLED,
137-
},
138-
# Only public because it is used in toolchain definition
139-
visibility = ["//visibility:public"],
140-
)
141-
142-
config_setting(
143-
name = "_precompile_enabled_generated_source",
144-
flag_values = {
145-
":precompile": PrecompileFlag.IF_GENERATED_SOURCE,
146-
},
147-
# Only public because it is used in toolchain definition
148-
visibility = ["//visibility:public"],
149-
)
150-
151-
config_setting(
152-
name = "_precompile_enabled_force",
153-
flag_values = {
154-
":precompile": PrecompileFlag.FORCE_ENABLED,
155-
},
156-
# Only public because it is used in toolchain definition
157-
visibility = ["//visibility:public"],
158-
)
159-
160-
# FIXME @aignas 2024-06-14: this currently does not handle the `auto` value of
161-
# the flag correctly. Right now the behaviour is to disable the pre-compilation
162-
# via the _precompile_flag_get_effective_value function default to disabled if
163-
# it the flag is "AUTO", however we may need to revisit this.
164-
selects.config_setting_group(
165-
name = "is_precompile_enabled",
166-
match_any = [
167-
":_precompile_enabled",
168-
":_precompile_enabled_force",
169-
":_precompile_enabled_generated_source",
170-
],
171-
# Only public because it is used in toolchain definition
172-
visibility = ["//visibility:public"],
173-
)

python/private/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ bzl_library(
5959
name = "autodetecting_toolchain_bzl",
6060
srcs = ["autodetecting_toolchain.bzl"],
6161
deps = [
62-
":toolchain_types_bzl",
6362
"//python:py_runtime_bzl",
6463
"//python:py_runtime_pair_bzl",
6564
],

python/private/autodetecting_toolchain.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
load("//python:py_runtime.bzl", "py_runtime")
1818
load("//python:py_runtime_pair.bzl", "py_runtime_pair")
19-
load("//python/private:toolchain_types.bzl", "TARGET_TOOLCHAIN_TYPE")
2019

2120
def define_autodetecting_toolchain(name):
2221
"""Defines the autodetecting Python toolchain.
@@ -66,6 +65,6 @@ def define_autodetecting_toolchain(name):
6665
native.toolchain(
6766
name = name,
6867
toolchain = ":_autodetecting_py_runtime_pair",
69-
toolchain_type = TARGET_TOOLCHAIN_TYPE,
68+
toolchain_type = ":toolchain_type",
7069
visibility = ["//visibility:public"],
7170
)

python/private/flags.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BootstrapImplFlag = enum(
3434
def _precompile_flag_get_effective_value(ctx):
3535
value = ctx.attr._precompile_flag[BuildSettingInfo].value
3636
if value == PrecompileFlag.AUTO:
37-
value = PrecompileFlag.IF_GENERATED_SOURCE
37+
value = PrecompileFlag.DISABLED
3838
return value
3939

4040
# Determines if Python source files should be compiled at build time.

python/private/py_toolchain_suite.bzl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ def py_toolchain_suite(*, prefix, user_repository_name, python_version, set_pyth
107107
),
108108
toolchain_type = EXEC_TOOLS_TOOLCHAIN_TYPE,
109109
# The target settings capture the Python version
110-
target_settings = select({
111-
Label("//python/config_settings:is_precompile_enabled"): target_settings,
112-
"//conditions:default": [Label("//python/config_settings:is_precompile_enabled")],
113-
}),
110+
target_settings = target_settings,
114111
exec_compatible_with = kwargs.get("target_compatible_with"),
115112
)
116113

tests/base_rules/precompile/precompile_tests.bzl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def _test_precompile_enabled_setup(name, py_rule, **kwargs):
6161
target = name + "_subject",
6262
config_settings = {
6363
"//command_line_option:extra_toolchains": _TEST_TOOLCHAINS,
64-
PRECOMPILE: "enabled",
6564
},
6665
)
6766

@@ -120,7 +119,6 @@ def _test_pyc_only(name):
120119
config_settings = {
121120
"//command_line_option:extra_toolchains": _TEST_TOOLCHAINS,
122121
##PRECOMPILE_SOURCE_RETENTION: "omit_source",
123-
PRECOMPILE: "enabled",
124122
},
125123
target = name + "_subject",
126124
)
@@ -163,7 +161,6 @@ def _test_precompile_if_generated(name):
163161
target = name + "_subject",
164162
config_settings = {
165163
"//command_line_option:extra_toolchains": _TEST_TOOLCHAINS,
166-
PRECOMPILE: "enabled",
167164
},
168165
)
169166

@@ -206,7 +203,6 @@ def _test_omit_source_if_generated_source(name):
206203
config_settings = {
207204
"//command_line_option:extra_toolchains": _TEST_TOOLCHAINS,
208205
PRECOMPILE_SOURCE_RETENTION: "omit_if_generated_source",
209-
PRECOMPILE: "enabled",
210206
},
211207
)
212208

@@ -292,7 +288,6 @@ def _test_precompiler_action(name):
292288
target = name + "_subject",
293289
config_settings = {
294290
"//command_line_option:extra_toolchains": _TEST_TOOLCHAINS,
295-
PRECOMPILE: "enabled",
296291
},
297292
)
298293

0 commit comments

Comments
 (0)