Skip to content

Commit

Permalink
python: Remove PythonSemantics classes
Browse files Browse the repository at this point in the history
All they contain is the GET_INIT_PY_FILES function, which is really only used
by the PyBuiltins class.

PiperOrigin-RevId: 587053249
Change-Id: Iebd9db51513029d47a5148d4855334b44d7638d4
  • Loading branch information
rickeylev authored and copybara-github committed Dec 1, 2023
1 parent 6982e85 commit a3a2bf2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@

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

import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.rules.python.PyBuiltins;
import com.google.devtools.build.lib.rules.python.PythonUtils;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.SerializationConstant;
import java.util.UUID;

/** PyBuiltins with Bazel-specific functionality. */
public final class BazelPyBuiltins extends PyBuiltins {

private static final UUID GUID = UUID.fromString("0211a192-1b1e-40e6-80e9-7352360b12b1");

@SerializationConstant
public static final Runfiles.EmptyFilesSupplier GET_INIT_PY_FILES =
new PythonUtils.GetInitPyFiles(source -> false, GUID);

public BazelPyBuiltins() {
super(BazelPythonSemantics.GET_INIT_PY_FILES);
super(GET_INIT_PY_FILES);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ private SourceManifestAction createAction(ManifestType type, boolean addInitPy)
Runfiles.Builder builder = new Runfiles.Builder("TESTING", false);
builder.addSymlinks(fakeManifest);
if (addInitPy) {
builder.setEmptyFilesSupplier(
analysisMock.pySupport().getPythonSemantics().getEmptyRunfilesSupplier());
builder.setEmptyFilesSupplier(analysisMock.pySupport().getEmptyRunfilesSupplier());
}
return new SourceManifestAction(type, NULL_ACTION_OWNER, manifestOutputFile, builder.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

package com.google.devtools.build.lib.packages.util;

import com.google.devtools.build.lib.bazel.rules.python.BazelPythonSemantics;
import com.google.devtools.build.lib.rules.python.PythonSemantics;
import com.google.devtools.build.lib.analysis.Runfiles;
import com.google.devtools.build.lib.bazel.rules.python.BazelPyBuiltins;
import com.google.devtools.build.lib.testutil.TestConstants;
import java.io.IOException;

Expand Down Expand Up @@ -85,7 +85,7 @@ public String createPythonTopEntryPoint(MockToolsConfig config, String pyRuntime
}

@Override
public PythonSemantics getPythonSemantics() {
return new BazelPythonSemantics();
public Runfiles.EmptyFilesSupplier getEmptyRunfilesSupplier() {
return BazelPyBuiltins.GET_INIT_PY_FILES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package com.google.devtools.build.lib.packages.util;

import com.google.devtools.build.lib.rules.python.PythonSemantics;
import com.google.devtools.build.lib.analysis.Runfiles;
import java.io.IOException;

/** Creates mock BUILD files required for the python rules. */
Expand All @@ -31,5 +31,5 @@ public abstract class MockPythonSupport {
public abstract String createPythonTopEntryPoint(MockToolsConfig config, String pyRuntimeLabel)
throws IOException;

public abstract PythonSemantics getPythonSemantics();
public abstract Runfiles.EmptyFilesSupplier getEmptyRunfilesSupplier();
}

0 comments on commit a3a2bf2

Please sign in to comment.