Skip to content

Commit

Permalink
Flip --incompatible_allow_python_version_transitions
Browse files Browse the repository at this point in the history
    With this flag enabled by default, the Python version is no longer "sticky" and forced to a fixed value by a command line flag. Instead it adjusts to whatever the `py_binary` or `py_test` declares its version to be.

    For more information see feature tracking issue #6583 and flag migration tracking issue #7307.

    Closes #7307.

    RELNOTES[INC]: (Python rules) The python version now changes to whatever version is specified in a `py_binary` or `py_test`'s `python_version` attribute, instead of being forced to the value set by a command line flag. You can temporarily revert this change with `--incompatible_allow_python_version_transitions=false`. See [#7307](bazelbuild/bazel#7307) for more information.

    PiperOrigin-RevId: 240227319
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent bb9a93b commit 7619039
Showing 1 changed file with 4 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public String getTypeDescription() {
*/
@Option(
name = "incompatible_py3_is_default",
defaultValue = "true",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.GENERIC_INPUTS,
effectTags = {
OptionEffectTag.LOADING_AND_ANALYSIS,
Expand All @@ -125,7 +125,7 @@ public String getTypeDescription() {

@Option(
name = "incompatible_py2_outputs_are_suffixed",
defaultValue = "true",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.GENERIC_INPUTS,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
metadataTags = {
Expand Down Expand Up @@ -230,14 +230,11 @@ public String getTypeDescription() {
public boolean incompatibleDisallowLegacyPyProvider;

@Option(
name = "incompatible_use_python_toolchains",
// TODO(brandjon): Rename to --incompatible_use_python_toolchains when ready to make available
name = "experimental_use_python_toolchains",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.GENERIC_INPUTS,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"If set to true, executable native Python rules will use the Python runtime specified by "
+ "the Python toolchain, rather than the runtime given by legacy flags like "
Expand All @@ -254,26 +251,6 @@ public String getTypeDescription() {
+ "data runfiles of another binary.")
public boolean buildTransitiveRunfilesTrees;

@Option(
name = "incompatible_windows_escape_python_args",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {
OptionEffectTag.ACTION_COMMAND_LINES,
OptionEffectTag.AFFECTS_OUTPUTS,
},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"On Linux/macOS/non-Windows: no-op. On Windows: this flag affects how py_binary and"
+ " py_test targets are built: how their launcher escapes command line flags. When"
+ " this flag is true, the launcher escapes command line flags using Windows-style"
+ " escaping (correct behavior). When the flag is false, the launcher uses Bash-style"
+ " escaping (buggy behavior). See https://github.com/bazelbuild/bazel/issues/7958")
public boolean windowsEscapePythonArgs;

@Override
public Map<OptionDefinition, SelectRestriction> getSelectRestrictions() {
// TODO(brandjon): Instead of referencing the python_version target, whose path depends on the
Expand Down Expand Up @@ -392,11 +369,6 @@ public FragmentOptions getHost() {
hostPythonOptions.buildPythonZip = buildPythonZip;
hostPythonOptions.incompatibleDisallowLegacyPyProvider = incompatibleDisallowLegacyPyProvider;
hostPythonOptions.incompatibleUsePythonToolchains = incompatibleUsePythonToolchains;
hostPythonOptions.windowsEscapePythonArgs = windowsEscapePythonArgs;

// Save host options in case of a further exec->host transition.
hostPythonOptions.hostForcePython = hostForcePython;

return hostPythonOptions;
}

Expand Down

0 comments on commit 7619039

Please sign in to comment.