-
Notifications
You must be signed in to change notification settings - Fork 4.4k
incompatible_python_disable_py2 #17293
Copy link
Copy link
Closed
Labels
breaking-change-7.0Incompatible flags to be flipped in Bazel 7.0Incompatible flags to be flipped in Bazel 7.0incompatible-changeIncompatible/breaking changeIncompatible/breaking changemigration-readyIncompatible flag is ready for migration with Bazel rolling releases or Bazel@last_greenIncompatible flag is ready for migration with Bazel rolling releases or Bazel@last_greenteam-Rules-PythonNative rules for PythonNative rules for Pythontype: process
Description
This issue tracks enabling --incompatible_python_disable_py2 (implemented in d1bbf4b) as part of #15684
When enabled, the Python rules will reject Python 2 only attribute values. This includes:
python_version=PY2srcs_version=PY2andsrcs_version=PY2ONLY- Setting
py2_runtime
To fix, you must update your rules (or dependencies) to not set these Python 2 values:
- For
srcs_version: remove the attribute. - For
py2_runtime: remove the attribute. - For
python_version: remove the attribute frompy_binaryandpy_test. Forpy_runtime,
the entire target can be deleted, as there is nothing that can use it.
Note that the PyInfo and PyRuntimeInfo providers do not raise an error. This is simply because providers can't access flags to know whether to enforce behavior; code should still be updated as appropriate:
- For PyInfo, stop reading/writing
has_py2_only_sourcesandhas_py3_only_sources. - For PyRuntimeInfo, set
python_version=PY3
Most of this can be automated using buildozer
remove python_version //...%py_binary
remove python_version //...%py_test
remove srcs_version //...%py_binary
remove srcs_version //...%py_test
remove srcs_version //...%py_library
remove py2_runtime //...%py_runtime_pair
It may not be your code with a problem, but a dependency. In this case, you probably just need to update your dependency to a newer version -- most projects no longer require Python 2.
- For rules_pkg, upgrade to 0.3.0 or greater
Reactions are currently unavailable
Metadata
Metadata
Labels
breaking-change-7.0Incompatible flags to be flipped in Bazel 7.0Incompatible flags to be flipped in Bazel 7.0incompatible-changeIncompatible/breaking changeIncompatible/breaking changemigration-readyIncompatible flag is ready for migration with Bazel rolling releases or Bazel@last_greenIncompatible flag is ready for migration with Bazel rolling releases or Bazel@last_greenteam-Rules-PythonNative rules for PythonNative rules for Pythontype: process