Skip to content

fix: stop rules_python from warning about its own implicit __init__.py creation - #4451

Merged
rickeylev merged 1 commit into
bazel-contrib:mainfrom
dws:diabolic
Nov 9, 2026
Merged

rickeylev merged 1 commit into
bazel-contrib:mainfrom
dws:diabolic

Conversation

@dws

@dws dws commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

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

…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
dws marked this pull request as ready for review November 9, 2026 03:07
@dws
dws requested review from aignas and rickeylev as code owners November 9, 2026 03:07
@dws

dws commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

If this or something like it could be included in 2.5.0, that would be great.

@dws

dws commented Nov 9, 2026 •

Copy link
Copy Markdown
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.

@rickeylev

Copy link
Copy Markdown
Collaborator

/backport

@rickeylev

Copy link
Copy Markdown
Collaborator

Thank you. This has been bugging me, but I hadn't had time to deal with it.

@rickeylev rickeylev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sending my agent to cleanup the description, otherwise lgtm

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Updated release tracking issue #4388 (Release 2.5.0) with this PR added to the backports checklist.

@github-actions github-actions Bot mentioned this pull request Nov 9, 2026
16 tasks done
@rickeylev
rickeylev added this pull request to the merge queue Nov 9, 2026
Merged via the queue into bazel-contrib:main with commit ab7da31 Nov 9, 2026
15 checks passed
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
Updates CHANGELOG.md and removes news files for backports:
- #4438
- #4451

Work towards #4388
Release-Tracking-Issue: #4388

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rules_python warns about its own implicit __init__.py creation

2 participants