python / python/cpython

Embedded interpreters: No way to extend `sys.path`

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

還沒有人認領這個 Issue。

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

描述

Feature or enhancement

Proposal:

Setting up an embedded Python interpreter often involves augmenting sys.path with some application-specific subdirectories, so as not to pollute the system's normal Python installation.

Unfortunately, PyConfig only affords either replacing the default path wholesale, or leaving it as-is (via module_search_paths_set). There appears to be no way to augment sys.path with application-specific directories and no documented way to retrieve the default contents of sys.path.

A workable solution might be to enhance cfg.module_search_paths_set so that when it's set to 2 or 3, the application's paths shall be prepended / appended to sys.path instead of replacing it.

Has this already been discussed elsewhere?

I have already discussed this feature proposal on Discourse

Links to previous discussion of this feature:

https://discuss.python.org/t/embedding-how-do-i-extend-sys-path/75734

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

先閱讀 PyConfig 文件以及 issue 中描述的 module_search_paths_set 行為,然後閱讀連結的 Discourse 討論,了解先前的設計背景。確定應如何將應用程式專用路徑與預設的 sys.path 結合,以及文件中應如何描述 API 行為;完成內容應包括已達成共識的實作,以及相應的文件或測試。

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

評估

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

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

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