From 29759d0b9fe8fab3b6074343857f570e13e8f874 Mon Sep 17 00:00:00 2001 From: brandjon Date: Thu, 31 Jan 2019 17:20:42 -0800 Subject: [PATCH] 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 --- .../lib/rules/python/PythonConfigurationLoader.java | 2 +- .../build/lib/rules/python/PythonOptions.java | 12 +++++++----- .../rules/python/PyBaseConfiguredTargetTestBase.java | 8 ++++---- .../lib/rules/python/PythonConfigurationTest.java | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) 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 6a1e1059372f0e..6e73aa5bc9c15f 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 @@ public PythonConfiguration create(BuildOptions buildOptions) 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 4e0b5b934eb1c6..1c8a9e40c39593 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 @@ public String getTypeDescription() { 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 getSelectRestrictions() { @@ -284,7 +286,7 @@ public FragmentOptions getHost() { (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 527b67b6a78d51..ac331bc0373e23 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 @@ public void srcsPackageNameCannotHaveHyphen() throws Exception { @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 @@ public void producesBothModernAndLegacyProviders_WithoutIncompatibleFlag() throw @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 @@ public void producesOnlyModernProvider_WithIncompatibleFlag() throws Exception { @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 @@ public void consumesLegacyProvider_WithoutIncompatibleFlag() throws Exception { @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 60add6fe63cdf7..204383a3ace5a2 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 @@ public void getHost_CopiesMostValues() throws Exception { "--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