Skip to content

Instantly share code, notes, and snippets.

@Kif11
Last active August 31, 2016 06:57
Show Gist options
  • Save Kif11/28a216d27eae2100aa1e0fd978016ae3 to your computer and use it in GitHub Desktop.
Save Kif11/28a216d27eae2100aa1e0fd978016ae3 to your computer and use it in GitHub Desktop.
Bash script to facilitade Python module dependency instalation and environment configuration
#!/usr/bin/env bash
# Get this scrip directory
CURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Set basic environmental variables
export PYTHONPATH="$PYTHONPATH:$CURDIR/lib/python2.7/site-packages"
# Dependencies
DEPENDENCIES=(\
pathlib==1.0.1\
requests==2.10.0\
)
COMMAND="$1"
if [ "$COMMAND" = "" ]
then
python ./app.py
elif [ "$COMMAND" = "test" ]
then
python ./tests/simple_test.py
elif [ "$COMMAND" = "setup" ]
then
# Overide pip command to make it Install to our local directory
function pip () {
shift # get rid of the "install" word
`which pip` install --ignore-installed --install-option="--prefix=$CURDIR" $@
}
PIPLOCALPATH="$CURDIR"
export PKG_CONFIG_PATH=$CURDIR/lib/python2.7/site-packages
# Create folder for Python modules
mkdir -p "$PIPLOCALPATH"
# Install all of the dependencies modules
for i in ${DEPENDENCIES[@]}; do
echo '--------------------------------------------------------------------'
echo 'Installing:' ${i}
echo '--------------------------------------------------------------------'
pip install ${i}
done
else
echo "run script does not know this command"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment