bazel-contrib / bazel-contrib/rules_python

[gazelle] docs issues

未关闭
#1,977 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
gazelle help wanted
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
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 进行比较,然后更新文档中的仓库名称和 Python 版本,使示例能够正常工作且不会出现报告中的 toolchain 错误。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
build-system, documentation
Issue 类型
文档
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。