Skip to content

Commit

Permalink
Add PyInfo migration flag to --all_incompatible_changes
Browse files Browse the repository at this point in the history
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](#7298).

PiperOrigin-RevId: 231885505
  • Loading branch information
brandjon authored and Copybara-Service committed Feb 1, 2019
1 parent 4a55d41 commit 29759d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public PythonConfiguration create(BuildOptions buildOptions)
pythonOptions.buildTransitiveRunfilesTrees,
/*oldPyVersionApiAllowed=*/ !pythonOptions.experimentalRemoveOldPythonVersionApi,
/*useNewPyVersionSemantics=*/ pythonOptions.experimentalAllowPythonVersionTransitions,
/*disallowLegacyPyProvider=*/ pythonOptions.experimentalDisallowLegacyPyProvider);
/*disallowLegacyPyProvider=*/ pythonOptions.incompatibleDisallowLegacyPyProvider);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<OptionDefinition, SelectRestriction> getSelectRestrictions() {
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "(",
Expand All @@ -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 + "(",
Expand All @@ -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):",
Expand All @@ -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):",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29759d0

Please sign in to comment.