bazel-contrib / bazel-contrib/rules_python

Gazelle python_root directive only adds imports to subfolders

オープン
#2,571 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Starlark
スター
688
フォーク
721
平均マージ
15時間 7分
マージ済み PR(30日)
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?**

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Start by tracing Gazelle plugin target generation for BUILD files containing a `# gazelle:python_root` directive, focusing on root-level Python sources and generated `py_binary` targets. Compare root-folder targets with subfolder targets and verify that completed generation adds `imports = ["."]` where needed, then confirm the target runs without the missing-import failure.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。