python / python/cpython

Support entrypoint references in -m

未關閉
#145,495 15 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

interpreter-core stdlib topic-importlib type-feature
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先追蹤 CPython 對 -m 的命令列處理,並將其與提案中描述的 Packaging entry-points 和 console_scripts 行為進行比較。確認應如何重寫 sys.argv,以及執行 python -m importable.module:entrypoint_function [args...] 時會發生什麼;完成的標準是該語法使用指定的引數呼叫函式,並保留所述的 argv 約定。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
cli
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。