vpip.venv

Building venvs.

Constants

vpip.venv.GLOBAL_FOLDER: str

Absolute path to the global package venv folder ~/.vpip/pkg_venvs

vpip.venv.PREINSTALLED_PACKAGES: List[str] = ['pip', 'wheel']

These packages are pre-installed by vpip. They are excluded from the lock file. You can update them via update_venv command.

Functions

vpip.venv.get_global_folder(pkg_name)

Get global venv folder for a package.

Parameters:

pkg_name (str) – Package name.

Return type:

str

vpip.venv.iter_global_packages()

Iterate through all venv folders for globally installed packages.

Return type:

Iterator[str]

vpip.venv.get_current_venv()

Get the Venv instance pointing to ./.venv.

Return type:

Venv

vpip.venv.get_global_pkg_venv(pkg)

Get the Venv instance pointing the venv folder of the global installed package.

Parameters:

pkg (str) – Package name. It would also be used as the folder name.

Return type:

Venv

vpip.venv.get_global_script_folders() Iterable[Path]

Return a list of folders. Which are used to write global scripts.

Following paths are checked against env variable PATH:

'~/.local/bin'
'~/bin'
sysconfig.get_path('scripts')

They are only returned if included in PATH.

Classes

class vpip.venv.Builder(system_site_packages=False, clear=False, symlinks=False, upgrade=False, with_pip=False, prompt=None, upgrade_deps=False)

Bases: EnvBuilder

An environment builder that could be used inside a venv.

It also upgrades pip to the latest version after installed.

class vpip.venv.Venv(env_dir)

A helper class that is associated to a venv folder. It allows you to easily activate/deactivate the venv.

Parameters:

env_dir (str) – The target venv folder.

activate(auto_create=False)

Activate the venv. Update PATH and VIRTUAL_ENV environment variables.

Parameters:

auto_create (bool) – If True then automatically create the venv when the folder doesn’t exist.

This function can be used as a context manager that will deactivate() when exited.

create()

Create the venv.

deactivate()

Deactivate the venv.

destroy()

Destroy the venv. Remove the venv folder.

exists()

Check if the folder exists.

Return type:

bool