bazel-contrib / bazel-contrib/rules_python

Allow to specific python_version in gazelle generated py_binary and py_test rules

Open
#2,749 2 comments 1 reaction 0 assignees View on GitHub
gazelle type: feature request
Dominant language
Starlark
Stars
688
Forks
721
Avg merge
14h 49m
Merged PRs (30d)
81

Description

# 🚀 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.