-
Notifications
You must be signed in to change notification settings - Fork 272
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
Breaks with Python toolchains (to be flipped in Bazel 0.27) #456
Comments
Is that alone going to fix things? The catch we've had in the past is we use py_binary as tool for an action, and that action then is tagged to always run on a mac, but in a mix/remote execution env, the problem is no transitions happen related to that, so the py_binary was built for the host env, not actually for the mac where it gets run. So how to we ensure the py_binary will always work? |
Right, there can only be one host configuration, so unfortunately there can only be one Python version used for all Python targets built in the host configuration. This has always been true, so it is not a regression. What has changed is that now Bazel enforces that the version you ask for (even implicitly by default) is the version you get. The default Python version is Python 3, and it seems you were expecting to get Python 2. You can tell Bazel to use Python 2 for the host configuration with |
A global flag doesn't help, we're a rule set, we need to work (with some python tools along the way) no matter what flags the end developer ends up needing to pass. |
For the end user there can only be one version used in the host config. If you have Python tools that require PY2, then so do your users. Both you and they will have to set Again, this has always been the case, it's just more apparent now that the default has changed to PY3 (as of Bazel 0.25) and Bazel is actually enforcing this default (as of Bazel 0.27). |
There should be a way to make this "just work", wether they have python 2 or 3 installed, what's the path to that? Anything outside of that is basically going to be hostile to Mac users. |
Spoke with @sergiocampama on Friday and put my plan in bazelbuild/bazel#8547. To the point you raise, I think there are two separate cases:
For the first case, if you have a host tool that legitimately is PY2, then the combination of fixing bazelbuild/bazel#4815 along with the fact that PY3 is now the default means that you had better tell Bazel to use PY3 in the host config with For the second case, it seems there's a real need for a way to define a One idea is to add a new allowed value The other idea is to have users indirect their dependencies, so that instead of depending on a In any case, my main goal now is to be less hostile to all users by advising them of the need to set |
The solution I outlined for mac users in bazelbuild/bazel#8547 (break them once with instructions on how to opt out of strict version checking) is marked as a Bazel release blocker. In the meantime, can we add the |
CI should be fixed up (just the one on head bazel, the latest bazel doesn't have the flag set yet, waiting to see if there is better resolution that forcing all developers to also set the flag) |
I'm still seeing failures in this run from last night (~8pm EST). I suspect that e385296 and fac34c5 only set the flag in rules_apple's own CI pipeline, not the collective Bazel@HEAD + downstream projects pipeline. That would require setting I understand your reluctance to add a bazelrc flag in so far as it signifies that users are supposed to update their own bazelrcs. But they'll have to do that anyway, regardless of whether the downstream projects pipeline turns green for rules_apple or not. Bazel does not currently provide a built-in way to automatically select Python 2 or 3 mode for binaries based on the user's platform, and never has (although one can probably be written using macros as I mentioned above). The fact that it happened to work before was a bug (bazelbuild/bazel#4815 specifically). |
The rc file won't help the integration tests, it is failing in the workspaces created within those tests. fac34c5 went in an hour ago to hopefully finish catching those issues. |
Oh, I see. Thanks! +@laurentlb, can we get a rerun of either the RC's or the bazel@head+downstream pipeline to verify this fix? |
There's atleast one more test that isn't channeling thru our common plumbing and hitting a python issue. I've got some cls in the pipeline fixing things that need to land first, once that's in, I'll send out another CL to get the last place I know of hitting python differences. |
@brandjon is this flag still going to flip in 0.27 meaning you will force all devs to use the python flag or is it going to get flipped back of pending resolution for things like us where we use python within the rules can shouldn't require global flags? |
The plan is to flip in 0.27 and force people to add There's a few different use cases here:
Edit: I should add, the non-strict toolchain also works on non-mac platforms, should it be needed. |
Working toward #456. - Add a wrap to test under python 2 and 3. - Minor tweaks to improve support for both pythons. RELNOTES: None. PiperOrigin-RevId: 252104076
Working toward #456. - Add a wrap to test under python 2 and 3. - Minor tweaks to improve support for both pythons. - Tweak the tools a little for dual support. RELNOTES: None. PiperOrigin-RevId: 252104076
Working toward #456. - Add a wrap to test under python 2 and 3. - Minor tweaks to improve support for both pythons. - Tweak the tools a little for dual support. RELNOTES: None. PiperOrigin-RevId: 252104076
Working toward #456. - Add a wrap to test under python 2 and 3. - Minor tweaks to improve support for both pythons. - Tweak the tools a little for dual support. RELNOTES: None. PiperOrigin-RevId: 252428068
If the target is truly compatible with both, in its source code and in the target attributes, transitively, then it should be fine. (Also discussed this use case here.) |
Verified in buildkite. Thanks. Do keep in mind that users may still have to add |
Bazel 0.27 flips
--incompatible_use_python_toolchains
, which breaksrules_apple
according to a presubmit. The flag causes Bazel to actually run Python targets with the version of Python that was requested at analysis time, instead of whatever thepython
command happens to be. You likely need to addpython_version = "PY2"
to your targets, and/or enable--host_force_python=PY2
. Note that the default version for both host and target config is Python 3 as of Bazel 0.25.The text was updated successfully, but these errors were encountered: