py_console_script_binary and gazelle modules_mapping warn about implicit __init__.py even after explicit_init_py(default = True)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 68/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- python
- 領域
- build-system
研究方向
Start with the affected entry points: python/entry_points/py_console_script_binary.bzl and the py_console_script_gen_py target, then inspect the modules_mapping generator and merger targets in rules_python_gazelle_plugin. Run the Bazel reproduction with explicit_init_py(default = True) and --incompatible_default_to_explicit_init_py. Done means the three warnings disappear while the generated outputs remain byte-identical and the console script still runs.
由索引模型根據 Issue 內容生成。
描述
🐞 bug report
Affected Rule
The issue is caused by the rule: py_console_script_binary (its generator, @rules_python//python/private:py_console_script_gen_py) and the gazelle plugin's modules_mapping (@rules_python_gazelle_plugin//modules_mapping:generator and :merger).
Is this a regression?
No. These tools have always relied on implicit __init__.py creation; the deprecation warning is what's new.
Description
The module-wide explicit_init_py setting (#3997) only covers the declaring module's own targets. These three py_binary tools belong to rules_python and rules_python_gazelle_plugin, which don't declare it for themselves or set legacy_create_init on the targets. So any module that uses py_console_script_binary or modules_mapping still gets the warning after opting itself in, and has nothing left to change.
The tools don't seem to need the implicit files. With --incompatible_default_to_explicit_init_py, the repro below builds byte-identical outputs (the generated entry point and the modules-mapping JSON), and the console script still runs. So legacy_create_init = 0 on the three targets, or explicit_init_py(default = True) in both modules, looks sufficient.
The three targets are unchanged on main. py_console_script_gen_py was also mentioned in a comment on #2945.
🔬 Minimal Reproduction
MODULE.bazel:
bazel_dep(name = "rules_python", version = "2.3.4")
bazel_dep(name = "rules_python_gazelle_plugin", version = "2.3.4")
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.13")
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
hub_name = "pypi",
python_version = "3.13",
requirements_lock = "//:requirements.txt",
)
use_repo(pip, "pypi")
rules_python_config = use_extension("@rules_python//python/extensions:config.bzl", "config")
rules_python_config.explicit_init_py(default = True)
BUILD.bazel:
load("@pypi//:requirements.bzl", "all_whl_requirements")
load("@rules_python//python/entry_points:py_console_script_binary.bzl", "py_console_script_binary")
load("@rules_python_gazelle_plugin//modules_mapping:def.bzl", "modules_mapping")
py_console_script_binary(
name = "pyflakes",
pkg = "@pypi//pyflakes",
)
modules_mapping(
name = "modules_map",
wheels = all_whl_requirements,
)
requirements.txt:
pyflakes==3.4.0
bazel build --nobuild //...
🔥 Exception or Error
WARNING: Target @@rules_python_gazelle_plugin+//modules_mapping:generator is using implicit __init__.py creation.
WARNING: Target @@rules_python_gazelle_plugin+//modules_mapping:merger is using implicit __init__.py creation.
WARNING: Target @@rules_python+//python/private:py_console_script_gen_py is using implicit __init__.py creation.
🌍 Your Environment
Operating System:
macOS (arm64); the same three warnings on Linux x86_64 and aarch64
Output of bazel version:
Build label: 9.2.0
Rules_python version:
2.3.4 and 2.4.0-rc2
- 主要語言
- Starlark
- 星號
- 688
- 分支
- 728
- 平均合併
- 16 小時 50 分鐘
- 30 天內合併 PR
- 136
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
bazel-contrib/rules_python 的其他 Issue
-
Increase the patch version of all Python releases可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉Good first issue
難度 2/5 1-3 小時 新手友好度 86/100
bazel-contrib/rules_python#4358 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
bazel-contrib/rules_python#4251 · 1 個 reaction ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
bazel-contrib/rules_python#4164 · 1 則留言 ·
維護者通常 1 天內回覆
-
Can Close? need: repro
難度 5/5 一週以上 新手友好度 35/100
bazel-contrib/rules_python#4315 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 45/100
bazel-contrib/rules_python#4311 ·
維護者通常 1 天內回覆
查看 bazel-contrib/rules_python 的全部 Issue
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
RevenueCat/purchases-hybrid-common#2039 ·
維護者通常 1 天內回覆
-
Update migen未關閉
難度 2/5 1-3 小時 新手友好度 70/100
YosysHQ/oss-cad-suite-build#220 ·
-
難度 2/5 1-3 小時 新手友好度 67/100
OpenLiberty/ci.maven#2137 ·
維護者通常 1 天內回覆
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 76/100
-
@apps/catalog enhancement
難度 2/5 1-3 小時 新手友好度 76/100
ymm-oss/flutter-mobile-project-template#699 ·
維護者通常 15 天內回覆