Skip to content

Bazel doesn't recognize that /usr/bin/python is Python 3, not 2. #6744

@philwo

Description

@philwo

Description of the problem / feature request:

On systems where "python" on the PATH is Python 3 (e.g. Arch Linux has /usr/bin/python = Python3, also some macOS Homebrew installations seem to have /usr/local/bin/python as Python3), Bazel doesn't realize that and believes it's using Python 2.

Thus py_binary's that use PY2 (which is still the default for Bazel, so that would be almost all binaries) and are not compatible with Python 3 will mysteriously fail to run.

Some examples of where this caused confusion:

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Bazel should detect the correct Python 2.x and 3.x versions from the PATH, by inspecting the version output of "python", "python2" and "python3" and then choosing appropriate binaries.

What operating system are you running Bazel on?

Arch Linux

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)team-Rules-PythonNative rules for Pythontype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions