Clearly document PY2/PY3 mode #6442
Labels
P2
We'll consider working on this in future. (Assignee optional)
team-Rules-Python
Native rules for Python
type: documentation (cleanup)
Explain on the python rules page the following info:
There's a configuration field for selecting the python major version. It can be PY2, PY3, or unset/unknown.
This gets set to PY2 or PY3 when you encounter a
py_binary
target (based on itsdefault_python_version
attr), or by a top-level flag--force_python
.Once set, the same mode is used recursively for
py_library
targets that are transitively in thedeps
attr. But targets in thedata
attr are reset to unknown, so they can containpy_binary
s in a different mode.The mode determines what system python interpreter is used by default (if no
py_runtime
/--python_top
is given). In the future it may also be used to help select among multiplepy_runtime
s.Users can
select()
on theforce_python
flag to condition pieces of the build based on which mode is being used.Bazel validates that python targets marked via
srcs_version
to be only PY2 or only PY3 are built in the expected mode.NB: Current bugs that impact the above description:
The mode change from unknown -> PY2 doesn't actually work. This'll be fixed by the fix for py_library enforces Python 2 for some reason #1446.
The reset over
data
deps isn't yet implemented (Reset the PY2/PY3 mode along data dependencies #6441).The system python version isn't selected correctly for PY3 (py_binary doesn't automatically pick a Python runtime matching the requested version #4815).
The text was updated successfully, but these errors were encountered: