Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 22462

David Winterbottom: Bootstrapped virtualenvs

$
0
0

The excellent virtualenvwrapper supports a postmkvirtualenv script to bootstrap your virtual environments. Here's a useful implementation:

#!/usr/bin/env bash# Grab project name from virtualenv nameNAME=$(basename $VIRTUAL_ENV)# Set terminal title on postactivateecho"title $NAME"> $VIRTUAL_ENV/bin/postactivate

# Change directory to root of project on postactivate. We assume the# mkvirtualenv is being run from the root of the project. This line# will need to edited later if not.echo"cd $PWD">> $VIRTUAL_ENV/bin/postactivate

# Run postactivate now to get the title setsource$VIRTUAL_ENV/bin/postactivate

This ensures that a new virtualenv has a postactivate script which:

  1. Sets the terminal title to that of the virtualenv
  2. Changes directory to the root of the project

By convention, such ...


Viewing all articles
Browse latest Browse all 22462

Trending Articles