Manage virtual environments
Project description
Dephell VEnvs
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:
{project} - last part of the path to the project.
{digest} - short hash of full path to the project to avoid collisions.
{env} - name of sub-environment because most of project need more than one environment. For example, tests, docs, tests-py35.
Ways to get VEnv object from VEnvs:
venvs.get(project_path, env). Pass here path to the project and sub-environment name and DepHell will substitute them is the path template and return VEnv instance for this path.
venvs.get_by_name(name). Pass only name and this will be substituted as {project} and other substitutions ({digest}, {env}) will be just dropped out.
venvs.current – returns current active venv if some venv is active.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dephell_venvs-0.1.13-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5186e9c8f1090a19e6d2abb30c78fa7c865163cb907e3688ce5402e72b82c7d |
|
MD5 | 8e9e7011ac6fbcd7c293fdb1ec7c3249 |
|
BLAKE2b-256 | fbf4dcc4fb97ad71753156c59ecbd51f047e209bc8e51a0c8a29ccd7f78a5358 |