Python changes in Bazel 0.25

132 views
Skip to first unread message

Jon Brandvein

unread,
Apr 5, 2019, 2:54:22 PM4/5/19
to Bazel/Python Special Interest Group
Just wanted to announce a few updates on Python rules in the upcoming 0.25 release.

First, we've flipped the incompatible change flags introduced in 0.23 and 0.24. These flags fall into three categories:

    Better mixing of Python 2 and Python 3:
      --incompatible_remove_old_python_version_api (#7308)
      --incompatible_allow_python_version_transitions (#7307)

    Making Python 3 the default:
      --incompatible_py3_is_default (#7359)
      --incompatible_py2_outputs_are_suffixed (#7593)

    Removing the legacy struct "py" provider:
      --incompatible_disallow_legacy_py_provider (#7298)

These changes have been validated for downstream projects tested by our CI pipelines. But if you are broken by them, see the associated Github issues for migration instructions.

Second, we're introducing --incompatible_use_python_toolchains (#7899), which is aimed at replacing --python_top / --python_path with the toolchain mechanism, so that you automatically get a suitable Python runtime for the target platform. This is intended to deprecate the need for select()-based hacks in py_runtime. We're expecting to flip this flag in 0.26.

Note that since this flag affects how you invoke bazel (--python_top), and since the py_runtime information is inherently platform-dependent, it'll be harder for our CI to discover problems in downstream projects. Therefore, it'll be more important than usual for you to try out this flag in your build. See the Github issue for an example of how to define and register a Python toolchain.

Nicolas Lopez

unread,
Apr 5, 2019, 3:05:36 PM4/5/19
to Jon Brandvein, Bazel/Python Special Interest Group
please see https://github.com/bazelbuild/rules_k8s/issues/305 for issues we are having with these changes.
In a nutshell: it seems py_binary outputs for host configuration always point to python3 even when we set python_version= "PY2" in a py_binary target (note outputs produced for the target configuration are indeed pointing to python2 as we expect).

--
You received this message because you are subscribed to the Google Groups "Bazel/Python Special Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-sig-pyth...@googlegroups.com.
To post to this group, send email to bazel-si...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-sig-python/85300f70-4923-4736-ba0d-a0566aba54e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jon Brandvein

unread,
Apr 5, 2019, 3:22:18 PM4/5/19
to Nicolas Lopez, Bazel/Python Special Interest Group
Responded in that issue. The problem is the host config doesn't support choosing the Python version, unless you override it for all host-configured targets with --host_force_python. The plan for this is to introduce the "exec configuration" to replace host configuration. This is being worked on by the configurability team, and when that's done each rule will likely have to migrate host dependencies to a new attribute (e.g. genrule tools may become genrule exec_tools).
Reply all
Reply to author
Forward
0 new messages