bazel-contrib / bazel-contrib/rules_python

`runfiles` module name conflicts with PyCharm

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

Descripción

# 🐞 bug report

### Affected Rule

`runfiles`

### Is this a regression?

No

### Description

PyCharm's Python console adds some stuff to the import path including a `runfiles` module. So when users open a project that supports both Bazel and virtual environments using this console, they run into errors like

```
>>> import mytest
Traceback (most recent call last):
File "", line 1, in
File "/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/tmp/PythonProject/mytest/__init__.py", line 1, in
from runfiles import Runfiles
ImportError: cannot import name 'Runfiles' from 'runfiles' (/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/runfiles.py)
```

There doesn't seem to be any way around this other than wrapping `from runfiles import Runfiles` in some `try/except` or similar, which is unfortunate.

What if we had the `bazel-runfiles` package ship its implementation in a `bazel_runfiles` module instead, with `runfiles` remaining and serving as a simple proxy? This would allow affected environments to use

```
from bazel_runfiles import Runfiles
```

which should avoid any naming conflicts.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza localizando el paquete de Python bazel-runfiles y sus puntos de entrada de empaquetado. Confirma cómo se puede exponer la implementación a través de bazel_runfiles manteniendo runfiles como proxy y, a continuación, verifica que la importación propuesta evita el conflicto con PyCharm sin afectar a los usuarios existentes.

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

Evaluación

Stack tecnológico
python
Área
tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.