Skip to content

Commit 7d8e8ea

Browse files
rickeylevfweikert
authored andcommitted
python: remove unused Java code
With the deletion of the Java rule implementation, large amounts of code are now unused. Entire removal of the classes isn't yet possible, but most of their code can be removed. This also makes it easier to transition to the Starlark providers, since less Java code is referencing the to-be-deleted Java providers Work towards bazelbuild#15897 PiperOrigin-RevId: 514566571 Change-Id: I28ef124369fc678945873bc21919830cb73eafc8
1 parent 13cd115 commit 7d8e8ea

File tree

5 files changed

+13
-1323
lines changed

5 files changed

+13
-1323
lines changed

src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyBinaryRule.java

-12
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414

1515
package com.google.devtools.build.lib.bazel.rules.python;
1616

17-
import static com.google.devtools.build.lib.packages.Attribute.attr;
18-
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
1917

2018
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
2119
import com.google.devtools.build.lib.analysis.RuleDefinition;
2220
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
23-
import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
2421
import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuleClasses.PyBinaryBaseRule;
2522
import com.google.devtools.build.lib.packages.RuleClass;
2623
import com.google.devtools.build.lib.rules.python.PyRuleClasses;
@@ -41,15 +38,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
4138
return builder
4239
.requiresConfigurationFragments(PythonConfiguration.class, BazelPythonConfiguration.class)
4340
.cfg(PyRuleClasses.VERSION_TRANSITION)
44-
.add(
45-
attr("$zipper", LABEL)
46-
.cfg(ExecutionTransitionFactory.create())
47-
.exec()
48-
.value(env.getToolsLabel("//tools/zip:zipper")))
49-
.add(
50-
attr("$launcher", LABEL)
51-
.cfg(ExecutionTransitionFactory.create())
52-
.value(env.getToolsLabel("//tools/launcher:launcher")))
5341
.build();
5442
}
5543

src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuleClasses.java

-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import static com.google.devtools.build.lib.packages.Attribute.attr;
1818
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
1919
import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
20-
import static com.google.devtools.build.lib.packages.BuildType.NODEP_LABEL;
2120
import static com.google.devtools.build.lib.packages.BuildType.TRISTATE;
2221
import static com.google.devtools.build.lib.packages.Type.STRING;
2322
import static com.google.devtools.build.lib.packages.Type.STRING_LIST;
@@ -36,7 +35,6 @@
3635
import com.google.devtools.build.lib.rules.python.PyCommon;
3736
import com.google.devtools.build.lib.rules.python.PyInfo;
3837
import com.google.devtools.build.lib.rules.python.PyRuleClasses;
39-
import com.google.devtools.build.lib.rules.python.PyRuntimeInfo;
4038
import com.google.devtools.build.lib.rules.python.PythonVersion;
4139

4240
/**
@@ -215,18 +213,6 @@ responsible for creating (possibly empty) __init__.py files and adding them to t
215213
<p>Stamped binaries are <em>not</em> rebuilt unless their dependencies change.</p>
216214
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
217215
.add(attr("stamp", TRISTATE).value(TriState.AUTO))
218-
// TODO(brandjon): Consider adding to py_interpreter a .mandatoryBuiltinProviders() of
219-
// PyRuntimeInfoProvider. (Add a test case to PythonConfigurationTest for violations of
220-
// this requirement.) Probably moot now that this is going to be replaced by toolchains.
221-
.add(attr(":py_interpreter", LABEL).value(PY_INTERPRETER))
222-
.add(
223-
attr("$py_toolchain_type", NODEP_LABEL)
224-
.value(env.getToolsLabel("//tools/python:toolchain_type")))
225-
/* Only used when no py_runtime() is available. See #7901
226-
*/
227-
.add(
228-
attr("$default_bootstrap_template", LABEL)
229-
.value(env.getToolsLabel(PyRuntimeInfo.DEFAULT_BOOTSTRAP_TEMPLATE)))
230216
.addToolchainTypes(
231217
ToolchainTypeRequirement.builder(env.getToolsLabel("//tools/python:toolchain_type"))
232218
.mandatory(true)

src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyTestRule.java

-22
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
package com.google.devtools.build.lib.bazel.rules.python;
1616

1717
import static com.google.devtools.build.lib.packages.Attribute.attr;
18-
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
1918
import static com.google.devtools.build.lib.packages.BuildType.TRISTATE;
2019
import static com.google.devtools.build.lib.packages.Type.BOOLEAN;
2120

2221
import com.google.devtools.build.lib.analysis.BaseRuleClasses;
2322
import com.google.devtools.build.lib.analysis.RuleDefinition;
2423
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
25-
import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
2624
import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuleClasses.PyBinaryBaseRule;
2725
import com.google.devtools.build.lib.packages.RuleClass;
2826
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
@@ -39,11 +37,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
3937
return builder
4038
.requiresConfigurationFragments(PythonConfiguration.class, BazelPythonConfiguration.class)
4139
.cfg(PyRuleClasses.VERSION_TRANSITION)
42-
.add(
43-
attr("$zipper", LABEL)
44-
.cfg(ExecutionTransitionFactory.create())
45-
.exec()
46-
.value(env.getToolsLabel("//tools/zip:zipper")))
4740
.override(
4841
attr("testonly", BOOLEAN)
4942
.value(true)
@@ -53,21 +46,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
5346
that the stamp argument is set to 0 by default for tests.
5447
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
5548
.override(attr("stamp", TRISTATE).value(TriState.NO))
56-
.add(
57-
attr("$launcher", LABEL)
58-
.cfg(ExecutionTransitionFactory.create())
59-
.value(env.getToolsLabel("//tools/launcher:launcher")))
60-
.add(
61-
attr(":lcov_merger", LABEL)
62-
.cfg(ExecutionTransitionFactory.create())
63-
.value(BaseRuleClasses.getCoverageOutputGeneratorLabel()))
64-
// Add the script as an attribute in order for py_test to output code coverage results for
65-
// code covered by CC binaries invocations.
66-
.add(
67-
attr("$collect_cc_coverage", LABEL)
68-
.cfg(ExecutionTransitionFactory.create())
69-
.singleArtifact()
70-
.value(env.getToolsLabel("//tools/test:collect_cc_coverage")))
7149
.build();
7250
}
7351

0 commit comments

Comments
 (0)