Add PyInfo migration flag to --all_incompatible_changes

This renames --experimental_disallow_legacy_py_provider to --incompatible_disallow_legacy_py_provider and makes it available under --all_incompatible_changes. Migrate legacy "py" struct providers to PyInfo instead.

See #7298 for more information.

Work toward #7298 and #7010.

RELNOTES[INC]: Python rules will soon reject the legacy "py" struct provider (preview by enabling --incompatible_disallow_legacy_py_provider). Upgrade rules to use PyInfo instead. See [#7298](https://github.com/bazelbuild/bazel/issues/7298).

PiperOrigin-RevId: 231885505
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java
index 6a1e105..6e73aa5 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfigurationLoader.java
@@ -40,7 +40,7 @@
         pythonOptions.buildTransitiveRunfilesTrees,
         /*oldPyVersionApiAllowed=*/ !pythonOptions.experimentalRemoveOldPythonVersionApi,
         /*useNewPyVersionSemantics=*/ pythonOptions.experimentalAllowPythonVersionTransitions,
-        /*disallowLegacyPyProvider=*/ pythonOptions.experimentalDisallowLegacyPyProvider);
+        /*disallowLegacyPyProvider=*/ pythonOptions.incompatibleDisallowLegacyPyProvider);
   }
 
   @Override
diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
index 4e0b5b9..1c8a9e4 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonOptions.java
@@ -169,18 +169,20 @@
   private static final OptionDefinition HOST_FORCE_PYTHON_DEFINITION =
       OptionsParser.getOptionDefinitionByName(PythonOptions.class, "host_force_python");
 
-  // TODO(#7010): Change the option name to "incompatible_..." and enable the appropriate metadata
-  // tags.
   @Option(
-      name = "experimental_disallow_legacy_py_provider",
+      name = "incompatible_disallow_legacy_py_provider",
       defaultValue = "false",
       documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS,
       effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
+      metadataTags = {
+        OptionMetadataTag.INCOMPATIBLE_CHANGE,
+        OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
+      },
       help =
           "If set to true, native Python rules will neither produce nor consume the legacy \"py\" "
               + "provider. Use PyInfo instead. Under this flag, passing the legacy provider to a "
               + "Python target will be an error.")
-  public boolean experimentalDisallowLegacyPyProvider;
+  public boolean incompatibleDisallowLegacyPyProvider;
 
   @Override
   public Map<OptionDefinition, SelectRestriction> getSelectRestrictions() {
@@ -284,7 +286,7 @@
         (hostForcePython != null) ? hostForcePython : PythonVersion.DEFAULT_TARGET_VALUE;
     hostPythonOptions.setPythonVersion(hostVersion);
     hostPythonOptions.buildPythonZip = buildPythonZip;
-    hostPythonOptions.experimentalDisallowLegacyPyProvider = experimentalDisallowLegacyPyProvider;
+    hostPythonOptions.incompatibleDisallowLegacyPyProvider = incompatibleDisallowLegacyPyProvider;
     return hostPythonOptions;
   }
 
diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java
index 527b67b..ac331bc 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyBaseConfiguredTargetTestBase.java
@@ -142,7 +142,7 @@
 
   @Test
   public void producesBothModernAndLegacyProviders_WithoutIncompatibleFlag() throws Exception {
-    useConfiguration("--experimental_disallow_legacy_py_provider=false");
+    useConfiguration("--incompatible_disallow_legacy_py_provider=false");
     scratch.file(
         "pkg/BUILD", //
         ruleName + "(",
@@ -155,7 +155,7 @@
 
   @Test
   public void producesOnlyModernProvider_WithIncompatibleFlag() throws Exception {
-    useConfiguration("--experimental_disallow_legacy_py_provider=true");
+    useConfiguration("--incompatible_disallow_legacy_py_provider=true");
     scratch.file(
         "pkg/BUILD", //
         ruleName + "(",
@@ -168,7 +168,7 @@
 
   @Test
   public void consumesLegacyProvider_WithoutIncompatibleFlag() throws Exception {
-    useConfiguration("--experimental_disallow_legacy_py_provider=false");
+    useConfiguration("--incompatible_disallow_legacy_py_provider=false");
     scratch.file(
         "pkg/rules.bzl",
         "def _myrule_impl(ctx):",
@@ -194,7 +194,7 @@
 
   @Test
   public void rejectsLegacyProvider_WithIncompatibleFlag() throws Exception {
-    useConfiguration("--experimental_disallow_legacy_py_provider=true");
+    useConfiguration("--incompatible_disallow_legacy_py_provider=true");
     scratch.file(
         "pkg/rules.bzl",
         "def _myrule_impl(ctx):",
diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java
index 60add6f..204383a 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/python/PythonConfigurationTest.java
@@ -165,12 +165,12 @@
             "--experimental_allow_python_version_transitions=true",
             "--experimental_remove_old_python_version_api=true",
             "--build_python_zip=true",
-            "--experimental_disallow_legacy_py_provider=true");
+            "--incompatible_disallow_legacy_py_provider=true");
     PythonOptions hostOpts = (PythonOptions) opts.getHost();
     assertThat(hostOpts.experimentalAllowPythonVersionTransitions).isTrue();
     assertThat(hostOpts.experimentalRemoveOldPythonVersionApi).isTrue();
     assertThat(hostOpts.buildPythonZip).isEqualTo(TriState.YES);
-    assertThat(hostOpts.experimentalDisallowLegacyPyProvider).isTrue();
+    assertThat(hostOpts.incompatibleDisallowLegacyPyProvider).isTrue();
   }
 
   @Test