bazel-contrib / bazel-contrib/rules_python

Allow to specific python_version in gazelle generated py_binary and py_test rules

未关闭
#2,749 2 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看
gazelle type: feature request
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

# 🚀 feature request

### Relevant Rules

### Description

Currently I am using bazel and gazelle to manage a mono repo with multiple python projects.

Some of them using python 3.10 and others are using python 3.11.

When using gazelle with rules_python, I need to manually append `python_version=3.11` to generated py_test rule.

For example

```bazel
# generated by gazelle

py_test(
name = "test_module_a",
srcs = ["module-a/tests/test_module_a.py"],
python_version = "3.11", # manually edit line
deps = [
"//module-a/src/module_a"
],
)
```

### Describe the solution you'd like

We should have a new directive such as `gazelle:python_version` to allow user to override `python_version` attribute in generated `py_test` and `py_binary` rules.

### Describe alternatives you've considered

Gemini also suggested to use a `build_arg` to override default generated rules but it doesn't work.

贡献指南

打开贡献指南

调研方向

首先定位 Gazelle Python 生成以及生成的 py_binary 和 py_test 规则的指令处理入口点。检查现有指令如何影响生成的属性,然后验证 python_version 指令是否会在不进行手动编辑的情况下为这两种规则类型生成所请求的属性。

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

评估

技术栈
python
领域
build-system
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

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