Skip to main content
# fabvenv

A fabric utility for creating remote virtual environments, and installing and
updating packages.

The basic use case this covers is logging into a remote host, downloading
virtualenv.py, using it to create a virtual environment for a project,
including installing `pip`, and then installing packages, based on a
"requirements.txt" file.

## Installation

```
pip install fabvenv
```

## Usage

Here is how I define Fabric tasks to create a virtual environment, install
packages, add a directory to the `sys.path` of the python executable, etc.:

```
@task
def venv_create():
require('configured')
venv = fabvenv.Venv(config.venv, config.requirements)
if not venv.exists():
venv.create(config.system_python)


@task
def venv_install():
require('configured')
fabvenv.Venv(config.venv, config.requirements).install()


@task
def venv_upgrade():
require('configured')
fabvenv.Venv(config.venv, config.requirements).upgrade()


@task
def venv_freeze():
require('configured')
fabvenv.Venv(config.venv, config.requirements).freeze()


@task
def venv_remove():
require('configured')
venv = fabvenv.Venv(config.venv, config.requirements)
if venv.exists():
venv.remove()


@task
def venv_pth():
'''
Add the code directory to the virtualenv sys.path.
'''
require('configured')
fabvenv.Venv(config.venv, config.requirements).venv_pth([config.code])
```

## Contribute

Pull requests and issues are welcomed.

## Testing

The file `tests/fabfile.py` is a basic test of using fabric and fabvenv to
create a virtual environment, install a package, upgrade a package, and remove
the virtual environment.

This tests uses an installed version of `fabric` and `fabvenv`. To avoid
having the test conflict with any other installation of `fabvenv`, use a
virtual environment for testing.

Clone fabvenv:

git clone git@github.com:todddeluca/fabvenv.git
cd fabvenv

Install fabric and fabvenv into a virtual environment:

virtualenv ~/tmp/venv
~/tmp/venv/bin/pip install fabric
~/tmp/venv/bin/pip install -e .

The test also assumes that you can do passwordless (keypair) ssh into localhost
as `$USER`.

Run the tests as follows:

cd tests/
~/tmp/venv/bin/fab test_fabvenv

Release files for fabvenv 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fabvenv 0.2.1
File Size Uploaded
fabvenv-0.2.1.tar.gz 3.6 kB Details

Release files / fabvenv-0.2.1.tar.gz

Download URL fabvenv-0.2.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d8c73d27872cff3e253f16d87f6ecbbce8d350561d8851178d41401625a077fd
BLAKE2b-256 checksum
How to use checksums
d7c6a35f52745dd7cfbc4e96795da4e0c3c3d7d273586c7fd5a683acecbf5c04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.2.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page