bazel如何选择python版本?

How does bazel choose the python version?

我是 运行 一个 python 二进制目标 bazel run xxx 并且在目标中我正在做 print(sys.version)。这输出 Python version 3.6.8 (default, Jan 14 2019, 11:02:34)

当我直接输入 python 命令时,我得到 Python 3.7.3 (default, Apr 3 2019, 19:16:38)

Why/how bazel 是否选择了不同的 python 版本?

Bazel 将根据构建的配置选择不同的 python 版本。如果未覆盖任何内容,bazel 将使用其默认 python 版本。这可以通过在 运行 一个 bazel 命令时传递 --python_version=<some_version> 来覆盖。

https://docs.bazel.build/versions/master/be/python.html#py_binary.python_version https://github.com/bazelbuild/rules_python/blob/120590e2f2b66e5590bf4dc8ebef9c5338984775/python/BUILD#L43