bazel-contrib / bazel-contrib/rules_python

Gazelle generates py_proto_library with imports attribute when in a non-root python_root

Abierto
#3,494 0 comentarios 0 reacciones 0 asignados Ver en GitHub
gazelle
Lenguaje dominante
Starlark
Estrellas
688
Forks
721
Merge medio
15 h 7 min
PR fusionados (30 d)
76

Descripción

# 🐞 bug report

### Affected Rule

`gazelle`

### Is this a regression?

No, I believe it's a new feature introduced by https://github.com/bazel-contrib/rules_python/issues/2994 and it seems to be not working as expected in the specific situation of this report.

### Description

When using gazelle to generate [`py_proto_library`](https://github.com/bazel-contrib/rules_python/issues/2994), it doesn't work as expected when the proto file is in a subfolder of a python root that differs from the repo root (specified with the directive `# gazelle:python_root`).

Gazelle generates the target with an `imports` attribute, which is not supported and thus the target fails to build.

## 🔬 Minimal Reproduction

https://github.com/regb/issue-reports/tree/main/rules_python/py_proto_imports

## 🔥 Exception or Error

Gazelle runs smoothly but generates the invalid targets, then running build generate this error:



$ bazel build ...
ERROR: /home/regb/vcs/issue-reports/rules_python/py_proto_imports/src/mypackage/BUILD.bazel:10:17: //src/mypackage:example_py_pb2: no such attribute 'imports' in 'py_proto_library' rule
ERROR: package contains errors: src/mypackage
ERROR: package contains errors: src/mypackage: //src/mypackage:example_py_pb2: no such attribute 'imports' in 'py_proto_library' rule
WARNING: Target pattern parsing failed.
ERROR: Skipping '...': Error evaluating '...': error loading package 'src/mypackage': Package 'src/mypackage' contains errors
ERROR: Error evaluating '...': error loading package 'src/mypackage': Package 'src/mypackage' contains errors
INFO: Elapsed time: 0.136s
INFO: 0 processes.
ERROR: Build did NOT complete successfully

## 🌍 Your Environment

**Operating System:**

  

Ubuntun 22.04

**Output of `bazel version`:**

  

8.5.0

**Rules_python version:**

  

1.7.0 (also tested 1.6.3)

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Start with the minimal reproduction at regb/issue-reports/rules_python/py_proto_imports and inspect the generated BUILD.bazel under src/mypackage, focusing on the # gazelle:python_root directive and the generated py_proto_library target. Run Gazelle followed by bazel build ...; done means the generated target no longer contains the unsupported imports attribute and the build succeeds.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
build-system, tooling
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.