Skip to main content

Manage virtual environments

Project description

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:

  • {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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dephell_venvs-0.1.15.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

dephell_venvs-0.1.15-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file dephell_venvs-0.1.15.tar.gz.

File metadata

  • Download URL: dephell_venvs-0.1.15.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0

File hashes

Hashes for dephell_venvs-0.1.15.tar.gz
Algorithm Hash digest
SHA256 e903fb4b40d81be04066b590a2c27fbb9bfa376005e22bcb70b86bcc3c089353
MD5 e7d8b8db04672f1d7597de1423b830b8
BLAKE2b-256 c0ecc58c7ac91fa65311e52a23afed8a320cb702ed1fbd0e3e44243731be1699

See more details on using hashes here.

File details

Details for the file dephell_venvs-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: dephell_venvs-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.7.0

File hashes

Hashes for dephell_venvs-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 c2105e3c19b2821ac3d8d407dd6d48c98ad0b862741a35993b5084cb8bcc017a
MD5 a2c53049eacbfb55c6d0cffd0a476fca
BLAKE2b-256 b69cca83f185b30cd2ce4bf15b37e1d26a5876880a439e65dd5b021c259e30a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page