bazel-contrib / bazel-contrib/rules_python
Remove automatic __init__.py generation (set incompatible_default_to_explicit_init_py to true)
- 主要语言
- Starlark
- 星标
- 688
- 派生
- 721
- 平均合并
- 15 小时 7 分钟
- 30 天内合并 PR
- 76
描述
The automatic generation of `__init__.py` files has been a source of odd, surprising, and incorrect behavior. e.g. it makes directories importable that shouldn't be importable. This is because it's logic is extremely simple: create an init.py file in every parent directory for a path that ends with .py or .so.
It's also expensive: it requires flattening the runfiles at analysis time.
Some of the venv site package work incidentally side-steps this because the way it creates symlinks "hides" some of the paths from the regular set of runfiles.
Addressing this is a bit more complicated because the incompatible_default_to_explicit_init_py lives in bazel, but the usage is in rules_python.
In any case, I think the todo list is:
1. [x] Add a rules_python flag to replace incompatible_default_to_explicit_init_py
2. [ ] Disable the behavior by default
3. [ ] Remove the dead code paths
Users can use `--flag_alias` to map (1) to the bazel builtin flag.
This is the rules_python side of https://github.com/bazelbuild/bazel/issues/7386
贡献指南
调研方向
首先跟踪 rules_python 对 Bazel 的 incompatible_default_to_explicit_init_py flag 的使用情况,以及会自动创建 __init__.py 文件的 runfiles 分析逻辑。检查 venv site package 的符号链接行为和相关的 Bazel issue。完成的标准是默认禁用该行为,并移除因此变成死代码的代码路径,同时不破坏 package 处理。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- build-system
- Issue 类型
- 重构
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100