bazel-contrib/rules_python

`runfiles` module name conflicts with PyCharm

Open

#3.714 geöffnet am 17. Apr. 2026

Auf GitHub ansehen
 (2 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)Starlark (705 Forks)auto 404
help wanted

Repository-Metriken

Stars
 (679 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

🐞 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 "<input>", line 1, in <module>
  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 <module>
    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.

Contributor Guide