bazel-contrib / bazel-contrib/rules_python

[gazelle] docs issues

オープン
#1,977 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
gazelle help wanted
主要言語
Starlark
スター
688
フォーク
721
平均マージ
15時間 7分
マージ済み PR(30日)
76

説明

# 🐞 Errors in Gazelle docs

### Description

The first code snippet in the [Adding Gazelle to Your Project](https://github.com/bazelbuild/rules_python/blob/main/gazelle/README.md#adding-gazelle-to-your-project) docs has errors.

1. It looks like `python = use_extension("@rules_python//python/extensions:python.bzl", "python")` needs to be added to avoid `ERROR: /.../MODULE.bazel:12:10: name 'python' is not defined`

2. The references to "python3_9" and "python3_9_toolchains" in the `use_repo` and `register_toolchains` calls are causing errors like `ERROR: /.../rules_python_gazelle_plugin~/modules_mapping/BUILD.bazel:3:10: While resolving toolchains for target @@rules_python_gazelle_plugin~//modules_mapping:generator (f0f11f9): invalid registered toolchain '@python3_9_toolchains//:all': No repository visible as '@python3_9_toolchains' from main repository.`

I tried adding an underscore before the "3_9" as per [this docstring](https://github.com/bazelbuild/rules_python/blob/main/python/private/bzlmod/python.bzl#L307) ("A toolchain's repository name uses the format `python_{major}_{minor}`, e.g. `python_3_10`") but that didn't help. I commented all those references out and instead added `python.toolchain(python_version="3.9", is_default=True)`, and seem to have gotten past this error, but I'm not sure if that has the exact same effect as the code that the docs intend you to add.

While in there, would be good to update to a newer version of Python, as 3.9 is several releases old (3.12 is latest stable).

## 🌍 Your Environment

**Operating System:**

reproduced on macOS and Linux

**Output of `bazel version`:**

reproduced on various versions of Bazel 7

**Rules_python version:**

0.33.1

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

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

調査の方向性

gazelle/README.md の「Adding Gazelle to Your Project」にある最初のコードスニペットから始め、Bazel 7 上で rules_python 0.33.1 を使って再現してください。スニペットを python/private/bzlmod/python.bzl と比較し、報告されている toolchain エラーなしで例が動作するように、ドキュメントに記載されているリポジトリ名と Python バージョンを更新してください。

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

評価

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

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

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