Created
April 8, 2015 21:10
-
-
Save do3cc/520c9b0b03466f2bf469 to your computer and use it in GitHub Desktop.
virtualenvwrapper init
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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