-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add load() statements for Python rules in third_party #9019
Conversation
Discussed with @laszlocsomor. Resolution is:
|
SGTM. I think in the long term we'd benefit from purging six and protobuf (and whatever else we can) from bazel_tools to avoid needing such hacks, and require users to import in their WORKSPACE all language rules and tools they need. |
Note that db063a8 (internally cl/260716838 from the PR description) is now merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I can help you merge this once tests pass.
Gah,
But from what I can tell, the use of And if protobuf gets its |
flips table |
Ok, I have the framework of a solution. Protobuf, which is used both in-tree as-is, and as a (local) external repo, is hand-modified to reference As for six, which is used in-workspace and in Here is a Buildkite run (in progress) of a proof of concept of these third_party/ changes plus my incompatible flag introduction. If this all goes well I'll clean up this PR and look to merge tomorrow (the scheduled day of the release cut). |
4ab7cdd
to
081af60
Compare
Well great, I broke bootstrapping (see CI results for this PR). You don't happen to have any ideas John, do you? |
Turns out it helps if, when creating a new third_party/ subdir, I also add it to To allow |
Detail: src/test/shell/integration/modify_execution_info_test.sh requires a fix to its test setup to add
Setting up one more combined CI run tonight and I'll handle the rest tomorrow. |
@brandjon that's some heroic effort you do here.
This part I don't follow. Could you explain the deal with
Sounds like you could verify this by adding garbage to |
Thanks, but don't mistake exasperated frequent updates for heroism ;)
Six is used in a
Gah, with garbage added I get a test failure in |
Yep, garbage in the WORKSPACE kills it too. Which makes sense, if the workspace is being evaluated that explains why six.BUILD is. Failing target within the test's call to compile.sh is
|
In any case I'll just fix the six.BUILD file to be compatible with the flag just in case we run into some kind of bootstrapping problem when we try to flip the flag. |
This stub contains only one relevant file, @rules_python//python:defs.bzl, which mimics the file at the same path in bazelbuild/rules_python. Having this repo gives us a way to inject this defs.bzl file into our protobuf dependency, which is loaded as a separate (local) external repo and therefore cannot access the existing //tools/python:private/defs.bzl in Bazel's own workspace. It also means we'll be compatible with the future upstream migration to fix protobuf for bazelbuild#9006. A separate PR will add this to the Bazel root WORKSPACE file (since third_party/ must be updated in a separate commit). Break-out of bazelbuild#9019. Work toward bazelbuild#9006. RELNOTES: None
Please see PR #9044, the first step of merging this. |
Thanks for the explanation! |
These will be used by third_party/protobuf in a follow-up. Also update a test that uses protobuf and that will break when protobuf is updated (since the test can't be changed in the same PR as third_party/). Break-out of bazelbuild#9019. Work toward bazelbuild#9006. RELNOTES: None
Manual presubmit run with current commits (which need to be rebased but content-wise I believe are ok) is here. |
This stub contains only one relevant file, @rules_python//python:defs.bzl, which mimics the file at the same path in bazelbuild/rules_python. Having this repo gives us a way to inject this defs.bzl file into our protobuf dependency, which is loaded as a separate (local) external repo and therefore cannot access the existing //tools/python:private/defs.bzl in Bazel's own workspace. It also means we'll be compatible with the future upstream migration to fix protobuf for #9006. A separate PR will add this to the Bazel root WORKSPACE file (since third_party/ must be updated in a separate commit). Break-out of #9019. Work toward #9006. Closes #9044. RELNOTES: None
These will be used by third_party/protobuf in a follow-up. Also update a test that uses protobuf and that will break when protobuf is updated (since the test can't be changed in the same PR as third_party/). Break-out of bazelbuild#9019. Work toward bazelbuild#9006. RELNOTES: None
These will be used by third_party/protobuf in a follow-up. Also update a test that uses protobuf and that will break when protobuf is updated (since the test can't be changed in the same PR as third_party/). Break-out of bazelbuild#9019. Work toward bazelbuild#9006. RELNOTES: None
Status update: Waiting on this PR's auto-initiated CI run, which includes #9048. #9048 is blocked on this run, because the issue in the test it fixes is only exercised by this PR. #9048's own CI is proceeding as we speak and should easily pass. So I propose that if both of these PRs CI are green, we rebase and merge without waiting for more runs. |
I am fine with merging once the combined test run passes. |
These will be used by third_party/protobuf in a follow-up. Also update a test that uses protobuf and that will break when protobuf is updated (since the test can't be changed in the same PR as third_party/). Break-out of #9019. Closes #9048. Work toward #9006. RELNOTES: None PiperOrigin-RevId: 261176215
This replaces all direct uses of the native Python rules underneath the third_party/ directory with load()s of the internal wrapper macros. These macros are needed for compatibility with `--incompatible_load_python_rules_from_bzl`. Some of the uses are replaced by the file under the tools/ dir, which is already used elsewhere in Bazel. A few uses have to use a new @rules_python repo (see also bazelbuild#9029). Work toward bazelbuild#9006. RELNOTES: None
This seems to have broken https://buildkite.com/bazel/starlark/builds/83#482da2c7-8415-4381-9645-173a945749c3 |
I verified it locally:
|
So IIUC, this breaks projects that import @io_bazel (i.e. that depend directly on bazelbuild/bazel's source tree). This seems acceptable/allowed to me, and not subject to our incompatible change policy. If it breaks the project, they can version the dependency and work around the change on their own timetable, just like any other repo dependency. It's not an issue with the host bazel binary. Or am I misunderstanding? |
Note that any recent (last week or so) version of bazelbuild/rules_python will give you a @rules_python in your workspace that is compatible with bazel's source tree's use of @rules_python, which is only a stub. |
FYI, bazelbuild/starlark doesn't appear to run in the downstream projects CI. Last night's run, which I believe includes this PR, is green (modulo unrelated nodejs failures). |
Sent bazelbuild/starlark#79 to migrate them. |
This PR is necessary to unblock #9006, which blocks the next Bazel release. However, I'm running into some trouble getting the load paths to work. Note that this PR depends on cl/260716838 which is as of this writing in-flight.
The trouble with load paths is that this makes third_party packages load a bzl underneath
//tools
, This works for some third_party packages, but six and protobuf get turned into local external repos by Bazel's own WORKSPACE file, which causes the labels to resolve relative to@six
and@com_google_protobuf
respectively.I can sort of fix this by qualifying the label with
@io_bazel
, except that this breaks six's use inside of@bazel_tools
, which cannot access@io_bazel
.So my ideas are
Add some kind of repository renaming to the generation of
@bazel_tools
, to rewrite@io_bazel
as@bazel_tools
or the main repo name. This seems ugly and like it will confuse future debugging.Use labels that are not qualified by repo name and therefore work both within
@io_bazel
and@bazel_tools
. Add some kind of rewriting step to the repo rules that produce@six
and@com_google_protobuf
within Bazel's WORKSPACE.Don't add a dependency on the
//tools/...
bzl at all, but instead inline that file into each third_party package that needs it.Finally, I want to say I've never modified third_party before so I don't know what our practices are regarding hand-crafted changes to vendored sources. I'm happy to tweak things by adding explanatory comments, but this change is somewhat time-sensitive (cut date is supposed to be August 1).