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)[source]#

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

count(value, /)#

Return number of occurrences of value.

index(value, start=0, stop=sys.maxsize, /)#

Return first index of value.

Raises ValueError if the value is not present.

bin: str#

Alias for field number 1

env: str#

Alias for field number 0

inc: str#

Alias for field number 3

lib: str#

Alias for field number 2

class xontrib.voxapi.Vox(force_removals=False)[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(name)[source]#

Activate a virtual environment.

Parameters
namestr

Virtual environment name or absolute path.

active()[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(name, interpreter=None, system_site_packages=False, symlinks=False, with_pip=True, prompt=None)[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. Can be configured via the $VOX_DEFAULT_INTERPRETER environment variable.

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)

prompt: str

Provides an alternative prompt prefix for this environment.

deactivate()[source]#

Deactivate the active virtual environment. Returns its name.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.#
get_binary_path(binary: str, *dirs: str)[source]#
items() a set-like object providing a view on D's items#
keys() a set-like object providing a view on D's keys#
upgrade(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() an object providing a view on D's values#