Skip to content

Commit

Permalink
Enable Python toolchains by default
Browse files Browse the repository at this point in the history
    (This is a roll-forward of bazelbuild/bazel@bf66dc7.)

    This flips --incompatible_use_python_toolchains, which deprecates --python_top (and for the most part, --python_path). See #7899 for more on the change and migration procedure.

    Known downstream breakages are summarized [here](bazelbuild/bazel#7899 (comment)).

    Fixes #7899, fixes #7375, significant progress on #4815.

    RELNOTES[INC]: Python rules now determine the Python runtime using toolchains rather than `--python_top` and `--python_path`, which are deprecated. See [#7899](bazelbuild/bazel#7899) for information on declaring Python toolchains and migrating your code. As a side-benefit, this addresses [#4815](bazelbuild/bazel#4815) (incorrect interpreter version used) on non-Windows platforms. Note however that some builds break due to getting the version they asked for -- consider setting `python_version = "PY2"` on Python 2 targets and `--host_force_python=PY2` if any Python 2 targets are used in the host configuration. You can temporarily opt out of this change with `--incompatible_use_python_toolchains=false`.

    PiperOrigin-RevId: 250918912
  • Loading branch information
Luca Di Grazia committed Sep 4, 2022
1 parent cbdc10a commit c00ac5e
Showing 1 changed file with 14 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,6 @@ public String getTypeDescription() {
+ "--python_top.")
public boolean incompatibleUsePythonToolchains;

@Option(
name = "incompatible_load_python_rules_from_bzl",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES,
},
help =
"If enabled, direct use of the native Python rules is disabled. Please use the Starlark "
+ "rules instead: https://github.com/bazelbuild/rules_python. See also "
+ "https://github.com/bazelbuild/bazel/issues/9006.")
public boolean loadPythonRulesFromBzl;

@Option(
name = "experimental_build_transitive_python_runfiles",
defaultValue = "true",
Expand All @@ -270,21 +255,24 @@ public String getTypeDescription() {
public boolean buildTransitiveRunfilesTrees;

@Option(
name = "incompatible_default_to_explicit_init_py",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.GENERIC_INPUTS,
effectTags = {OptionEffectTag.AFFECTS_OUTPUTS},
name = "incompatible_windows_escape_python_args",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {
OptionEffectTag.ACTION_COMMAND_LINES,
OptionEffectTag.AFFECTS_OUTPUTS,
},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"This flag changes the default behavior so that __init__.py files are no longer "
+ "automatically created in the runfiles of Python targets. Precisely, when a "
+ "py_binary or py_test target has legacy_create_init set to \"auto\" (the default), "
+ "it is treated as false if and only if this flag is set. See "
+ "https://github.com/bazelbuild/bazel/issues/10076.")
public boolean incompatibleDefaultToExplicitInitPy;
"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() {
Expand Down Expand Up @@ -404,7 +392,7 @@ public FragmentOptions getHost() {
hostPythonOptions.buildPythonZip = buildPythonZip;
hostPythonOptions.incompatibleDisallowLegacyPyProvider = incompatibleDisallowLegacyPyProvider;
hostPythonOptions.incompatibleUsePythonToolchains = incompatibleUsePythonToolchains;
hostPythonOptions.loadPythonRulesFromBzl = loadPythonRulesFromBzl;
hostPythonOptions.windowsEscapePythonArgs = windowsEscapePythonArgs;

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

0 comments on commit c00ac5e

Please sign in to comment.