diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuleClasses.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuleClasses.java index e391f530bcf351..6a6ec17629727c 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuleClasses.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/python/BazelPyRuleClasses.java @@ -106,10 +106,10 @@ executable Python rule (py_binary or py_test). and should be avoided.

Under the old semantics - (--experimental_allow_python_version_transitions=false), it is an error to + (--incompatible_allow_python_version_transitions=false), it is an error to build any Python target for a version disallowed by its srcs_version attribute. Under the new semantics - (--experimental_allow_python_version_transitions=true), this check is + (--incompatible_allow_python_version_transitions=true), this check is deferred to the executable rule: You can build a srcs_version = "PY3" py_library target for Python 2, but you cannot actually depend on it via deps from a Python 3 py_binary. @@ -170,7 +170,7 @@ public RuleClass build(RuleClass.Builder builder, final RuleDefinitionEnvironmen .add(attr("main", LABEL).allowedFileTypes(PYTHON_SOURCE)) /* A deprecated alias for python_version; use that instead. This attribute is - disabled under --experimental_remove_old_python_version_api. For migration + disabled under --incompatible_remove_old_python_version_api. For migration purposes, if python_version is given then the value of default_python_version is ignored. */ @@ -186,13 +186,13 @@ Whether to build this target (and its transitive deps) for Python 2 3. Valid values are "PY2" (the default) and "PY3".

Under the old semantics - (--experimental_allow_python_version_transitions=false), the Python version + (--incompatible_allow_python_version_transitions=false), the Python version generally cannot be changed once set. This means that the --python_version flag overrides this attribute, and other Python binaries in the data deps of this target are forced to use the same version as this target.

Under the new semantics - (--experimental_allow_python_version_transitions=true), the Python version + (--incompatible_allow_python_version_transitions=true), the Python version is always set (possibly by default) to whatever version is specified by this attribute, regardless of the version specified on the command line or by other targets that depend on this one. 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 6e12259516c5e9..3bef233b3e824c 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 @@ -361,7 +361,7 @@ private static Map makeAndInitConvertedFiles( /** * Under the old version semantics ({@code - * --experimental_allow_python_version_transitions=false}), checks that the {@code srcs_version} + * --incompatible_allow_python_version_transitions=false}), checks that the {@code srcs_version} * attribute is compatible with the Python version as determined by the configuration. * *

A failure is reported as a rule error. @@ -438,7 +438,7 @@ private void validateOldVersionAttrNotUsedIfDisabled() { ruleContext.attributeError( DEFAULT_PYTHON_VERSION_ATTRIBUTE, "the 'default_python_version' attribute is disabled by the " - + "'--experimental_remove_old_python_version_api' flag"); + + "'--incompatible_remove_old_python_version_api' flag"); } } @@ -464,7 +464,7 @@ private void validateLegacyProviderNotUsedIfDisabled() { } /** - * Under the new version semantics ({@code --experimental_allow_python_version_transitions=true}), + * Under the new version semantics ({@code --incompatible_allow_python_version_transitions=true}), * if the Python version (as determined by the configuration) is inconsistent with {@link * #hasPy2OnlySources} or {@link #hasPy3OnlySources}, emits a {@link FailAction} that "generates" * the executable. diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java index 86373c5841bb53..4622ba272030c0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonConfiguration.java @@ -98,10 +98,10 @@ public String getOutputDirectoryName() { @Override public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOptions) { PythonOptions opts = buildOptions.get(PythonOptions.class); - if (opts.forcePython != null && opts.experimentalRemoveOldPythonVersionApi) { + if (opts.forcePython != null && opts.incompatibleRemoveOldPythonVersionApi) { reporter.handle( Event.error( - "`--force_python` is disabled by `--experimental_remove_old_python_version_api`")); + "`--force_python` is disabled by `--incompatible_remove_old_python_version_api`")); } } 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 6e73aa5bc9c15f..08095e71e303d4 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 @@ -38,8 +38,8 @@ public PythonConfiguration create(BuildOptions buildOptions) pythonVersion, pythonOptions.buildPythonZip, pythonOptions.buildTransitiveRunfilesTrees, - /*oldPyVersionApiAllowed=*/ !pythonOptions.experimentalRemoveOldPythonVersionApi, - /*useNewPyVersionSemantics=*/ pythonOptions.experimentalAllowPythonVersionTransitions, + /*oldPyVersionApiAllowed=*/ !pythonOptions.incompatibleRemoveOldPythonVersionApi, + /*useNewPyVersionSemantics=*/ pythonOptions.incompatibleAllowPythonVersionTransitions, /*disallowLegacyPyProvider=*/ pythonOptions.incompatibleDisallowLegacyPyProvider); } 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 09814484f688ed..e598c9545fb7e5 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 @@ -70,28 +70,34 @@ public String getTypeDescription() { public TriState buildPythonZip; @Option( - name = "experimental_remove_old_python_version_api", + name = "incompatible_remove_old_python_version_api", defaultValue = "false", documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, - metadataTags = {OptionMetadataTag.EXPERIMENTAL}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, help = "If true, disables use of the `--force_python` flag and the `default_python_version` " + "attribute for `py_binary` and `py_test`. Use the `--python_version` flag and " + "`python_version` attribute instead, which have exactly the same meaning. This " + "flag also disables `select()`-ing over `--host_force_python`.") - public boolean experimentalRemoveOldPythonVersionApi; + public boolean incompatibleRemoveOldPythonVersionApi; @Option( - name = "experimental_allow_python_version_transitions", + name = "incompatible_allow_python_version_transitions", defaultValue = "false", documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS, effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS}, - metadataTags = {OptionMetadataTag.EXPERIMENTAL}, + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, help = "If true, Python rules use the new PY2/PY3 version semantics. For more information, see " + "the documentation for `py_binary`'s `python_version` attribute.") - public boolean experimentalAllowPythonVersionTransitions; + public boolean incompatibleAllowPythonVersionTransitions; /** * This field should be either null (unset), {@code PY2}, or {@code PY3}. Other {@code @@ -112,7 +118,7 @@ public String getTypeDescription() { }, help = "The Python major version mode, either `PY2` or `PY3`. Note that under the new version " - + "semantics (`--experimental_allow_python_version_transitions`) this is overridden " + + "semantics (`--incompatible_allow_python_version_transitions`) this is overridden " + "by `py_binary` and `py_test` targets (even if they don't explicitly specify a " + "version) so there is usually not much reason to supply this flag.") public PythonVersion pythonVersion; @@ -124,7 +130,7 @@ public String getTypeDescription() { * This field should be either null (unset), {@code PY2}, or {@code PY3}. Other {@code * PythonVersion} values do not represent distinct Python versions and are not allowed. * - *

This flag is not accessible to the user when {@link #experimentalRemoveOldPythonVersionApi} + *

This flag is not accessible to the user when {@link #incompatibleRemoveOldPythonVersionApi} * is true. * *

Native rule logic should call {@link #getPythonVersion} / {@link #setPythonVersion} instead @@ -139,7 +145,7 @@ public String getTypeDescription() { effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS}, help = "Deprecated alias for `--python_version`. Disabled by " - + "`--experimental_remove_old_python_version_api`.") + + "`--incompatible_remove_old_python_version_api`.") public PythonVersion forcePython; private static final OptionDefinition FORCE_PYTHON_DEFINITION = @@ -193,7 +199,7 @@ public Map getSelectRestrictions() { new SelectRestriction( /*visibleWithinToolsPackage=*/ true, "Use @bazel_tools//python/tools:python_version instead.")); - if (experimentalRemoveOldPythonVersionApi) { + if (incompatibleRemoveOldPythonVersionApi) { restrictions.put( FORCE_PYTHON_DEFINITION, new SelectRestriction( @@ -227,14 +233,14 @@ public PythonVersion getPythonVersion() { /** * Returns whether a Python version transition to {@code version} is allowed and not a no-op. * - *

Under the new semantics ({@link #experimentalAllowPythonVersionTransitions} is true), + *

Under the new semantics ({@link #incompatibleAllowPythonVersionTransitions} is true), * version transitions are always allowed, so this essentially returns whether the new version is * different from the existing one. However, to improve compatibility for unmigrated {@code * select()}s that depend on {@code "force_python"}, if the old API is still enabled then * transitioning is still done whenever {@link #forcePython} is not in agreement with the * requested version, even if {@link #getPythonVersion}'s value would be unaffected. * - *

Under the old semantics ({@link #experimentalAllowPythonVersionTransitions} is false), + *

Under the old semantics ({@link #incompatibleAllowPythonVersionTransitions} is false), * version transitions are not allowed once the version has already been set ({@link #forcePython} * or {@link #pythonVersion} is non-null). Due to a historical bug, it is also not allowed to * transition the version to the hard-coded default value. Under these constraints, there is only @@ -244,10 +250,10 @@ public PythonVersion getPythonVersion() { */ public boolean canTransitionPythonVersion(PythonVersion version) { Preconditions.checkArgument(version.isTargetValue()); - if (experimentalAllowPythonVersionTransitions) { + if (incompatibleAllowPythonVersionTransitions) { boolean currentVersionNeedsUpdating = !version.equals(getPythonVersion()); boolean forcePythonNeedsUpdating = - !experimentalRemoveOldPythonVersionApi && !version.equals(forcePython); + !incompatibleRemoveOldPythonVersionApi && !version.equals(forcePython); return currentVersionNeedsUpdating || forcePythonNeedsUpdating; } else { boolean currentlyUnset = forcePython == null && pythonVersion == null; @@ -264,7 +270,7 @@ public boolean canTransitionPythonVersion(PythonVersion version) { * constructed instance. The mutation does not depend on whether or not {@link * #canTransitionPythonVersion} would return true. * - *

If the old semantics are in effect ({@link #experimentalAllowPythonVersionTransitions} is + *

If the old semantics are in effect ({@link #incompatibleAllowPythonVersionTransitions} is * false), after this method is called {@link #canTransitionPythonVersion} will return false. * *

To help avoid breaking old-API {@code select()} expressions that check the value of {@code @@ -284,9 +290,9 @@ public void setPythonVersion(PythonVersion version) { @Override public FragmentOptions getHost() { PythonOptions hostPythonOptions = (PythonOptions) getDefault(); - hostPythonOptions.experimentalRemoveOldPythonVersionApi = experimentalRemoveOldPythonVersionApi; - hostPythonOptions.experimentalAllowPythonVersionTransitions = - experimentalAllowPythonVersionTransitions; + hostPythonOptions.incompatibleRemoveOldPythonVersionApi = incompatibleRemoveOldPythonVersionApi; + hostPythonOptions.incompatibleAllowPythonVersionTransitions = + incompatibleAllowPythonVersionTransitions; PythonVersion hostVersion = (hostForcePython != null) ? hostForcePython : PythonVersion.DEFAULT_TARGET_VALUE; hostPythonOptions.setPythonVersion(hostVersion); 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 ac331bc0373e23..12b95ea973b54e 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 @@ -76,7 +76,7 @@ public void srcsVersionClashesWithForcePythonFlagUnderOldSemantics() throws Exce // PyExecutableConfiguredTargetTestBase. Note that under the new semantics py_binary and // py_library ignore the version flag, so those tests use the attribute to set the version // instead. - useConfiguration("--experimental_allow_python_version_transitions=false", "--force_python=PY3"); + useConfiguration("--incompatible_allow_python_version_transitions=false", "--force_python=PY3"); checkError("pkg", "foo", // error: "'//pkg:foo' can only be used with Python 2", @@ -106,7 +106,7 @@ public void versionIs3IfForcedByFlagUnderOldSemantics() throws Exception { // would only make sense for py_library; see PyLibraryConfiguredTargetTest for the analogous // test. ensureDefaultIsPY2(); - useConfiguration("--experimental_allow_python_version_transitions=false", "--force_python=PY3"); + useConfiguration("--incompatible_allow_python_version_transitions=false", "--force_python=PY3"); scratch.file( "pkg/BUILD", // ruleName + "(", diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java index 31309aa72c6b13..d3d164a2473342 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyBinaryConfiguredTargetTest.java @@ -51,7 +51,7 @@ private void declareBinDependingOnLibWithVersions(String binVersion, String libS @Test public void python2WithPy3SrcsVersionDependency_OldSemantics() throws Exception { reporter.removeHandler(failFastHandler); // expect errors - useConfiguration("--experimental_allow_python_version_transitions=false"); + useConfiguration("--incompatible_allow_python_version_transitions=false"); declareBinDependingOnLibWithVersions("PY2", "PY3"); assertThat(view.hasErrors(getConfiguredTarget("//pkg:bin"))).isTrue(); assertContainsEvent("//pkg:lib: Rule '//pkg:lib' can only be used with Python 3"); @@ -59,7 +59,7 @@ public void python2WithPy3SrcsVersionDependency_OldSemantics() throws Exception @Test public void python2WithPy3SrcsVersionDependency_NewSemantics() throws Exception { - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); declareBinDependingOnLibWithVersions("PY2", "PY3"); assertThat(getPyExecutableDeferredError("//pkg:bin")) .contains("being built for Python 2 but (transitively) includes Python 3-only sources"); @@ -68,7 +68,7 @@ public void python2WithPy3SrcsVersionDependency_NewSemantics() throws Exception @Test public void python2WithPy3OnlySrcsVersionDependency_OldSemantics() throws Exception { reporter.removeHandler(failFastHandler); // expect errors - useConfiguration("--experimental_allow_python_version_transitions=false"); + useConfiguration("--incompatible_allow_python_version_transitions=false"); declareBinDependingOnLibWithVersions("PY2", "PY3ONLY"); assertThat(view.hasErrors(getConfiguredTarget("//pkg:bin"))).isTrue(); assertContainsEvent("//pkg:lib: Rule '//pkg:lib' can only be used with Python 3"); @@ -76,7 +76,7 @@ public void python2WithPy3OnlySrcsVersionDependency_OldSemantics() throws Except @Test public void python2WithPy3OnlySrcsVersionDependency_NewSemantics() throws Exception { - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); declareBinDependingOnLibWithVersions("PY2", "PY3ONLY"); assertThat(getPyExecutableDeferredError("//pkg:bin")) .contains("being built for Python 2 but (transitively) includes Python 3-only sources"); @@ -85,7 +85,7 @@ public void python2WithPy3OnlySrcsVersionDependency_NewSemantics() throws Except @Test public void python3WithPy2OnlySrcsVersionDependency_OldSemantics() throws Exception { reporter.removeHandler(failFastHandler); // expect errors - useConfiguration("--experimental_allow_python_version_transitions=false"); + useConfiguration("--incompatible_allow_python_version_transitions=false"); declareBinDependingOnLibWithVersions("PY3", "PY2ONLY"); assertThat(view.hasErrors(getConfiguredTarget("//pkg:bin"))).isTrue(); assertContainsEvent("//pkg:lib: Rule '//pkg:lib' can only be used with Python 2"); @@ -93,7 +93,7 @@ public void python3WithPy2OnlySrcsVersionDependency_OldSemantics() throws Except @Test public void python3WithPy2OnlySrcsVersionDependency_NewSemantics() throws Exception { - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); declareBinDependingOnLibWithVersions("PY3", "PY2ONLY"); assertThat(getPyExecutableDeferredError("//pkg:bin")) .contains("being built for Python 3 but (transitively) includes Python 2-only sources"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyExecutableConfiguredTargetTestBase.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyExecutableConfiguredTargetTestBase.java index 338a6fc13a612d..acfd1fa337ef75 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PyExecutableConfiguredTargetTestBase.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyExecutableConfiguredTargetTestBase.java @@ -131,7 +131,7 @@ private String ruleDeclWithPyVersionAttr(String name, String version) { @Test public void oldVersionAttr_UnknownValue() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=false"); + useConfiguration("--incompatible_remove_old_python_version_api=false"); checkError( "pkg", "foo", @@ -156,7 +156,7 @@ public void newVersionAttr_UnknownValue() throws Exception { @Test public void oldVersionAttr_BadValue() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=false"); + useConfiguration("--incompatible_remove_old_python_version_api=false"); checkError( "pkg", "foo", @@ -181,7 +181,7 @@ public void newVersionAttr_BadValue() throws Exception { @Test public void oldVersionAttr_GoodValue() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=false"); + useConfiguration("--incompatible_remove_old_python_version_api=false"); scratch.file("pkg/BUILD", ruleDeclWithDefaultPyVersionAttr("foo", "PY2")); getOkPyTarget("//pkg:foo"); assertNoEvents(); @@ -196,13 +196,13 @@ public void newVersionAttr_GoodValue() throws Exception { @Test public void cannotUseOldVersionAttrWithRemovalFlag() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=true"); + useConfiguration("--incompatible_remove_old_python_version_api=true"); checkError( "pkg", "foo", // error: "the 'default_python_version' attribute is disabled by the " - + "'--experimental_remove_old_python_version_api' flag", + + "'--incompatible_remove_old_python_version_api' flag", // build file: ruleDeclWithDefaultPyVersionAttr("foo", "PY2")); } @@ -216,7 +216,7 @@ public void cannotUseOldVersionAttrWithRemovalFlag() throws Exception { */ @Test public void canCopyTargetWhenOldAttrDisallowed() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=true"); + useConfiguration("--incompatible_remove_old_python_version_api=true"); scratch.file( "pkg/rules.bzl", "def copy_target(rulefunc, src, dest):", @@ -253,7 +253,7 @@ public void newVersionAttrTakesPrecedenceOverOld() throws Exception { " python_version = 'PY3',", ")"); assertPythonVersionIs_UnderNewConfig( - "//pkg:foo", PythonVersion.PY3, "--experimental_remove_old_python_version_api=false"); + "//pkg:foo", PythonVersion.PY3, "--incompatible_remove_old_python_version_api=false"); } @Test @@ -264,8 +264,8 @@ public void versionAttrWorksUnderOldAndNewSemantics_WhenNotDefaultValue() throws assertPythonVersionIs_UnderNewConfigs( "//pkg:foo", PythonVersion.PY3, - new String[] {"--experimental_allow_python_version_transitions=false"}, - new String[] {"--experimental_allow_python_version_transitions=true"}); + new String[] {"--incompatible_allow_python_version_transitions=false"}, + new String[] {"--incompatible_allow_python_version_transitions=true"}); } @Test @@ -276,8 +276,8 @@ public void versionAttrWorksUnderOldAndNewSemantics_WhenSameAsDefaultValue() thr assertPythonVersionIs_UnderNewConfigs( "//pkg:foo", PythonVersion.PY2, - new String[] {"--experimental_allow_python_version_transitions=false"}, - new String[] {"--experimental_allow_python_version_transitions=true"}); + new String[] {"--incompatible_allow_python_version_transitions=false"}, + new String[] {"--incompatible_allow_python_version_transitions=true"}); } @Test @@ -287,7 +287,7 @@ public void flagTakesPrecedenceUnderOldSemantics_NonDefaultValue() throws Except assertPythonVersionIs_UnderNewConfig( "//pkg:foo", PythonVersion.PY3, - "--experimental_allow_python_version_transitions=false", + "--incompatible_allow_python_version_transitions=false", "--force_python=PY3"); } @@ -298,7 +298,7 @@ public void flagTakesPrecedenceUnderOldSemantics_DefaultValue() throws Exception assertPythonVersionIs_UnderNewConfig( "//pkg:foo", PythonVersion.PY2, - "--experimental_allow_python_version_transitions=false", + "--incompatible_allow_python_version_transitions=false", "--force_python=PY2"); } @@ -312,12 +312,12 @@ public void versionAttrTakesPrecedenceUnderNewSemantics_NonDefaultValue() throws "//pkg:foo", PythonVersion.PY3, new String[] { - "--experimental_allow_python_version_transitions=true", - "--experimental_remove_old_python_version_api=false", + "--incompatible_allow_python_version_transitions=true", + "--incompatible_remove_old_python_version_api=false", "--force_python=PY2" }, new String[] { - "--experimental_allow_python_version_transitions=true", "--python_version=PY2" + "--incompatible_allow_python_version_transitions=true", "--python_version=PY2" }); } @@ -331,12 +331,12 @@ public void versionAttrTakesPrecedenceUnderNewSemantics_DefaultValue() throws Ex "//pkg:foo", PythonVersion.PY2, new String[] { - "--experimental_allow_python_version_transitions=true", - "--experimental_remove_old_python_version_api=false", + "--incompatible_allow_python_version_transitions=true", + "--incompatible_remove_old_python_version_api=false", "--force_python=PY3" }, new String[] { - "--experimental_allow_python_version_transitions=true", "--python_version=PY3" + "--incompatible_allow_python_version_transitions=true", "--python_version=PY3" }); } @@ -350,13 +350,13 @@ public void canBuildWithDifferentVersionAttrs_UnderOldAndNewSemantics() throws E assertPythonVersionIs_UnderNewConfigs( "//pkg:foo_v2", PythonVersion.PY2, - new String[] {"--experimental_allow_python_version_transitions=false"}, - new String[] {"--experimental_allow_python_version_transitions=true"}); + new String[] {"--incompatible_allow_python_version_transitions=false"}, + new String[] {"--incompatible_allow_python_version_transitions=true"}); assertPythonVersionIs_UnderNewConfigs( "//pkg:foo_v3", PythonVersion.PY3, - new String[] {"--experimental_allow_python_version_transitions=false"}, - new String[] {"--experimental_allow_python_version_transitions=true"}); + new String[] {"--incompatible_allow_python_version_transitions=false"}, + new String[] {"--incompatible_allow_python_version_transitions=true"}); } @Test @@ -387,7 +387,7 @@ public void canBuildWithDifferentVersionAttrs_UnderOldSemantics_FlagSetToNonDefa @Test public void incompatibleSrcsVersion_OldSemantics() throws Exception { - useConfiguration("--experimental_allow_python_version_transitions=false"); + useConfiguration("--incompatible_allow_python_version_transitions=false"); checkError( "pkg", "foo", @@ -404,7 +404,7 @@ public void incompatibleSrcsVersion_OldSemantics() throws Exception { @Test public void incompatibleSrcsVersion_NewSemantics() throws Exception { reporter.removeHandler(failFastHandler); // We assert below that we don't fail at analysis. - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); scratch.file( "pkg/BUILD", // build file: @@ -425,7 +425,7 @@ public void incompatibleSrcsVersion_DueToVersionAttrDefault() throws Exception { ensureDefaultIsPY2(); // When changed to PY3, flip srcs_version below to be PY2ONLY. // This test doesn't care whether we use old and new semantics, but it affects how we assert. - useConfiguration("--experimental_allow_python_version_transitions=false"); + useConfiguration("--incompatible_allow_python_version_transitions=false"); // Fails because default_python_version is PY2 by default, so the config is set to PY2 // regardless of srcs_version. diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PyLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PyLibraryConfiguredTargetTest.java index 1c39537c0c05cd..737a74c3c65ad0 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PyLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PyLibraryConfiguredTargetTest.java @@ -37,7 +37,7 @@ public PyLibraryConfiguredTargetTest() { public void canBuildWithIncompatibleSrcsVersionUnderNewSemantics() throws Exception { // See PyBaseConfiguredTargetTestBase for the analogous test under the old semantics, which // applies not just to py_library but also to py_binary and py_test. - useConfiguration("--experimental_allow_python_version_transitions=true", "--force_python=PY3"); + useConfiguration("--incompatible_allow_python_version_transitions=true", "--force_python=PY3"); scratch.file( "pkg/BUILD", "py_library(", @@ -54,7 +54,7 @@ public void versionIs3IfSetByFlagUnderNewSemantics() throws Exception { // See PyBaseConfiguredTargetTestBase for the analogous test under the old semantics, which // applies not just to py_library but also to py_binary and py_test. ensureDefaultIsPY2(); - useConfiguration("--experimental_allow_python_version_transitions=true", "--force_python=PY3"); + useConfiguration("--incompatible_allow_python_version_transitions=true", "--force_python=PY3"); scratch.file( "pkg/BUILD", "py_library(", 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 204383a3ace5a2..f453abecef8afb 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 @@ -53,10 +53,10 @@ public void invalidTargetPythonValue_UnknownValue() { @Test public void oldVersionFlagGatedByExperimentalFlag() throws Exception { - create("--experimental_remove_old_python_version_api=false", "--force_python=PY2"); + create("--incompatible_remove_old_python_version_api=false", "--force_python=PY2"); checkError( - "`--force_python` is disabled by `--experimental_remove_old_python_version_api`", - "--experimental_remove_old_python_version_api=true", + "`--force_python` is disabled by `--incompatible_remove_old_python_version_api`", + "--incompatible_remove_old_python_version_api=true", "--force_python=PY2"); } @@ -87,7 +87,7 @@ public void getPythonVersion_FallBackOnOldFlag() throws Exception { public void canTransitionPythonVersion_OldSemantics_Yes() throws Exception { ensureDefaultIsPY2(); PythonOptions opts = - parsePythonOptions("--experimental_allow_python_version_transitions=false"); + parsePythonOptions("--incompatible_allow_python_version_transitions=false"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isTrue(); } @@ -96,12 +96,12 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseAlreadySet() throws ensureDefaultIsPY2(); PythonOptions optsWithOldFlag = parsePythonOptions( - "--experimental_allow_python_version_transitions=false", - "--experimental_remove_old_python_version_api=false", + "--incompatible_allow_python_version_transitions=false", + "--incompatible_remove_old_python_version_api=false", "--force_python=PY2"); PythonOptions optsWithNewFlag = parsePythonOptions( - "--experimental_allow_python_version_transitions=false", "--python_version=PY2"); + "--incompatible_allow_python_version_transitions=false", "--python_version=PY2"); assertThat(optsWithOldFlag.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); assertThat(optsWithNewFlag.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); } @@ -111,7 +111,7 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseNewValueSameAsDefau throws Exception { ensureDefaultIsPY2(); PythonOptions opts = - parsePythonOptions("--experimental_allow_python_version_transitions=false"); + parsePythonOptions("--incompatible_allow_python_version_transitions=false"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY2)).isFalse(); } @@ -119,7 +119,7 @@ public void canTransitionPythonVersion_OldSemantics_NoBecauseNewValueSameAsDefau public void canTransitionPythonVersion_NewSemantics_Yes() throws Exception { PythonOptions opts = parsePythonOptions( - "--experimental_allow_python_version_transitions=true", "--python_version=PY3"); + "--incompatible_allow_python_version_transitions=true", "--python_version=PY3"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY2)).isTrue(); } @@ -127,10 +127,10 @@ public void canTransitionPythonVersion_NewSemantics_Yes() throws Exception { public void canTransitionPythonVersion_NewSemantics_NoBecauseSameAsCurrent() throws Exception { PythonOptions opts = parsePythonOptions( - "--experimental_allow_python_version_transitions=true", + "--incompatible_allow_python_version_transitions=true", // Set --force_python too, or else we fall into the "make --force_python consistent" // case. - "--experimental_remove_old_python_version_api=false", + "--incompatible_remove_old_python_version_api=false", "--force_python=PY3", "--python_version=PY3"); assertThat(opts.canTransitionPythonVersion(PythonVersion.PY3)).isFalse(); @@ -140,8 +140,8 @@ public void canTransitionPythonVersion_NewSemantics_NoBecauseSameAsCurrent() thr public void canTransitionPythonVersion_NewApi_YesBecauseForcePythonDisagrees() throws Exception { PythonOptions opts = parsePythonOptions( - "--experimental_allow_python_version_transitions=true", - "--experimental_remove_old_python_version_api=false", + "--incompatible_allow_python_version_transitions=true", + "--incompatible_remove_old_python_version_api=false", // Test that even though getPythonVersion() would not be affected by a transition (it is // PY3 before and after), the transition is still considered necessary because // --force_python's value needs to be brought in sync. @@ -162,13 +162,13 @@ public void setPythonVersion() throws Exception { public void getHost_CopiesMostValues() throws Exception { PythonOptions opts = parsePythonOptions( - "--experimental_allow_python_version_transitions=true", - "--experimental_remove_old_python_version_api=true", + "--incompatible_allow_python_version_transitions=true", + "--incompatible_remove_old_python_version_api=true", "--build_python_zip=true", "--incompatible_disallow_legacy_py_provider=true"); PythonOptions hostOpts = (PythonOptions) opts.getHost(); - assertThat(hostOpts.experimentalAllowPythonVersionTransitions).isTrue(); - assertThat(hostOpts.experimentalRemoveOldPythonVersionApi).isTrue(); + assertThat(hostOpts.incompatibleAllowPythonVersionTransitions).isTrue(); + assertThat(hostOpts.incompatibleRemoveOldPythonVersionApi).isTrue(); assertThat(hostOpts.buildPythonZip).isEqualTo(TriState.YES); assertThat(hostOpts.incompatibleDisallowLegacyPyProvider).isTrue(); } @@ -178,7 +178,7 @@ public void getHost_AppliesHostForcePython() throws Exception { ensureDefaultIsPY2(); PythonOptions optsWithOldFlag = parsePythonOptions( - "--experimental_remove_old_python_version_api=false", + "--incompatible_remove_old_python_version_api=false", "--force_python=PY2", "--host_force_python=PY3"); PythonOptions optsWithNewFlag = diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PythonSrcsVersionAspectTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PythonSrcsVersionAspectTest.java index e21f4ce54e7258..919c2067eb3a1a 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PythonSrcsVersionAspectTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PythonSrcsVersionAspectTest.java @@ -33,7 +33,7 @@ public class PythonSrcsVersionAspectTest extends BuildViewTestCase { @Before public void setUp() throws Exception { - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); } private static String join(String... args) { diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java index db8c29cec8b42e..4dcd13ab122d39 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PythonStarlarkApiTest.java @@ -77,7 +77,7 @@ private void defineUserlibRule() throws Exception { @Test public void librarySandwich() throws Exception { // Use new version semantics so we don't validate source versions in py_library. - useConfiguration("--experimental_allow_python_version_transitions=true"); + useConfiguration("--incompatible_allow_python_version_transitions=true"); defineUserlibRule(); scratch.file( "pkg/BUILD", diff --git a/src/test/java/com/google/devtools/build/lib/rules/python/PythonVersionSelectTest.java b/src/test/java/com/google/devtools/build/lib/rules/python/PythonVersionSelectTest.java index 7a8b4cf4dc2e1e..c9541183bb3d3a 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/python/PythonVersionSelectTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/python/PythonVersionSelectTest.java @@ -71,7 +71,7 @@ public void cannotSelectOnNativePythonVersionFlag() throws Exception { public void canSelectOnForcePythonFlagsUnderOldApi() throws Exception { // For backwards compatibility purposes, select()-ing on --force_python and --host_force_python // is allowed while the old API is still enabled. - useConfiguration("--experimental_remove_old_python_version_api=false"); + useConfiguration("--incompatible_remove_old_python_version_api=false"); scratch.file("fp/BUILD", makeFooThatSelectsOnFlag("force_python", "PY2")); scratch.file("hfp/BUILD", makeFooThatSelectsOnFlag("host_force_python", "PY2")); assertThat(getConfiguredTarget("//fp:foo")).isNotNull(); @@ -80,7 +80,7 @@ public void canSelectOnForcePythonFlagsUnderOldApi() throws Exception { @Test public void cannotSelectOnForcePythonFlagsWithoutOldApi() throws Exception { - useConfiguration("--experimental_remove_old_python_version_api=true"); + useConfiguration("--incompatible_remove_old_python_version_api=true"); checkError( "fp", "foo", diff --git a/src/test/shell/bazel/python_version_test.sh b/src/test/shell/bazel/python_version_test.sh index 1cd977234d1c75..525af0d92bed65 100755 --- a/src/test/shell/bazel/python_version_test.sh +++ b/src/test/shell/bazel/python_version_test.sh @@ -245,7 +245,7 @@ EOF sed s/py3bin/py2bin/ test/py2bin_calling_py3bin.py > test/py3bin_calling_py2bin.py chmod u+x test/py2bin_calling_py3bin.py test/py3bin_calling_py2bin.py - EXPFLAG="--experimental_allow_python_version_transitions=true" + EXPFLAG="--incompatible_allow_python_version_transitions=true" bazel build $EXPFLAG //test:py2bin_calling_py3bin //test:py3bin_calling_py2bin \ || fail "bazel build failed" @@ -324,7 +324,7 @@ EOF chmod u+x test/shbin_calling_py23bins.sh - EXPFLAG="--experimental_allow_python_version_transitions=true" + EXPFLAG="--incompatible_allow_python_version_transitions=true" bazel build $EXPFLAG //test:shbin_calling_py23bins \ || fail "bazel build failed" @@ -364,8 +364,8 @@ EOF # Run under both old and new semantics. for EXPFLAG in \ - "--experimental_allow_python_version_transitions=true" \ - "--experimental_allow_python_version_transitions=false"; do + "--incompatible_allow_python_version_transitions=true" \ + "--incompatible_allow_python_version_transitions=false"; do echo "Using $EXPFLAG" > $TEST_log bazel build $EXPFLAG --host_force_python=PY2 //test:genrule_calling_pybin \ || fail "bazel build failed" @@ -454,7 +454,7 @@ $(rlocation {{WORKSPACE_NAME}}/test/py3bin) EOF chmod u+x test/shbin.sh - EXPFLAG="--experimental_allow_python_version_transitions=true" + EXPFLAG="--incompatible_allow_python_version_transitions=true" bazel build $EXPFLAG //test:shbin \ || fail "bazel build failed" diff --git a/src/test/shell/integration/python_stub_test.sh b/src/test/shell/integration/python_stub_test.sh index 2be52481cc56cc..0095590bb17e1a 100755 --- a/src/test/shell/integration/python_stub_test.sh +++ b/src/test/shell/integration/python_stub_test.sh @@ -121,7 +121,7 @@ py_library( EOF touch test/lib2.py test/lib3.py - EXPFLAG="--experimental_allow_python_version_transitions=true" + EXPFLAG="--incompatible_allow_python_version_transitions=true" bazel build --python_version=PY2 $EXPFLAG //test:* \ &> $TEST_log || fail "bazel build failed"