Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message when host tools built for PY3 fail #8549

Closed
brandjon opened this issue Jun 3, 2019 · 0 comments
Closed

Improve error message when host tools built for PY3 fail #8549

brandjon opened this issue Jun 3, 2019 · 0 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Rules-Python Native rules for Python type: feature request

Comments

@brandjon
Copy link
Member

brandjon commented Jun 3, 2019

The default host config Python version is PY3, but many host tools are written for Python 2. With --incompatible_use_python_toolchains being flipped, a common mode of failure is that these tools now fail for downstream users who do not know to set --host_force_python=PY2. This previously worked because we were ignoring the Python version and just calling python, which on most systems is Python 2 (#4815).

We already have a diagnostic message for host tools that exit with a non-zero code, in the case where the target's python_version disagrees with the host config's Python version. But this message does not fire when there is no python_version attribute set and no --host_force_python passed, since both of these default to PY3. I propose we extend this message to also fire when python_version is not explicitly set. That will cover the common case and help alert downstream users to the changed needed in their bazelrc.

Looking to cherrypick into 0.27.

@brandjon brandjon added type: feature request P1 I'll work on this now. (Assignee required) team-Rules-Python Native rules for Python labels Jun 3, 2019
@brandjon brandjon self-assigned this Jun 3, 2019
laurentlb pushed a commit that referenced this issue Jun 6, 2019
We already emit a diagnostic message when the host config's Python version overrides a Python tool's normal version. This helps users know to add --host_force_python=PY2 to their bazelrc. Without it, all they'd see is a confusing Python stack trace.

With this change, we also emit a diagnostic message when the target's python_version attribute is omitted and the user has not set --host_force_python=PY2. This covers the case where both the target and the host config default to PY3, but the target was really intended to be a Python 2 target. Previously, this case sometimes worked anyway due to #4815, but with Python toolchains enabled it breaks and we need to help the user understand the breakage.

In all cases the diagnostic is still only printed when the target has non-zero exit code and is built in host config.

See also #7899. Fixes #8549.

RELNOTES: None
PiperOrigin-RevId: 251496135
laurentlb pushed a commit that referenced this issue Jun 7, 2019
We already emit a diagnostic message when the host config's Python version overrides a Python tool's normal version. This helps users know to add --host_force_python=PY2 to their bazelrc. Without it, all they'd see is a confusing Python stack trace.

With this change, we also emit a diagnostic message when the target's python_version attribute is omitted and the user has not set --host_force_python=PY2. This covers the case where both the target and the host config default to PY3, but the target was really intended to be a Python 2 target. Previously, this case sometimes worked anyway due to #4815, but with Python toolchains enabled it breaks and we need to help the user understand the breakage.

In all cases the diagnostic is still only printed when the target has non-zero exit code and is built in host config.

See also #7899. Fixes #8549.

RELNOTES: None
PiperOrigin-RevId: 251496135
irengrig pushed a commit to irengrig/bazel that referenced this issue Jun 18, 2019
We already emit a diagnostic message when the host config's Python version overrides a Python tool's normal version. This helps users know to add --host_force_python=PY2 to their bazelrc. Without it, all they'd see is a confusing Python stack trace.

With this change, we also emit a diagnostic message when the target's python_version attribute is omitted and the user has not set --host_force_python=PY2. This covers the case where both the target and the host config default to PY3, but the target was really intended to be a Python 2 target. Previously, this case sometimes worked anyway due to bazelbuild#4815, but with Python toolchains enabled it breaks and we need to help the user understand the breakage.

In all cases the diagnostic is still only printed when the target has non-zero exit code and is built in host config.

See also bazelbuild#7899. Fixes bazelbuild#8549.

RELNOTES: None
PiperOrigin-RevId: 251496135
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
We already emit a diagnostic message when the host config's Python version overrides a Python tool's normal version. This helps users know to add --host_force_python=PY2 to their bazelrc. Without it, all they'd see is a confusing Python stack trace.

With this change, we also emit a diagnostic message when the target's python_version attribute is omitted and the user has not set --host_force_python=PY2. This covers the case where both the target and the host config default to PY3, but the target was really intended to be a Python 2 target. Previously, this case sometimes worked anyway due to bazelbuild#4815, but with Python toolchains enabled it breaks and we need to help the user understand the breakage.

In all cases the diagnostic is still only printed when the target has non-zero exit code and is built in host config.

See also bazelbuild#7899. Fixes bazelbuild#8549.

RELNOTES: None
PiperOrigin-RevId: 251496135
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Rules-Python Native rules for Python type: feature request
Projects
None yet
Development

No branches or pull requests

1 participant