Slight refactoring to PyCommon
This makes it easier for a Google-internal ruleset to add a PyInfo provider.
RELNOTES: None
PiperOrigin-RevId: 302955232
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 69cf9ff..3c8968f 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
@@ -895,10 +895,13 @@
return ruleContext.getRelatedArtifact(executable.getRootRelativePath(), "");
}
- public void addCommonTransitiveInfoProviders(
- RuleConfiguredTargetBuilder builder, NestedSet<Artifact> filesToBuild) {
-
- // Add PyInfo and/or legacy "py" struct provider.
+ /**
+ * Adds a PyInfo or legacy "py" provider.
+ *
+ * <p>This is a public method because some rules just want a PyInfo provider without the other
+ * things py_library needs.
+ */
+ public void addPyInfoProvider(RuleConfiguredTargetBuilder builder) {
boolean createLegacyPyProvider =
!ruleContext.getFragment(PythonConfiguration.class).disallowLegacyPyProvider();
PyProviderUtils.builder(createLegacyPyProvider)
@@ -908,6 +911,11 @@
.setHasPy2OnlySources(hasPy2OnlySources)
.setHasPy3OnlySources(hasPy3OnlySources)
.buildAndAddToTarget(builder);
+ }
+
+ public void addCommonTransitiveInfoProviders(
+ RuleConfiguredTargetBuilder builder, NestedSet<Artifact> filesToBuild) {
+ addPyInfoProvider(builder);
// Add PyRuntimeInfo if this is an executable rule.
if (runtimeFromToolchain != null) {