Vox (xontrib.voxapi)

API for Vox, the Python virtual environment manager for xonsh.

Vox defines several events related to the life cycle of virtual environments:

  • vox_on_create(env: str) -> None

  • vox_on_activate(env: str, path: pathlib.Path) -> None

  • vox_on_deactivate(env: str, path: pathlib.Path) -> None

  • vox_on_delete(env: str) -> None

exception xontrib.voxapi.EnvironmentInUse[source]

The given environment is currently activated, and the operation cannot be performed.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
exception xontrib.voxapi.NoEnvironmentActive[source]

No environment is currently activated, and the operation cannot be performed.

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
class xontrib.voxapi.VirtualEnvironment(env, bin, lib, inc)

Create new instance of VirtualEnvironment(env, bin, lib, inc)

count()
index()

Raises ValueError if the value is not present.

property bin

Alias for field number 1

property env

Alias for field number 0

property inc

Alias for field number 3

property lib

Alias for field number 2

class xontrib.voxapi.Vox[source]

API access to Vox and virtual environments, in a dict-like format.

Makes use of the VirtualEnvironment namedtuple:

  1. env: The full path to the environment

  2. bin: The full path to the bin/Scripts directory of the environment

activate(self, name)[source]

Activate a virtual environment.

Parameters
namestr

Virtual environment name or absolute path.

active(self)[source]

Get the name of the active virtual environment.

You can use this as a key to get further information.

Returns None if no environment is active.

create(self, name, interpreter=None, system_site_packages=False, symlinks=False, with_pip=True)[source]

Create a virtual environment in $VIRTUALENV_HOME with python3’s venv.

Parameters
namestr

Virtual environment name

interpreter: str

Python interpreter used to create the virtual environment.

system_site_packagesbool

If True, the system (global) site-packages dir is available to created environments.

symlinksbool

If True, attempt to symlink rather than copy files into virtual environment.

with_pipbool

If True, ensure pip is installed in the virtual environment. (Default is True)

deactivate(self)[source]

Deactivate the active virtual environment. Returns its name.

get(self, key, default=None)
items(self)
keys(self)
upgrade(self, name, symlinks=False, with_pip=True, interpreter=None)[source]

Create a virtual environment in $VIRTUALENV_HOME with python3’s venv.

WARNING: If a virtual environment was created with symlinks or without PIP, you must specify these options again on upgrade.

Parameters
namestr

Virtual environment name

interpreter: str

The Python interpreter used to create the virtualenv

symlinksbool

If True, attempt to symlink rather than copy files into virtual environment.

with_pipbool

If True, ensure pip is installed in the virtual environment.

values(self)