aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-09-07 14:20:09 +0000
committerGravatar Yun Peng <pcloudy@google.com>2016-09-08 08:43:37 +0000
commit75733e1cceb04f5eaeb3ba821f9c96886af9c0be (patch)
tree283ec9dad77748fcfd8775a984933a72490636a3 /src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java
parent09cb1a72fecade911b14208801c95a9f4f8ac83a (diff)
Remove some unused code from the Python rules.
-- MOS_MIGRATED_REVID=132433369
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java b/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java
index ab3f3210f3..f5875fa48c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PyCommon.java
@@ -20,7 +20,6 @@ import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Action;
import com.google.devtools.build.lib.actions.ActionOwner;
import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.ResourceSet;
import com.google.devtools.build.lib.actions.extra.ExtraActionInfo;
import com.google.devtools.build.lib.actions.extra.PythonInfo;
import com.google.devtools.build.lib.analysis.AnalysisEnvironment;
@@ -34,9 +33,7 @@ import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.SkylarkProviders;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.Util;
-import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.cmdline.Label;
-import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
import com.google.devtools.build.lib.collect.nestedset.Order;
@@ -468,67 +465,6 @@ public final class PyCommon {
}
}
- protected static final ResourceSet PY_COMPILE_RESOURCE_SET =
- ResourceSet.createWithRamCpuIo(10 /* MB */, 1 /* CPU */, 0.0 /* IO */);
-
- /**
- * Utility function to compile multiple .py files to .pyc files.
- */
- public Collection<Artifact> createPycFiles(
- Iterable<Artifact> sources, PathFragment pythonBinary,
- String pythonPrecompileAttribute, String hostPython2RuntimeAttribute) {
- List<Artifact> pycFiles = new ArrayList<>();
- for (Artifact source : sources) {
- Artifact pycFile = createPycFile(source, pythonBinary, pythonPrecompileAttribute,
- hostPython2RuntimeAttribute);
- if (pycFile != null) {
- pycFiles.add(pycFile);
- }
- }
- return ImmutableList.copyOf(pycFiles);
- }
-
- /**
- * Given a single .py source artifact generate a .pyc file.
- * @param pythonPrecompileAttribute e.g., "$python_precompile".
- * @param hostPython2RuntimeAttribute e.g., ":host_python2_runtime".
- */
- public Artifact createPycFile(
- Artifact source, PathFragment pythonBinary,
- String pythonPrecompileAttribute, String hostPython2RuntimeAttribute) {
- PackageIdentifier packageId = ruleContext.getLabel().getPackageIdentifier();
- PackageIdentifier itemPackageId = source.getOwner().getPackageIdentifier();
- if (!itemPackageId.equals(packageId)) {
- // This will produce an error, so we skip this element.
- return null;
- }
-
- Artifact output =
- ruleContext.getRelatedArtifact(source.getRootRelativePath(), ".pyc");
-
- // TODO(nnorwitz): Consider adding PYTHONHASHSEED=0 to the environment.
- // This will make the .pyc more stable, though it will still be non-deterministic.
- // The timestamp is zeroed out above.
- SpawnAction.Builder builder = new SpawnAction.Builder()
- .setResources(PY_COMPILE_RESOURCE_SET)
- .setExecutable(pythonBinary)
- .setProgressMessage("Compiling Python " + source.prettyPrint())
- .addInputArgument(
- ruleContext.getPrerequisiteArtifact(pythonPrecompileAttribute, Mode.HOST))
- .setMnemonic("PyCompile");
-
- TransitiveInfoCollection pythonTarget =
- ruleContext.getPrerequisite(hostPython2RuntimeAttribute, Mode.HOST);
- if (pythonTarget != null) {
- builder.addTransitiveInputs(pythonTarget.getProvider(FileProvider.class).getFilesToBuild());
- }
-
- builder.addInputArgument(source);
- builder.addOutputArgument(output);
- ruleContext.registerAction(builder.build(ruleContext));
- return output;
- }
-
/**
* Returns true if this target has an .so file in its transitive dependency closure.