bazel-contrib / bazel-contrib/rules_python

`runfiles` module name conflicts with PyCharm

Đang mở
#3,714 2 bình luận 2 reaction 0 người được giao Xem trên GitHub
help wanted
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu bằng cách xác định package Python bazel-runfiles và các entry point đóng gói của nó. Xác nhận cách có thể expose implementation thông qua bazel_runfiles trong khi vẫn giữ runfiles làm proxy, sau đó kiểm tra rằng import được đề xuất tránh được xung đột với PyCharm mà không làm hỏng các user hiện tại.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.