bazel-contrib / bazel-contrib/rules_python

[Gazelle][proto] How to automatically resolve protobuf target

Ouverte
#1,703 8 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
gazelle type: feature request
Langage dominant
Starlark
Étoiles
688
Forks
721
Merge moyen
15 h 7 min
PR mergées (30 j)
76

Description

# 🐞 bug report

### Affected Rule

gazelle resolve

### Is this a regression?
No

### Description

I have a python file with a proto definition imported. When I try to use gazelle to auto generate py_library target, it fails to validate dependency. I look into some code in bazel_gazelle/resolve/index.go, no proto target defined in there.

## 🔬 Minimal Reproduction

  

import a.b.c_pb2

and then run bazel run :py_gazelle

## 🔥 Exception or Error

  

gazelle: ERROR: failed to validate dependencies for target "//:check": "a.b.c_pb2" at line 11 from "check.py" is an invalid dependency: possible solutions:
1. Add it as a dependency in the requirements.txt file.
2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
3. Ignore it with a comment '# gazelle:ignore a.b.c_pb2' in the Python file.

"a.b" at line 11 from "check.py" is an invalid dependency: possible solutions:
1. Add it as a dependency in the requirements.txt file.
2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
3. Ignore it with a comment '# gazelle:ignore a.b' in the Python file.

"a" at line 11 from "check.py" is an invalid dependency: possible solutions:
1. Add it as a dependency in the requirements.txt file.
2. Instruct Gazelle to resolve to a known dependency using the gazelle:resolve directive.
3. Ignore it with a comment '# gazelle:ignore a' in the Python file.


## 🌍 Your Environment

**Operating System:**

  

ubuntu 20.04

**Output of `bazel version`:**

  

Bazelisk version: v1.16.0
Build label: 6.2.1
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Jun 2 16:59:58 2023 (1685725198)
Build timestamp: 1685725198
Build timestamp as int: 1685725198

**Rules_python version:**

  

0.25

**Anything else relevant?**
rules_python_gazelle_plugin version
0.28

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez dans bazel_gazelle/resolve/index.go et reproduisez l’échec avec l’exemple `import a.b.c_pb2` montré en utilisant `bazel run :py_gazelle`. Suivez la manière dont `gazelle resolve` valide les dépendances Python et déterminez comment les targets générés par protobuf doivent être reconnus ; le travail est terminé lorsque l’exemple génère une dépendance `py_library` valide sans directive resolve manuelle.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
build-system
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.