PyRuntime 資訊

回報問題 查看來源

包含 Python 執行階段的資訊,如 py_runtime 規則所傳回。

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 File;或 None;預設值為 None
新物件 interpreter 欄位的值。如果傳入 interpreter_path,請勿為此引數值。
files Filedepset;或 None,預設值為 None
新物件 files 欄位的值。如果傳入 interpreter_path,請勿為此引數值。如果指定 interpreter 且此引數為 None,則 files 會變成空白的 depset
coverage_tool File;或 None;預設值為 None
新物件 coverage_tool 欄位的值。
coverage_files Filedepset;或 None,預設值為 None
新物件 coverage_files 欄位的值。如果您未同時傳入 coverage_tool,請勿提供這個引數的值。
python_version 必要
新物件 python_version 欄位的值。
stub_shebang string;預設值為 None
新物件的 stub_shebang 欄位值。如未指定或未指定,系統會使用 #!/usr/bin/env python3
bootstrap_template File;或 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

如果這是建構中的執行階段,這個欄位是 Filedepset,必須新增至使用這個執行階段 (特別是 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。