Last active
March 15, 2016 22:00
-
-
Save mbaltrusitis/a906de4a3d3a7bd02a06 to your computer and use it in GitHub Desktop.
Get pip and virtualenv into your system Python if they aren't already. This will also create a virtualenv as an example at $APP_Path.
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 | |
APP_PATH=$HOME/app | |
PYTHON_KERNEL=$APP_PATH/venv/bin/python | |
function install_pip { | |
echo -e 'downloading pip...' | |
curl -SLO https://bootstrap.pypa.io/get-pip.py | |
echo -e 'installing pip...' | |
python get-pip.py | |
if [[ -e /usr/local/bin/pip ]]; then | |
echo -e 'pip successfully installed' | |
rm get-pip.py | |
else | |
echo -e 'install failed' | |
fi | |
} | |
function install_virtualenv { | |
echo -e 'installing virutalenv...' | |
echo -e '>> Need sudo to install into system pip! <<' | |
sudo pip install virtualenv | |
if [[ -e /usr/local/bin/virtualenv ]]; then | |
echo -e 'virtualenv successfully installed' | |
else | |
echo -e 'install failed' | |
fi | |
} | |
function check_pip { | |
if ! [[ $(which pip) ]]; then | |
install_pip | |
else | |
echo -e 'pip is installed.' | |
fi | |
} | |
function check_virtualenv { | |
if ! [[ -e /usr/local/bin/virtualenv ]]; then | |
echo -e 'virtualenv is missing.' | |
install_virtualenv | |
else | |
echo -e 'virtualenv is installed.' | |
fi | |
} | |
function create_app_virtualenv { | |
virtualenv $APP_PATH/venv | |
} | |
function virtualenv_demo { | |
$PYTHON_KERNEL -c 'print("Howdy!")' | |
} | |
function main { | |
check_pip | |
check_virtualenv | |
create_app_virtualenv | |
echo -e 'now just point the new kernel >>' $PYTHON_KERNEL '<< at an executable.' | |
echo -e 'Here is an example:\n\n' | |
virtualenv_demo | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment