common.runners.venv
Venv Objects
class Venv()
Creates and wraps the Python Virtual Environment to allow for code execution
__init__
def __init__(context: types.SimpleNamespace, current: bool = False) -> None
Please use Venv.create
, Venv.restore
or Venv.restore_current
methods to create Venv instance
create
@classmethod
def create(cls, venv_dir: str, dependencies: List[str] = None) -> "Venv"
Creates a new Virtual Environment at the location specified in venv_dir
and installs dependencies
via pip. Deletes partially created environment on failure.
restore
@classmethod
def restore(cls, venv_dir: str, current: bool = False) -> "Venv"
Restores Virtual Environment at venv_dir
restore_current
@classmethod
def restore_current(cls) -> "Venv"
Wraps the current Python environment.
delete_environment
def delete_environment() -> None
Deletes the Virtual Environment.
run_command
def run_command(entry_point: str, *script_args: Any) -> str
Runs any command
with specified script_args
. Current os.environ
and cwd is passed to executed process
run_script
def run_script(script_path: str, *script_args: Any) -> str
Runs a python script
source with specified script_args
. Current os.environ
and cwd is passed to executed process
run_module
def run_module(module: str, *module_args: Any) -> str
Runs a python module
with specified module_args
. Current os.environ
and cwd is passed to executed process
is_virtual_env
@staticmethod
def is_virtual_env() -> bool
Checks if we are running in virtual environment
is_venv_activated
@staticmethod
def is_venv_activated() -> bool
Checks if virtual environment is activated in the shell