Repository navigation
fix implicit __init__.py creation warnings - #1097
Conversation
|
Thanks for this! One spot that buildozer can't reach since it's created by a macro: the py_binary(
name = name,
srcs = [":" + name + "_install_script"],
main = name + "_install_script.py",
deps = [Label("//pkg/private:manifest"), Label("@rules_python//python/runfiles")],
legacy_create_init = 0,
srcs_version = "PY3",
python_version = "PY3",
**kwargs
)Would you mind adding |
Happy to! |
We here avoid diagnostics such as the following without resorting to
the Bazel flag `--incompatible_default_to_explicit_init_py`, which is
deprecated as of Bazel 10:
======================================================================
WARNING: Target @@rules_pkg+//pkg/private/deb:make_deb is using implicit __init__.py creation.
This diabolic behavior is deprecated and will be disabled by default in a
future release.
See bazel-contrib/rules_python#2945
Ensure all __init__.py files are explicitly created and
added to the srcs or deps of your targets.
Disable implicit creation for your module in MODULE.bazel:
rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
rules_python_config.explicit_init_py(default = True)
Or for a specific target by setting:
legacy_create_init = 0
Or globally with the following Bazel flag:
--incompatible_default_to_explicit_init_py
======================================================================
I saw these diagnostics with rules_python 2.5.0-rc3 and Bazel 9.3.2
(without the flag `--incompatible_default_to_explicit_init_py`).
Note that `legacy_create_init = 0` is supported in rules_python 1.7.0,
so there's no need to bump the minimum version of rules_python required
by rules_pkg. The `explicit_init_py()` method first appeared in
rules_python 2.3.0, so using it to deal with these warnings would
require bumping the minimum version of rules_python. I applied the
`legacy_create_init = 0` as follows:
buildozer "set legacy_create_init 0" //...:%py_binary
buildozer "set legacy_create_init 0" //...:%py_test
Fixed up pkg/install.bzl by hand per review comment from @fmeum.
Done! |
|
@fmeum What more must be done to get this to land? |
|
@aiuto Did you want to take a look before we merge? |
Fixes the Bazel-side warnings printed by `bazel build --config=llvm //src:bazel-dev` on a clean output base: * Replace the `--cpu`-based `config_setting`s in `//src/conditions`, which trigger a deprecation warning (`select() on cpu is deprecated`), with the existing constraint-based ones. Bazel CI doesn't use `--cpu` anymore. * Set `legacy_create_init = 0` on Bazel's own `py_binary` targets (`//src:create_embedded_tools`, `//tools/build_defs/proguard:wrapper_private`) to address the rules_python implicit `__init__.py` deprecation. * Drop the explicit `jar` packaging from Maven coordinates (`Assuming ... should be interpreted as ...`) and declare `known_contributing_modules` for the `maven` repo. `maven_install.json` only changes its input hash. * Only pass the `java_proto_library` for the service to `java_grpc_library`, as multiple `deps` are deprecated. The longrunning protos are covered transitively. * Exclude incubator modules from the "all modules" embedded JDK, which jlink warns about (`Using incubator modules: jdk.incubator.vector`) and Bazel doesn't use. Remaining warnings are fixed elsewhere and will be picked up by follow-up dependency updates: * c-ares: #32649 (drop c-ares), bazelbuild/bazel-central-registry#11756 * zstd-jni: bazelbuild/bazel-central-registry#11757 (zstd-jni 1.5.7-26) * protobuf: deprecated `GetEnum`/`GetRepeatedEnum` calls are fixed in protobuf 37.0 * rules_pkg: bazelbuild/rules_pkg#1097 * gRPC: grpc/grpc#43933, grpc/grpc-java#13188 * Mirror: #32646 Closes #32651 COPYBARA_INTEGRATE_REVIEW=#32651 from fmeum:fix-build-warnings 5f5e9c3 PiperOrigin-RevId: 1023592606 Change-Id: Ia04594ff9c771f596c291bf0d4785915124c6a5a
aiuto
left a comment
There was a problem hiding this comment.
I still think it's completely ridiculous that we need to put this legacy_init stuff on targets that actually have init.py. But that's the way rules python works, so resistance is futile.
We here avoid diagnostics such as the following without resorting to the Bazel flag
--incompatible_default_to_explicit_init_py, which is deprecated as of Bazel 10:I saw these diagnostics with rules_python 2.5.0-rc3 and Bazel 9.3.2 (without the flag
--incompatible_default_to_explicit_init_py).Note that
legacy_create_init = 0is supported in rules_python 1.7.0, so there's no need to bump the minimum version of rules_python required by rules_pkg. Theexplicit_init_py()method first appeared in rules_python 2.3.0, so using it to deal with these warnings would require bumping the minimum version of rules_python. I applied thelegacy_create_init = 0as follows:Fixed up
pkg/install.bzlby hand per review comment from @fmeum.