Skip to content

Instantly share code, notes, and snippets.

@donato donato/jwenv.sh
Last active Oct 27, 2017

Embed
What would you like to do?
Set JW Environment variables
# !/bin/bash
# This has two assumptions
# 1. Virtual environment set up in ~/venv/{project-name}
# 2. Configuration for configuration set up in ~/salt/{project-name}
# Given the name of the project as parameter
# $jwenv mini-batch
function project_name {
if [ -z $1 ];
then
project=`basename $PWD`;
echo $project
else
project=$1;
fi
}
function jwenv {
local project=$(project_name)
here=`pwd`
source ~/venv/$project/bin/activate
export PYENV_BASE=~/venv/$project/
export JWAPP_CONFD=~/salt/$project/
export JWAPP_ROOT=$here
export JWAPP_LOG=$here/logs/
export JWAPP_ENV=local
export JWAPP_VAR=$here/var/
export PYTHONPATH=$here
export BOTO_CONFIG=$here/boto.cfg
export LUIGI_CONFIG_PATH=$here/conf.d/luigi.cfg
echo "JWAPP and PYTHONPATH variables set."
}
function jwenv_init3 {
local project=$(project_name)
jwenv_init $project 3.5
}
function jwenv_init2 {
local project=$(project_name)
jwenv_init $project 2.7.10
}
function jwenv_init {
virtualenv --python=python$2 ~/venv/$1/
mkdir -p ~/salt/$1/
source ~/venv/$1/bin/activate
pip install --upgrade pip
pip install -U -r requirements.txt
print "Virtualenv setup"
jwenv $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.