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 目錄路徑。 |
字段
虛擬環境
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 對象。 |
獲取軟件包安裝位置
public static String getPackageInstallLocation (IRunUtil runUtil, String virtualenvPath)
獲取 python 包安裝位置。
此方法將調用 /path/to/venv/bin/pip3 show pip 並從 stdout 輸出中解析出包位置。
參數 | |
---|---|
runUtil | IRunUtil :用於運行命令的實用程序對象。 |
virtualenvPath | String : 創建的 virtualenv 目錄的路徑。 |
退貨 | |
---|---|
String | 一個字符串,表示安裝 Python 包的位置的絕對路徑。 |
獲取PythonBinDir
public static String getPythonBinDir (String virtualenvPath)
獲取 python bin 目錄路徑。
此方法將檢查目錄是否存在。
參數 | |
---|---|
virtualenvPath | String |
退貨 | |
---|---|
String | str,venv中python bin目錄的路徑。 |
投擲 | |
---|---|
| 如果 arg virtualenvPath 為空。 |
| 如果 /path/to/venv/bin 不存在。 |