bazel-contrib / bazel-contrib/rules_python

`runfiles` module name conflicts with PyCharm

Aperta
#3,714 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub
help wanted
Lingua principale
Starlark
Stelle
688
Fork
721
Merge medio
15h 7m
PR unite (30g)
76

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by locating the bazel-runfiles Python package and its packaging entry points. Confirm how the implementation can be exposed through bazel_runfiles while preserving runfiles as a proxy, then verify that the proposed import avoids the PyCharm conflict without breaking existing users.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.