Skip to main content

An API for virtualenv/pip

Project description

Build Status Latest version BSD License

virtualenv is a tool to create isolated Python environments. Unfortunately, it does not expose a native Python API. This package aims to provide an API in the form of a wrapper around virtualenv.

It can be used to create and delete environments and perform package management inside the environment.

Full support is provided for Python 2.7 and Python 3.3+.

Installation

The latest stable release is available on PyPi:

$ pip install virtualenv-api

Please note that the distribution is named virtualenv-api, yet the Python package is named virtualenvapi.

Alternatively, you may fetch the latest version from git:

$ pip install git+https://github.com/sjkingo/virtualenv-api.git

Examples

  • To begin managing an environment (it will be created if it does not exist):

from virtualenvapi.manage import VirtualEnvironment
env = VirtualEnvironment('/path/to/environment/name')

You may also specify the Python interpreter to use in this environment by passing the python argument to the class constructor (new in 2.1.3):

env = VirtualEnvironment('/path/to/environment/name', python='python3')
  • Check if the mezzanine package is installed:

>>> env.is_installed('mezzanine')
False
  • Install the latest version of the mezzanine package:

>>> env.install('mezzanine')
  • A wheel of the latest version of the mezzanine package (new in 2.1.4):

>>> env.wheel('mezzanine')
  • Install version 1.4 of the django package (this is pip’s syntax):

>>> env.install('django==1.4')
  • Upgrade the django package to the latest version:

>>> env.upgrade('django')
  • Uninstall the mezzanine package:

>>> env.uninstall('mezzanine')

Packages may be specified as name only (to work on the latest version), using pip’s package syntax (e.g. django==1.4) or as a tuple of ('name', 'ver') (e.g. ('django', '1.4')).

  • A package may be installed directly from a git repository (must end with .git):

>>> env.install('git+git://github.com/sjkingo/cartridge-payments.git')
  • Instances of the environment provide an installed_packages property:

>>> env.installed_packages
[('django', '1.5'), ('wsgiref', '0.1.2')]
  • A list of package names is also available in the same manner:

>>> env.installed_package_names
['django', 'wsgiref']
  • Search for a package on PyPI:

>>> env.search('requests')[0]
('requests', 'Python HTTP for Humans.')

Verbose output from each command is available in the environment’s build.log file, which is appended to with each operation. Any errors are logged to build.err.

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

virtualenv-api-2.1.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

virtualenv_api-2.1.4-py2.py3-none-any.whl (5.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file virtualenv-api-2.1.4.tar.gz.

File metadata

File hashes

Hashes for virtualenv-api-2.1.4.tar.gz
Algorithm Hash digest
SHA256 005d07870bf842c9026bce01ee066338d18238591dfab604d9761694a77a9104
MD5 b27c0a26bd5d1fbfe8929fdc5078158f
BLAKE2b-256 fcd8d57db5b3182662496c9d41e2b4f8af0959cbd107a4eedfc62b23f417b348

See more details on using hashes here.

File details

Details for the file virtualenv_api-2.1.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for virtualenv_api-2.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5b65cb4b36fb28ec77bae4bb1fae35cb8313ffdcbedd92779ac7f45c096a0214
MD5 cf318b1835244c34524da91f1865cfac
BLAKE2b-256 4b28f656de9e69cee316a069dc5b89a4218b17d53973d5c5307e63b8cf749a2d

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