Skip to main content
Version: 1.0.0 (latest)

common.runners.venv

Venv Objects

class Venv()

[view_source]

Creates and wraps the Python Virtual Environment to allow for code execution

__init__

def __init__(context: types.SimpleNamespace, current: bool = False) -> None

[view_source]

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"

[view_source]

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"

[view_source]

Restores Virtual Environment at venv_dir

restore_current

@classmethod
def restore_current(cls) -> "Venv"

[view_source]

Wraps the current Python environment.

delete_environment

def delete_environment() -> None

[view_source]

Deletes the Virtual Environment.

run_command

def run_command(entry_point: str, *script_args: Any) -> str

[view_source]

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

[view_source]

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

[view_source]

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

[view_source]

Checks if we are running in virtual environment

is_venv_activated

@staticmethod
def is_venv_activated() -> bool

[view_source]

Checks if virtual environment is activated in the shell

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.