Python虚拟环境助手
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
公共构造函数
Python虚拟环境助手
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目录的路径。 |
投掷 | |
---|---|
NullPointerException | 如果 arg virtualenvPath 为空。 |
RuntimeException | 如果 /path/to/venv/bin 不存在。 |