dephell / dephell_venvs

Manage virtual environments
MIT License
1 stars 1 forks source link
dephell python venv virtualenv

Dephell VEnvs

travis appveyor MIT License

Manage Python virtual environments.

Installation

Install from PyPI:

python3 -m pip install --user dephell_venvs

Get venv from manager

from pathlib import Path
from dephell_venvs import VEnv, VEnvs

# pass here path with substitutions:
venvs = VEnvs(path=Path() / '{project}-{digest}' / '{env}')

VEnvs gets argument path that is path to the virtual environment with substitutions:

Ways to get VEnv object from VEnvs:

Example:

venv = venvs.get(project_path=Path('dephell_venvs'), env='pytest')
# VEnv(path=PosixPath('dephell_venvs/pytest'), project='dephell_venvs', env='pytest')

Manage venv

VEnv can be got from VEnvs ot created manually:

venv = VEnv(path=Path('venv'))

Check existence:

venv.exists()
# False

Create and destroy:

venv.create()
venv.destroy()

Some other useful information:

venv.bin_path
# PosixPath('dephell_venvs-njyT/pytest/bin')
venv.lib_path
# PosixPath('dephell_venvs-njyT/pytest/lib/python3.7/site-packages')
venv.python_path
# PosixPath('dephell_venvs-njyT/pytest/bin/python3.7')

venv.prompt
# 'dephell_venvs/pytest'

venv.python
# Python(path=PosixPath('dephell_venvs-njyT/pytest/bin/python3.7'), version='3.7.0', implementation='python', abstract=False)

For details about Python object see dephell_pythons.