bazel-contrib / bazel-contrib/rules_python
Gazelle python_root directive only adds imports to subfolders
- 主要语言
- Starlark
- 星标
- 688
- 派生
- 721
- 平均合并
- 15 小时 7 分钟
- 30 天内合并 PR
- 76
描述
# 🐞 bug report
### Affected Rule
Gazelle plugin target generation
### Is this a regression?
No
### Description
python targets that do not share root with the workspace needs `imports = [...]` statements added for imports to work correctly. The gazelle plugin supports this through adding `# gazelle:python_root` directives in `BUILD` files that are at the root of python trees. This works great for source files in subfolders, they have attributes like `imports = ["../.."],` added. However the sources files in the root folder itself does not get any imports attribute, while they need to have `imports = ["."]` to work correctly.
## 🔬 Minimal Reproduction
## 🔥 Exception or Error
Target py_binary file fails on run due to missing import.
## 🌍 Your Environment
**Operating System:**
Ubuntu 24.10
**Output of `bazel version`:**
Bazelisk version: v1.25.0
Build label: 8.0.1
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Fri Jan 17 19:16:16 2025 (1737141376)
Build timestamp: 1737141376
Build timestamp as int: 1737141376
**Rules_python version:**
bazel_dep(name = "rules_python", version = "1.1.0")
bazel_dep(name = "rules_python_gazelle_plugin", version = "1.1.0")
**Anything else relevant?**
贡献指南
调研方向
首先跟踪 Gazelle 插件针对包含 `# gazelle:python_root` 指令的 BUILD 文件生成目标的过程,重点关注根目录级别的 Python 源文件和生成的 `py_binary` 目标。比较根目录目标与子目录目标,并验证生成完成后是否在需要的位置添加了 `imports = ["."]`,然后确认该目标能够运行且不会出现缺少导入的失败。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- build-system
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100