PyRuntime 資訊

回報問題 查看來源 Nightly · 8.4 · 8.3 · 8.2 · 8.1 · 8.0 · 7.6

內含 py_runtime 規則傳回的 Python 執行階段相關資訊。

Python 執行階段是指平台執行階段建構內執行階段。平台執行階段會存取已知路徑的系統安裝解譯器,而建構內執行階段則會指向做為解譯器的 File。在上述兩種情況中,「解譯器」實際上是指任何可執行的二進位檔或包裝函式指令碼,能夠執行在指令列中傳遞的 Python 指令碼,並遵循與標準 CPython 解譯器相同的慣例。

成員

PyRuntimeInfo

PyRuntimeInfo PyRuntimeInfo(interpreter_path=None, interpreter=None, files=None, coverage_tool=None, coverage_files=None, python_version, stub_shebang=None, bootstrap_template=None)

PyRuntimeInfo 建構函式。

參數

參數 說明
interpreter_path stringNone;預設值為 None
新物件 interpreter_path 欄位的值。如果您傳遞 interpreter,請勿為這個引數提供值。
interpreter FileNone;預設值為 None
新物件 interpreter 欄位的值。如果您傳遞 interpreter_path,請勿為這個引數提供值。
files Filedepset;或 None; 預設值為 None
新物件 files 欄位的值。如果傳遞 interpreter_path,請勿為這個引數提供值。如果指定 interpreter,且這個引數為 None,則 files 會改為空白的 depset
coverage_tool FileNone;預設值為 None
新物件 coverage_tool 欄位的值。
coverage_files Filedepset;或 None; 預設值為 None
新物件 coverage_files 欄位的值。如果沒有傳遞 coverage_tool,請勿為這個引數提供值。
python_version 必要
新物件的 python_version 欄位值。
stub_shebang string; 預設值為 None
新物件 stub_shebang 欄位的值。如果為 None 或未指定,則使用 #!/usr/bin/env python3
bootstrap_template 檔案;或 None; 預設值為 None

bootstrap_template

File PyRuntimeInfo.bootstrap_template

要使用的存根指令碼範本檔案。應包含 %python_binary%、%workspace_name%、%main% 和 %imports%。如需更多變數,請參閱 @bazel_tools//tools/python:python_bootstrap_template.txt。

coverage_files

depset PyRuntimeInfo.coverage_files

使用 coverage_tool 時,執行階段所需的檔案。如未提供 coverage_tool,則為 None。 可能會傳回 None

coverage_tool

File PyRuntimeInfo.coverage_tool

如果已設定,這個欄位會是 File,代表用於從 Python 測試收集程式碼涵蓋率資訊的工具。否則為 None。 可能會傳回 None

檔案

depset PyRuntimeInfo.files

如果是建構內建的執行階段,這個欄位是 depsetFile,需要新增至使用這個執行階段的可執行目標的執行檔案 (特別是 interpreter 需要的檔案)。這個欄位不必包含 interpreter 的值。如果是平台執行階段,這個欄位為 None。 可能會傳回 None

口譯人員

File PyRuntimeInfo.interpreter

如果是建構內建的執行階段,這個欄位會是代表解譯器的 File。否則為 None。請注意,建構中的執行階段可以使用預先建構的已簽入解譯器,也可以使用從來源建構的解譯器。 可能會傳回 None

interpreter_path

string PyRuntimeInfo.interpreter_path

如果是平台執行階段,這個欄位是目標平台上解譯器的絕對檔案系統路徑。否則為 None。 可能會傳回 None

python_version

string PyRuntimeInfo.python_version

指出這個執行階段使用的是 Python 主要版本 2 或 3。有效值為 (僅限) "PY2""PY3"

stub_shebang

string PyRuntimeInfo.stub_shebang

「Shebang」運算式會加到執行 py_binary 目標時使用的 Python 啟動程式碼片段指令碼。不適用於 Windows。