-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
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
This issue tracks enabling
--incompatible_python_disable_py2(implemented in d1bbf4b) as part of #15684When enabled, the Python rules will reject Python 2 only attribute values. This includes:
python_version=PY2srcs_version=PY2andsrcs_version=PY2ONLYpy2_runtimeTo fix, you must update your rules (or dependencies) to not set these Python 2 values:
srcs_version: remove the attribute.py2_runtime: remove the attribute.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
PyInfoandPyRuntimeInfoproviders 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:has_py2_only_sourcesandhas_py3_only_sources.python_version=PY3Most of this can be automated using buildozer
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.