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.