dlt.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
set_pip_tool
@staticmethod
def set_pip_tool(pip_tool: str) -> ContextManager[None]
Sets pip tool in context manager, not thread safe
get_pip_tool
@staticmethod
def get_pip_tool() -> str
Gets configured tool to manage python packages, using DLT_PIP_TOOL or by
autodetecting uv and pip.