Skip to content

Instantly share code, notes, and snippets.

@do3cc
Created April 8, 2015 21:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save do3cc/520c9b0b03466f2bf469 to your computer and use it in GitHub Desktop.
Save do3cc/520c9b0b03466f2bf469 to your computer and use it in GitHub Desktop.
virtualenvwrapper init
#!/bin/bash
# Initialize a directory as a project
# This is script is meant as a companion for users who have a tool like
# checkoutmanager and work with virtualenvwrapper
# It also checks for starzel specific buildout conventions, but works for
# normal buildouts too
# This script is dangerous, it will delete the directory from which it gets
# executed and has no safeguard against it.
# Die on errors
set -e
# Globbing shall match hidden files
shopt -s dotglob
# Find the functions from virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
project_name=`pwd | sed -e 's/.*\///'`
if [[ ! -d $WORKON_HOME/$project_name ]]
then
echo Need to create virtualenv
tmpdir=`mktemp --directory`
mv * $tmpdir
cd ..
rmdir $project_name
mkproject $project_name
mv $tmpdir/* .
fi
# Starzel specific conventions.
# Our buildouts cannot run after a fresh checkout. First you must write your own
# secret.cfg, a file you can't check in and you must either create your own
# local.cfg file or symlink one. local.cfg has descriptions about the local
# environment.
if [[ -f secret.cfg_tmpl ]]
then
if [[ ! -f secret.cfg ]]
then
echo Need to copy secret.cfg example
cp secret.cfg_tmpl secret.cfg
fi
fi
if [[ -f local_develop.cfg ]]
then
if [[ ! -f local.cfg ]]
then
echo Need to create symlink for env description
ln -s local_develop.cfg local.cfg
fi
fi
if [[ ! -f bin/buildout ]]
then
echo Need to run bootstrap
if [[ -f bootstrap-buildout.py ]]
then
python bootstrap-buildout.py
fi
if [[ -f bootstrap.py ]]
then
python bootstrap.py
fi
fi
if [[ ! -f .installed.cfg ]]
then
if [[ -f bin/buildout ]]
then
echo Need to run buildout
./bin/buildout
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment