dephell-venvs


Namedephell-venvs JSON
Version 0.1.18 PyPI version JSON
download
home_page
SummaryManage virtual environments
upload_time2020-10-26 08:13:35
maintainer
docs_urlNone
authorGram
requires_python>=3.5
licenseMIT
keywords dephell packaging venv pipenv virtualenv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## Dephell VEnvs

[![travis](https://travis-ci.org/dephell/dephell_venvs.svg?branch=master)](https://travis-ci.org/dephell/dephell_venvs)
[![appveyor](https://ci.appveyor.com/api/projects/status/github/dephell/dephell_venvs?svg=true)](https://ci.appveyor.com/project/orsinium/dephell-venvs)
[![MIT License](https://img.shields.io/pypi/l/dephell-venvs.svg)](https://github.com/dephell/dephell_venvs/blob/master/LICENSE)

Manage Python virtual environments.

## Installation

Install from [PyPI](https://pypi.org/project/dephell-venvs):

```bash
python3 -m pip install --user dephell_venvs
```

## Get venv from manager

```python
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:

```python
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:

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

Check existence:

```python
venv.exists()
# False
```

Create and destroy:

```python
venv.create()
venv.destroy()
```

Some other useful information:

```python
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](https://github.com/dephell/dephell_pythons).

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "dephell-venvs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "dephell,packaging,venv,pipenv,virtualenv",
    "author": "Gram",
    "author_email": "master_fess@mail.ru",
    "download_url": "https://files.pythonhosted.org/packages/76/79/646c78687f459deb5e7a03568907039cd0c87403540571633b044e53b184/dephell_venvs-0.1.18.tar.gz",
    "platform": "None",
    "description": "## Dephell VEnvs\n\n[![travis](https://travis-ci.org/dephell/dephell_venvs.svg?branch=master)](https://travis-ci.org/dephell/dephell_venvs)\n[![appveyor](https://ci.appveyor.com/api/projects/status/github/dephell/dephell_venvs?svg=true)](https://ci.appveyor.com/project/orsinium/dephell-venvs)\n[![MIT License](https://img.shields.io/pypi/l/dephell-venvs.svg)](https://github.com/dephell/dephell_venvs/blob/master/LICENSE)\n\nManage Python virtual environments.\n\n## Installation\n\nInstall from [PyPI](https://pypi.org/project/dephell-venvs):\n\n```bash\npython3 -m pip install --user dephell_venvs\n```\n\n## Get venv from manager\n\n```python\nfrom pathlib import Path\nfrom dephell_venvs import VEnv, VEnvs\n\n# pass here path with substitutions:\nvenvs = VEnvs(path=Path() / '{project}-{digest}' / '{env}')\n```\n\n`VEnvs` gets argument `path` that is path to the virtual environment with substitutions:\n\n+ `{project}` - last part of the path to the project.\n+ `{digest}` - short hash of full path to the project to avoid collisions.\n+ `{env}` - name of sub-environment because most of project need more than one environment. For example, `tests`, `docs`, `tests-py35`.\n\nWays to get `VEnv` object from `VEnvs`:\n\n+ `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.\n+ `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.\n+ `venvs.current` -- returns current active venv if some venv is active.\n\nExample:\n\n```python\nvenv = venvs.get(project_path=Path('dephell_venvs'), env='pytest')\n# VEnv(path=PosixPath('dephell_venvs/pytest'), project='dephell_venvs', env='pytest')\n```\n\n## Manage venv\n\n`VEnv` can be got from `VEnvs` ot created manually:\n\n```python\nvenv = VEnv(path=Path('venv'))\n```\n\nCheck existence:\n\n```python\nvenv.exists()\n# False\n```\n\nCreate and destroy:\n\n```python\nvenv.create()\nvenv.destroy()\n```\n\nSome other useful information:\n\n```python\nvenv.bin_path\n# PosixPath('dephell_venvs-njyT/pytest/bin')\nvenv.lib_path\n# PosixPath('dephell_venvs-njyT/pytest/lib/python3.7/site-packages')\nvenv.python_path\n# PosixPath('dephell_venvs-njyT/pytest/bin/python3.7')\n\nvenv.prompt\n# 'dephell_venvs/pytest'\n\nvenv.python\n# Python(path=PosixPath('dephell_venvs-njyT/pytest/bin/python3.7'), version='3.7.0', implementation='python', abstract=False)\n```\n\nFor details about `Python` object see [dephell_pythons](https://github.com/dephell/dephell_pythons).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Manage virtual environments",
    "version": "0.1.18",
    "project_urls": {
        "Repository": "https://github.com/dephell/dephell_venvs"
    },
    "split_keywords": [
        "dephell",
        "packaging",
        "venv",
        "pipenv",
        "virtualenv"
    ],
    "urls": [
        {
            "comment_text": "None",
            "digests": {
                "blake2b_256": "a5faf16607d46e79bed41e6f45c61ab701614a4331c8e104b8d710d1b6ba0869",
                "md5": "c0e0ff2331b9ebacd15037fe78eca493",
                "sha256": "bd3ad440702aa9a9dc21bbab9633537fa395296d40451280d40046d9e3372e6d"
            },
            "downloads": -1,
            "filename": "dephell_venvs-0.1.18-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c0e0ff2331b9ebacd15037fe78eca493",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 1872027,
            "upload_time": "2020-10-26T08:13:39",
            "upload_time_iso_8601": "2020-10-26T08:13:39.942160Z",
            "url": "https://files.pythonhosted.org/packages/a5/fa/f16607d46e79bed41e6f45c61ab701614a4331c8e104b8d710d1b6ba0869/dephell_venvs-0.1.18-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "None",
            "digests": {
                "blake2b_256": "7679646c78687f459deb5e7a03568907039cd0c87403540571633b044e53b184",
                "md5": "fdb025b80bed491c652d2df264bc89ea",
                "sha256": "c7307291b754edba325ab27edeb05d85ee4dd2f1487c48872a1ebfc372bf7a2e"
            },
            "downloads": -1,
            "filename": "dephell_venvs-0.1.18.tar.gz",
            "has_sig": false,
            "md5_digest": "fdb025b80bed491c652d2df264bc89ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 1872248,
            "upload_time": "2020-10-26T08:13:35",
            "upload_time_iso_8601": "2020-10-26T08:13:35.285674Z",
            "url": "https://files.pythonhosted.org/packages/76/79/646c78687f459deb5e7a03568907039cd0c87403540571633b044e53b184/dephell_venvs-0.1.18.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-10-26 08:13:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dephell",
    "github_project": "dephell_venvs",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "appveyor": true,
    "lcname": "dephell-venvs"
}
        
Elapsed time: 0.20892s