PythonVirtualenvHelper
public
class
PythonVirtualenvHelper
extends Object
java.lang.Object | |
↳ | com.android.tradefed.util.PythonVirtualenvHelper |
用於啟用 Python 3 虛擬環境的輔助類別。
摘要
欄位 | |
---|---|
public
static
final
String |
VIRTUAL_ENV
|
公用建構函式 | |
---|---|
PythonVirtualenvHelper()
|
公用方法 | |
---|---|
static
void
|
activate(IRunUtil runUtil, File virtualenvDir)
為 RunUtil 啟用 virtualenv。 |
static
String
|
getPackageInstallLocation(IRunUtil runUtil, String virtualenvPath)
取得 Python 套件安裝位置。 |
static
String
|
getPythonBinDir(String virtualenvPath)
取得 Python bin 目錄路徑。 |
欄位
VIRTUAL_ENV
public static final String VIRTUAL_ENV
公用建構函式
PythonVirtualenvHelper
public PythonVirtualenvHelper ()
公用方法
啟用
public static void activate (IRunUtil runUtil, File virtualenvDir)
為 RunUtil 啟用 virtualenv。
參數 | |
---|---|
runUtil |
IRunUtil :用於執行 virtualenv 啟用指令的公用程式物件。 |
virtualenvDir |
File :代表已建立 virtualenv 目錄的 File 物件。 |
getPackageInstallLocation
public static String getPackageInstallLocation (IRunUtil runUtil, String virtualenvPath)
取得 Python 套件安裝位置。
這個方法會呼叫 /path/to/venv/bin/pip3 show pip,並從 stdout 輸出內容中剖析套件位置。
參數 | |
---|---|
runUtil |
IRunUtil :用於執行指令的公用程式物件。 |
virtualenvPath |
String :已建立的 virtualenv 目錄路徑。 |
傳回 | |
---|---|
String |
字串,代表 Python 套件安裝位置的絕對路徑。 |
getPythonBinDir
public static String getPythonBinDir (String virtualenvPath)
取得 Python bin 目錄路徑。
這個方法會檢查目錄是否存在。
參數 | |
---|---|
virtualenvPath |
String |
傳回 | |
---|---|
String |
str,venv 中 Python bin 目錄的路徑。 |
擲回 | |
---|---|
NullPointerException |
如果引數 virtualenvPath 為空值。 |
RuntimeException |
如果 /path/to/venv/bin 不存在。 |