Skip to content

Commit

Permalink
Remove prebuiltLibraries from PythonPackageComponents
Browse files Browse the repository at this point in the history
Summary: Removes prebuiltLibraries from PythonPackageComponents. We now extract sources from prebuilt_python_library and merge it into the top level module directory, so there's no need to keep this duplicate field around.

Test Plan: CI

Reviewed By: andrewjcg

fbshipit-source-id: 7cec967
  • Loading branch information
nataliejameson authored and facebook-github-bot committed Feb 16, 2018
1 parent 970a1da commit 2817982
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 39 deletions.
17 changes: 0 additions & 17 deletions src/com/facebook/buck/python/AbstractPythonPackageComponents.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.SetMultimap;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.immutables.value.Value;

@Value.Immutable(builder = false, singleton = true)
Expand All @@ -60,11 +57,6 @@ abstract class AbstractPythonPackageComponents implements RuleKeyAppendable {
@Value.Parameter
public abstract Map<Path, SourcePath> getNativeLibraries();

// Pre-built python libraries (eggs, wheels). Note that source distributions
// will not work!
@Value.Parameter
public abstract Set<SourcePath> getPrebuiltLibraries();

// Directories that pre-built python libraries are extracted to. Note that these
// can refer to the same libraries that are in getPrebuiltLibraries, but these are
// directories instead of archives. The key of this map is where to link the contents
Expand Down Expand Up @@ -109,7 +101,6 @@ public ImmutableCollection<BuildRule> getDeps(SourcePathRuleFinder ruleFinder) {
deps.addAll(ruleFinder.filterBuildRuleInputs(getModules().values()));
deps.addAll(ruleFinder.filterBuildRuleInputs(getResources().values()));
deps.addAll(ruleFinder.filterBuildRuleInputs(getNativeLibraries().values()));
deps.addAll(ruleFinder.filterBuildRuleInputs(getPrebuiltLibraries()));
deps.addAll(ruleFinder.filterBuildRuleInputs(getModuleDirs().values()));

return deps.build();
Expand All @@ -128,7 +119,6 @@ public static class Builder {
private final Map<Path, SourcePath> modules = new HashMap<>();
private final Map<Path, SourcePath> resources = new HashMap<>();
private final Map<Path, SourcePath> nativeLibraries = new HashMap<>();
private final Set<SourcePath> prebuiltLibraries = new LinkedHashSet<>();
private final SetMultimap<Path, SourcePath> moduleDirs = HashMultimap.create();
private Optional<Boolean> zipSafe = Optional.empty();

Expand Down Expand Up @@ -202,11 +192,6 @@ public Builder addNativeLibraries(Map<Path, SourcePath> sources, BuildTarget fro
return add("native library", nativeLibraries, nativeLibrarySources, sources, from);
}

public Builder addPrebuiltLibraries(Set<SourcePath> sources) {
prebuiltLibraries.addAll(sources);
return this;
}

public Builder addModuleDirs(Multimap<Path, SourcePath> moduleDirs) {
this.moduleDirs.putAll(moduleDirs);
return this;
Expand All @@ -216,7 +201,6 @@ public Builder addComponent(PythonPackageComponents other, BuildTarget from) {
addModules(other.getModules(), from);
addResources(other.getResources(), from);
addNativeLibraries(other.getNativeLibraries(), from);
addPrebuiltLibraries(other.getPrebuiltLibraries());
addModuleDirs(other.getModuleDirs());
addZipSafe(other.isZipSafe());
return this;
Expand All @@ -236,7 +220,6 @@ public PythonPackageComponents build() {
ImmutableMap.copyOf(modules),
ImmutableMap.copyOf(resources),
ImmutableMap.copyOf(nativeLibraries),
ImmutableSet.copyOf(prebuiltLibraries),
ImmutableSetMultimap.copyOf(moduleDirs),
zipSafe);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ public PythonPackageComponents getPythonPackageComponents(
ImmutableMap.of(module, output),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.of(false));
}
Expand Down
1 change: 1 addition & 0 deletions src/com/facebook/buck/python/PexStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ protected Optional<String> getStdin(ExecutionContext context) throws Interrupted
"modules", modulesBuilder.build(),
"resources", resourcesBuilder.build(),
"nativeLibraries", nativeLibrariesBuilder.build(),
// prebuiltLibraries key kept for compatibility
"prebuiltLibraries", ImmutableList.<String>of())));
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
4 changes: 0 additions & 4 deletions src/com/facebook/buck/python/PrebuiltPythonLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -76,9 +75,6 @@ public PythonPackageComponents getPythonPackageComponents(
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableMap.of(),
// TODO: We'll be removing 'prebuiltLibraries' in a subsequent diff after
// everything stops using it
ImmutableSet.of(binarySrc),
ImmutableSetMultimap.of(Paths.get(""), Objects.requireNonNull(getSourcePathToOutput())),
Optional.empty());
}
Expand Down
1 change: 0 additions & 1 deletion src/com/facebook/buck/python/PythonBinaryDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ public PythonBinary createBuildRule(
modules.build(),
/* resources */ ImmutableMap.of(),
/* nativeLibraries */ ImmutableMap.of(),
/* prebuiltLibraries */ ImmutableSet.of(),
/* moduleDirs */ ImmutableMultimap.of(),
/* zipSafe */ args.getZipSafe());

Expand Down
2 changes: 0 additions & 2 deletions src/com/facebook/buck/python/PythonLibraryDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import java.nio.file.Path;
import java.util.Map;
Expand Down Expand Up @@ -152,7 +151,6 @@ public <U> Optional<U> createMetadata(
args.getVersionedResources(),
selectedVersions),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
args.getZipSafe());

Expand Down
1 change: 0 additions & 1 deletion src/com/facebook/buck/python/PythonTestDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ public PythonTest createBuildRule(
.build(),
resources,
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
args.getZipSafe());
ImmutableList<BuildRule> deps =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ public void createBuildRulePythonPackageable() throws Exception {
rule.getSourcePathToOutput()),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.of(false));
assertEquals(expectedComponents, actualComponent);
Expand Down
10 changes: 0 additions & 10 deletions test/com/facebook/buck/python/PythonPackageableComponentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.facebook.buck.util.HumanReadableException;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSetMultimap;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -44,15 +43,13 @@ public void testMergeZipSafe() {
ImmutableMap.of(Paths.get("test"), FakeSourcePath.of("sourceA")),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.of(true));
PythonPackageComponents compB =
PythonPackageComponents.of(
ImmutableMap.of(Paths.get("test2"), FakeSourcePath.of("sourceB")),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.of(false));

Expand Down Expand Up @@ -89,15 +86,13 @@ public void testDuplicateSourcesInComponentsThrowsException() {
ImmutableMap.of(dest, FakeSourcePath.of("sourceA")),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.empty());
PythonPackageComponents compB =
PythonPackageComponents.of(
ImmutableMap.of(dest, FakeSourcePath.of("sourceB")),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.empty());
PythonPackageComponents.Builder builder = new PythonPackageComponents.Builder(me);
Expand All @@ -121,15 +116,13 @@ public void testDuplicateIndeticalSourcesInComponentsIsOk() {
ImmutableMap.of(dest, path),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.empty());
PythonPackageComponents compB =
PythonPackageComponents.of(
ImmutableMap.of(dest, path),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.empty());
PythonPackageComponents.Builder builder = new PythonPackageComponents.Builder(me);
Expand Down Expand Up @@ -160,7 +153,6 @@ public void testBuilderBuildsAndUpdates() {
FakeSourcePath.of("nativeA"),
Paths.get("nativeB.so"),
FakeSourcePath.of("nativeB")),
ImmutableSet.of(FakeSourcePath.of("archiveA.whl"), FakeSourcePath.of("archiveB.whl")),
ImmutableSetMultimap.of(
Paths.get(""),
FakeSourcePath.of("extractedA.whl"),
Expand All @@ -173,15 +165,13 @@ public void testBuilderBuildsAndUpdates() {
builder.addResources(ImmutableMap.of(Paths.get("barA"), FakeSourcePath.of("resA")), them);
builder.addNativeLibraries(
ImmutableMap.of(Paths.get("nativeA.so"), FakeSourcePath.of("nativeA")), them);
builder.addPrebuiltLibraries(ImmutableSet.of(FakeSourcePath.of("archiveA.whl")));
builder.addModuleDirs(
ImmutableSetMultimap.of(Paths.get(""), FakeSourcePath.of("extractedA.whl")));

builder.addModule(Paths.get("fooB"), FakeSourcePath.of("sourceB"), them);
builder.addResources(ImmutableMap.of(Paths.get("barB"), FakeSourcePath.of("resB")), them);
builder.addNativeLibraries(
ImmutableMap.of(Paths.get("nativeB.so"), FakeSourcePath.of("nativeB")), them);
builder.addPrebuiltLibraries(ImmutableSet.of(FakeSourcePath.of("archiveB.whl")));
builder.addModuleDirs(
ImmutableSetMultimap.of(Paths.get(""), FakeSourcePath.of("extractedB.whl")));

Expand Down
2 changes: 0 additions & 2 deletions test/com/facebook/buck/python/PythonPackagedBinaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -98,7 +97,6 @@ private RuleKey getRuleKeyForModuleLayout(
Paths.get(mod2), PathSourcePath.of(projectFilesystem, src2)),
ImmutableMap.of(),
ImmutableMap.of(),
ImmutableSet.of(),
ImmutableMultimap.of(),
Optional.empty()),
ImmutableSortedSet.of(),
Expand Down

0 comments on commit 2817982

Please sign in to comment.