Skip to content

Commit

Permalink
python: remove unused Java code
Browse files Browse the repository at this point in the history
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 #15897

PiperOrigin-RevId: 514566571
Change-Id: I28ef124369fc678945873bc21919830cb73eafc8
  • Loading branch information
rickeylev authored and copybara-github committed Mar 7, 2023
1 parent 8548e20 commit 4427a1f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1,323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@

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

import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;

import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuleClasses.PyBinaryBaseRule;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.rules.python.PyRuleClasses;
Expand All @@ -41,15 +38,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
return builder
.requiresConfigurationFragments(PythonConfiguration.class, BazelPythonConfiguration.class)
.cfg(PyRuleClasses.VERSION_TRANSITION)
.add(
attr("$zipper", LABEL)
.cfg(ExecutionTransitionFactory.create())
.exec()
.value(env.getToolsLabel("//tools/zip:zipper")))
.add(
attr("$launcher", LABEL)
.cfg(ExecutionTransitionFactory.create())
.value(env.getToolsLabel("//tools/launcher:launcher")))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
import static com.google.devtools.build.lib.packages.BuildType.NODEP_LABEL;
import static com.google.devtools.build.lib.packages.BuildType.TRISTATE;
import static com.google.devtools.build.lib.packages.Type.STRING;
import static com.google.devtools.build.lib.packages.Type.STRING_LIST;
Expand All @@ -36,7 +35,6 @@
import com.google.devtools.build.lib.rules.python.PyCommon;
import com.google.devtools.build.lib.rules.python.PyInfo;
import com.google.devtools.build.lib.rules.python.PyRuleClasses;
import com.google.devtools.build.lib.rules.python.PyRuntimeInfo;
import com.google.devtools.build.lib.rules.python.PythonVersion;

/**
Expand Down Expand Up @@ -215,18 +213,6 @@ responsible for creating (possibly empty) __init__.py files and adding them to t
<p>Stamped binaries are <em>not</em> rebuilt unless their dependencies change.</p>
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.add(attr("stamp", TRISTATE).value(TriState.AUTO))
// TODO(brandjon): Consider adding to py_interpreter a .mandatoryBuiltinProviders() of
// PyRuntimeInfoProvider. (Add a test case to PythonConfigurationTest for violations of
// this requirement.) Probably moot now that this is going to be replaced by toolchains.
.add(attr(":py_interpreter", LABEL).value(PY_INTERPRETER))
.add(
attr("$py_toolchain_type", NODEP_LABEL)
.value(env.getToolsLabel("//tools/python:toolchain_type")))
/* Only used when no py_runtime() is available. See #7901
*/
.add(
attr("$default_bootstrap_template", LABEL)
.value(env.getToolsLabel(PyRuntimeInfo.DEFAULT_BOOTSTRAP_TEMPLATE)))
.addToolchainTypes(
ToolchainTypeRequirement.builder(env.getToolsLabel("//tools/python:toolchain_type"))
.mandatory(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
package com.google.devtools.build.lib.bazel.rules.python;

import static com.google.devtools.build.lib.packages.Attribute.attr;
import static com.google.devtools.build.lib.packages.BuildType.LABEL;
import static com.google.devtools.build.lib.packages.BuildType.TRISTATE;
import static com.google.devtools.build.lib.packages.Type.BOOLEAN;

import com.google.devtools.build.lib.analysis.BaseRuleClasses;
import com.google.devtools.build.lib.analysis.RuleDefinition;
import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyRuleClasses.PyBinaryBaseRule;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
Expand All @@ -39,11 +37,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
return builder
.requiresConfigurationFragments(PythonConfiguration.class, BazelPythonConfiguration.class)
.cfg(PyRuleClasses.VERSION_TRANSITION)
.add(
attr("$zipper", LABEL)
.cfg(ExecutionTransitionFactory.create())
.exec()
.value(env.getToolsLabel("//tools/zip:zipper")))
.override(
attr("testonly", BOOLEAN)
.value(true)
Expand All @@ -53,21 +46,6 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
that the stamp argument is set to 0 by default for tests.
<!-- #END_BLAZE_RULE.ATTRIBUTE --> */
.override(attr("stamp", TRISTATE).value(TriState.NO))
.add(
attr("$launcher", LABEL)
.cfg(ExecutionTransitionFactory.create())
.value(env.getToolsLabel("//tools/launcher:launcher")))
.add(
attr(":lcov_merger", LABEL)
.cfg(ExecutionTransitionFactory.create())
.value(BaseRuleClasses.getCoverageOutputGeneratorLabel()))
// Add the script as an attribute in order for py_test to output code coverage results for
// code covered by CC binaries invocations.
.add(
attr("$collect_cc_coverage", LABEL)
.cfg(ExecutionTransitionFactory.create())
.singleArtifact()
.value(env.getToolsLabel("//tools/test:collect_cc_coverage")))
.build();
}

Expand Down
Loading

0 comments on commit 4427a1f

Please sign in to comment.