py_console_script_binary and gazelle modules_mapping warn about implicit __init__.py even after explicit_init_py(default = True)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- build-system
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
🐞 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
- Vorherrschende Sprache
- Starlark
- Sterne
- 687
- Forks
- 726
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 77
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus bazel-contrib/rules_python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bazel-contrib/rules_python#4251 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
bazel-contrib/rules_python#4164 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
go:embed stdlib_list.txt file in gazelle/python/std_modules.go is missingEvtl. vergeben @udaya2899 hat das vor 16 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bazel-contrib/rules_python#3821 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
bazel-contrib/rules_python#4269 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
bazel-contrib/rules_python#4250 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in bazel-contrib/rules_python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
beehive-lab/TornadoVM#1248 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
SimVascular/svZeroDSolver#253 ·
-
difficulty: easy domain: devops effort: 1-4h enhancement good first issue smart-contracts Stellar Wave
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Kaycee276/Chesster#469 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
ai-generated bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
VV01T3K/ResearchCruiseApp#463 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 75/100
tesseract-ocr/tesseract#4653 ·
Maintainer antworten meist innerhalb von 1 Tag