Repository navigation
fix: stop rules_python from warning about its own implicit __init__.py creation - #4451
Merged
Merged
Conversation
…y creation
This patch prevents the following warnings:
======================================================================
WARNING: Target @@rules_python+//tools:wheelmaker is using implicit __init__.py creation.
This diabolic behavior is deprecated and will be disabled by default in a
future release.
See bazel-contrib#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
======================================================================
======================================================================
WARNING: Target @@rules_python+//python/private:py_wheel_dist is using implicit __init__.py creation.
This diabolic behavior is deprecated and will be disabled by default in a
future release.
See bazel-contrib#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
======================================================================
======================================================================
WARNING: Target @@rules_python+//python/private:py_console_script_gen_py is using implicit __init__.py creation.
This diabolic behavior is deprecated and will be disabled by default in a
future release.
See bazel-contrib#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
======================================================================
======================================================================
WARNING: Target @@rules_python+//tools/publish:twine is using implicit __init__.py creation.
This diabolic behavior is deprecated and will be disabled by default in a
future release.
See bazel-contrib#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
======================================================================
Note that `--incompatible_default_to_explicit_init_py` throws the
following warning under Bazel 10:
WARNING: Option 'incompatible_default_to_explicit_init_py' is deprecated
Closes bazel-contrib#4448
dws
marked this pull request as ready for review
November 9, 2026 03:07
Contributor
Author
|
If this or something like it could be included in 2.5.0, that would be great. |
Contributor
Author
|
If you'd prefer per-target suppressions, I could do that instead. That just seems more prone to getting stale and being incomplete. |
Collaborator
|
/backport |
Collaborator
|
Thank you. This has been bugging me, but I hadn't had time to deal with it. |
rickeylev
approved these changes
Nov 9, 2026
rickeylev
left a comment
Collaborator
There was a problem hiding this comment.
sending my agent to cleanup the description, otherwise lgtm
Contributor
|
Updated release tracking issue #4388 (Release 2.5.0) with this PR added to the backports checklist. |
github-actions Bot
pushed a commit
that referenced
this pull request
Nov 9, 2026
…y creation (#4451) When rules_python is used as a Bzlmod dependency without --incompatible_default_to_explicit_init_py (which is deprecated in Bazel 10), rules_python emits implicit __init__.py deprecation warnings for its own internal targets (//tools:wheelmaker, //python/private:py_wheel_dist, //python/private:py_console_script_gen_py, and //tools/publish:twine). Enable rules_python_config.explicit_init_py(default = True) in MODULE.bazel so all targets in rules_python default to explicit __init__.py behavior. Closes #4448 (cherry picked from commit ab7da31) Work towards #4388
rickeylev
pushed a commit
that referenced
this pull request
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When rules_python is used as a Bzlmod dependency without
--incompatible_default_to_explicit_init_py(which is deprecated inBazel 10), rules_python emits implicit
__init__.pydeprecationwarnings for its own internal targets (
//tools:wheelmaker,//python/private:py_wheel_dist,//python/private:py_console_script_gen_py, and//tools/publish:twine).Enable
rules_python_config.explicit_init_py(default = True)inMODULE.bazelso all targets in rules_python default to explicit__init__.pybehavior.Closes #4448