-
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
incompatible_load_python_rules_from_bzl: Python rules now need to be loaded from @rules_python #9006
Comments
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`. Work toward bazelbuild#9006. RELNOTES: None
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`. Work toward bazelbuild#9006. RELNOTES: None
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`. Work toward bazelbuild#9006. RELNOTES: None
This adds `@bazel_tools//tools/python:private/defs.bzl`, which defines macro wrappers around the four native Python rules (`py_library`, `py_binary`, `py_test`, `py_runtime`). These wrappers simulate the behavior of `@rules_python//python:defs.bzl`, so that they are compatible with the upcoming `--incompatible_load_python_rules_from_bzl` flag. This change also updates many direct uses of the native Python rules to use the wrappers instead. However, changes to the third_party/ directory have to be in a separate commit. The new macros should only be used by Bazel itself. All external users should use @rules_python instead. I'm omitting updating src/test/py/bazel/testdata/runfiles_test/*/BUILD.mock files because they appear to be tests that shouldn't complain until the flag is flipped, and I'm not sure that adding a load won't break them. Also not updating the examples/ dir for similar reasons. Work toward #9006. RELNOTES: None PiperOrigin-RevId: 260858287
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`. Work toward bazelbuild#9006. RELNOTES: None
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`. Work toward bazelbuild#9006. RELNOTES: None
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`. Work toward #9006. RELNOTES: None
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`. Work toward bazelbuild#9006. RELNOTES: None
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 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 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 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 #9029). Work toward #9006. RELNOTES: None
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
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
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 #9029). Work toward #9006. RELNOTES: None
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
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
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 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 #9029). Work toward #9006. Closes #9019. RELNOTES: None
This is to prepare for the Bazel incompatible flag 'load_python_rules_from_bzl' (bazelbuild/bazel#9006). Change-Id: If824c080a2c5b1e02a2eaeb6873aafd7afaf949f GitOrigin-RevId: 767e391778adc345df482cccadc1875fab80021b
What's the status of this flag? Is it going to be flipped eventually or has it been abandoned? If it's the former, can we add |
+1 to @Yannic’s question: this flag was supposed to be flipped in Bazel |
Ow, this bug is still open? After careful consideration, we decided that this would be change that causes way too much breakage, so we decided to take another approach instead: we'll teach Bazel to be able to carry Starlark rules with itself just like it does ones implemented in Java now. We'll have to figure out how to decouple these rules from Bazel, of course, but that's a next step. (My crystal ball says that it will involve some magic connection between BUILD files and the WORKSPACE file, for example, by adding implicit |
If the plan is to reverse course, could it be a good idea to delete this flag? [Context: I, like others it seems, got here because someone using a tool I'd build for bazel had it flipped, breaking things. Probably via |
Flag:
--incompatible_load_python_rules_from_bzl
Available since: 0.29
Will be flipped in: 2.0
Feature tracking issue: #8893
Motivation
The "core" Python rule logic is currently bundled with Bazel as a combination of native symbols and symbols loaded from
@bazel_tools//tools/python
. Eventually the native rules will be ported to Starlark, and all symbols will live in bazelbuild/rules_python. In the meantime, we're making it so the user loads these symbols from the rules_python repository, even though they're largely still implemented inside of Bazel itself. This will help make future migration of rule logic to rules_python less painful.Change
Enabling this flag causes the four native Python rules,
py_library
py_binary
py_test
py_runtime
to fail at analysis time when they are used directly instead of via rules_python.
Migration
Any usage of the these rules as a built-in symbol should be replaced with a use of the macros defined in rules_python as follows. (All four macros are defined in
defs.bzl
.)should become
In the case of macros in .bzl files,
should become
To access the
@rules_python
repo you'll need to make sure you have the following in your WORKSPACE file:If you're using rules_python for pip support (which is separate from the core Python rules), you'll also need to call the
pip_repositories()
function.Note that until recently,
@rules_python
went by the workspace name@io_bazel_rules_python
. If you have a definition for the old name in your WORKSPACE file then you'll need to rename it, and ensure your commit is updated to a recent version.The text was updated successfully, but these errors were encountered: