python / python/cpython

Support entrypoint references in -m

Đang mở
#145,495 15 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

interpreter-core stdlib topic-importlib type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

Feature or enhancement

Proposal:

I'd like to adopt entry-points more at my company (we currently have top-level .py files that are often simple redirects to entry-point-style functions), but concern has been raised that there's no simple way for devs to mimic an entry-point invocation without installing their module, which is a hurdle to training. I'd like to extend -m to support entry-point syntax, i.e.

python -m importable.module:entrypoint_function [args...]

This should be roughly equivalent to adding this as a console_scripts entry-point, installing the module, and calling the entry-point from the bin dir:

  • the function will be expected to look at sys.argv to see what's been passed in
  • the first three elements in argv will be replaced with a single entry, so [args...] will be in argv[1:]
Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

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

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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách lần theo cách CPython xử lý dòng lệnh cho -m và so sánh với hành vi của các entry point trong Packaging và console_scripts được mô tả trong đề xuất. Xác nhận sys.argv cần được viết lại như thế nào và điều gì xảy ra với python -m importable.module:entrypoint_function [args...]; được xem là hoàn tất khi cú pháp này gọi hàm với các đối số đã chỉ định và giữ nguyên hợp đồng argv đã nê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
cli
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
Khá rõ ràng
Mức phù hợp với người mới
35/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.