bazel-contrib / bazel-contrib/rules_python

Remove automatic __init__.py generation (set incompatible_default_to_explicit_init_py to true)

Đang mở
#2,945 12 bình luận 12 reaction 0 người được giao Xem trên GitHub
cleanup core-rules
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ả

The automatic generation of `__init__.py` files has been a source of odd, surprising, and incorrect behavior. e.g. it makes directories importable that shouldn't be importable. This is because it's logic is extremely simple: create an init.py file in every parent directory for a path that ends with .py or .so.

It's also expensive: it requires flattening the runfiles at analysis time.

Some of the venv site package work incidentally side-steps this because the way it creates symlinks "hides" some of the paths from the regular set of runfiles.

Addressing this is a bit more complicated because the incompatible_default_to_explicit_init_py lives in bazel, but the usage is in rules_python.

In any case, I think the todo list is:

1. [x] Add a rules_python flag to replace incompatible_default_to_explicit_init_py
2. [ ] Disable the behavior by default
3. [ ] Remove the dead code paths

Users can use `--flag_alias` to map (1) to the bazel builtin flag.

This is the rules_python side of https://github.com/bazelbuild/bazel/issues/7386

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

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

Hướng nghiên cứu

Start by tracing the rules_python usage of Bazel's incompatible_default_to_explicit_init_py flag and the runfiles analysis logic that automatically creates __init__.py files. Review the venv site package symlink behavior and the related Bazel issue. Done means the behavior is disabled by default and the resulting dead code paths are removed without breaking package handling.

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
build-system
Loại issue
Tái cấu trúc
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổ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.