bazel-contrib / bazel-contrib/rules_python

[proposal] requires_python attribute

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

While having a global Python interpreter choice works fine for small repositories, in large repositories there are potentially considerable code compatibility concerns across interpreter/virtualenv versions and migrations of language versions require supporting split states where some targets have converted and others may not have converted.

Today it's possible to set up multiple Python toolchains and multiple virtualenvs and use build configuration to choose how a given target or group are built/tested and that works fine.

A problem we've encountered is that users who wish to _drop backwards compatibility_ have a hard time doing so in a sound way. Consider a service which has been able to adopt a new interpreter and would like to adopt new language features such as `:=` or `match`. Code which has adopted a syntax extension feature like this is no longer backwards compatible to earlier interpreters which can cause problems both in linting and if there are targets configured for older interpreters which depend on targets that have adopted these features.

The idea I've been kicking around is to extend `PyInfo` with a `requires_python` attribute expressing the interpreter constraint range same as in `setuptools`. It should also be possible for at a minimum the `py_binary` rule implementation to perform a consistency check over all the `PyInfo.requires_python` values and ensure that the rule as defined contains only compatible sources. It would also be desirable to be able to restrict eg. `rules_lint` behavior so that 3.8 linting would be applied only to 3.8 compatible sources; the alternative being choking on 3.11 features.

Thoughts?

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 việc xem xét đề xuất về thuộc tính PyInfo.requires_python và cách py_binary hiện đang xác thực các source của nó. Hãy cân nhắc phạm vi ràng buộc sẽ liên quan như thế nào đến setuptools và liệu rules_lint có thể giới hạn linting chỉ ở các source tương thích hay không. Để được coi là hoàn tất, cần có một thiết kế đã được thống nhất và hành vi kiểm tra tính nhất quán rõ ràng, nhưng issue hiện vẫn chưa đặc tả điều đó.

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ính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/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.