Last active
October 27, 2017 20:32
-
-
Save donato/0ed3969645827130c3b421eac1e76fce to your computer and use it in GitHub Desktop.
Set JW Environment variables
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 | |
# 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